one robot, two files, nothing skipped

The bumperbot URDF, taken apart until every number makes sense.

Every control sits directly under the 3D view, so we can drag a slider and watch the robot change without scrolling. The explanation is beside it, not above it.

3D: drag to rotate · right-drag or shift-drag to slide · mouse wheel or two-finger pinch to zoom · double-click to reset

part one of four

Walk the file from the top: bumperbot.urdf.xacro

Straight down the real file, one part at a time. Everything a part needs is explained inside that part, so we are never sent somewhere else to find it.

01

What a URDF actually is

Two kinds of thing, and that is all. The robot has six of one and five of the other.

Build it up one entry at a time
link = a partOne solid piece that cannot bend. Six of them: a floor marker, the chassis, two wheels, two casters.
joint = an attachmentNames two parts, says where the second sits relative to the first, and whether it may move. Five of them.
The rule that makes it a tree

Every joint has a parent and a child. A part can be the child of only one joint, so nothing is ever attached twice. Follow the parents upward and we always arrive at one part that has no parent. Here that is base_footprint.

This is why positions are easy. We never give a part a position in the world. We only say where it sits relative to its parent. Move the chassis and the wheels come along for free.

the robot, written out

The file does not look like this diagram. A link block and the joint that places it are written separately, often far apart. A link says what a part is; a joint says where it goes. We need both before a part exists anywhere.
02

Part 1 of 6: base_footprint, a link with nothing in it

One line, and it proves a link does not have to contain anything.


Read it out loud

“Create a part, call it base_footprint, it is finished.” The /> closes the tag immediately, which is only allowed because there is nothing inside.

No shape, no weight, no appearance

It cannot be seen or touched and it weighs nothing. It is a named point in space: a pin stuck in the floor with a label on it.

So why does it exist?

The tree needs a root with no parent. By convention that root sits flat on the ground directly under the robot, so “where is the robot” has an obvious answer. Navigation software looks for this exact name.

Remember it. Later, when the body height is wrong, the real damage is that base_footprint stops being on the floor, and everything reporting the robot’s position reports it wrong.
03

Part 2 of 6: base_link and the three boxes every real part has

Every part that is actually there contains the same three boxes. See what the three are for and most of the file becomes repetition.

The sentence to hold on to. A part answers three questions for two different audiences: what do I look like (the screen), what do I feel like (the physics engine), and how heavy am I (the physics engine again). Three questions, three boxes. They are allowed to disagree, and on this robot they deliberately do.

04

Part 3 of 6: base_joint, how a part gets a position

Two parts and no connection means the chassis is floating at the world origin, half buried. A joint fixes that, and it has only four things in it.

05

Part 4 of 6: wheel_right_link, where the three boxes stop agreeing

Same three boxes as the chassis. But on a wheel they describe three different shapes in three different places, and now we have the tools to see why.

06

Part 5 of 6: wheel_right_joint, the first joint allowed to move

base_joint was welded shut. This one spins forever, which needs a different type and an axis.

07

Part 6 of 6: the left wheel, and the only things that change

28 lines almost identical to the right wheel. Here is every difference instead of reading them again.

Test it
every difference between the two wheels
LineRightLeftWhy
One rule covers nearly all of it: the left wheel is a mirror image, so anything pointing sideways flips sign. Anything that does not point sideways stays identical.
The trap. The axis does not flip. Both wheels use 0 1 0. The mirroring is already done by the joint position and the visual tilt; flipping the axis too would undo it, and the robot would spin on the spot when told to drive forward. The button under the view tries it.
08

The last two parts: the casters, and a joint that goes down

Two wheels cannot stand up alone. The casters are the feet that stop the robot tipping, and they introduce one new idea: a negative Z.

09

Now read file 1 straight through: all 155 lines

Real order, nothing skipped, blank lines included so the numbers match a text editor. Click any line.

Why is this line here?

Where is it on the robot?

Change it and…

Go look at this

part two of four

Supporting examples, now that the file makes sense

Short hands-on versions of the ideas we just used. Nothing new to learn: these are for playing with, not for reading.

10

So where did every number come from?

Somebody measured a robot with a ruler and did six divisions. Drag the measurements and watch the file rewrite itself.

What we measure with a ruler
the arithmetic, step by step
which produces exactly these lines

11

Origins, all four side by side

Each origin was explained inside the part that uses it. This is just a bench to compare them on: drag one and watch only its own object move.

Drag each origin and watch only its own thing move
Optional — the long version, already covered in sections 03 and 05
first: what they all have in common

Every origin inside a link is measured from the link’s own zero point, which is wherever the CAD model’s origin ended up. Not from the floor, not from the robot centre, not from the previous tag. The same starting point every time.

So when we see three different numbers inside one link, they are not three different coordinate systems. They are three different answers to “how far from the link’s zero point is my thing?”

second: what each one moves
Origin insideMovesDoes not move
third: the worked example, with the real numbers

Take wheel_right_link. Its joint puts the link’s zero point at y = -0.0701. Now look at where the wheel actually is:

All three boxes are saying the same thing in their own words: “my thing is near the middle of the wheel, about 15 mm further out than the link’s zero point.” They differ slightly because the geometric middle and the centre of mass are not quite the same spot.

fourth: so why is base_link all zeros?

Because its mesh is already centred on the link origin in X and Y, so the picture needs no correction and the contact shape needs none either. But its <inertial> origin is 0 0 0.04, not zero, because the weight is not centred there: the chassis extends from 24.5 mm below the origin to 80 mm above it, so its mass sits high.

how a centre of mass is actually calculated

The inertial origin is the centre of mass, and it is not a mystery. It is a weighted average of position: every bit of the part pulls the balance point toward itself, in proportion to how heavy it is.

the formula, and it is just a weighted averagex̅ = (m₁x₁ + m₂x₂ + …) ÷ (m₁ + m₂ + …) do the same for y and z, and those three numbers are the inertial origin

A worked example we can check in memory. Suppose a wheel is a 40 g rim sitting at 20 mm out along the axle and a 13 g hub sitting at 2 mm out:

That is all the CAD program did, over a few hundred thousand tiny volumes instead of two lumps.

what changes when the balance point moves

Three concrete things, and nothing else:

where gravity pullsThe robot’s weight acts through this point, not through the middle of the shape. Raise it and the same bump tips the robot further.
how easily it tipsThe robot goes over when the balance point passes outside the patch its wheels sit on. The tipping angle in the chassis section is computed from exactly this.
how it rotatesSpin a part and it turns about its balance point, not its origin. Put the balance point off-centre and the part wobbles as it turns.

What it does not change: how the robot looks, where it collides, or where any joint sits. That is why moving the inertial slider leaves the picture untouched.

finding it with no CAD at all

Balance the real part on the edge of a ruler. Mark where it balances, turn it ninety degrees and do it again. Those two lines cross at the centre of mass. For most parts we can simply use the geometric centre, which is close enough for a simulation.

how to decide each one on a new robot
visual originStart at 0 0 0. Load the mesh and look. If it appears in the wrong place or lying on its side, this is the only line that fixes it.
collision originPut the simple shape where the part actually touches things. For a wheel that is the middle of the tread, not the mounting face.
inertial originThe centre of mass. CAD prints it. With no CAD, use the geometric centre of the part, which is close enough for a simulation.
joint originA measured distance between two parts, taken with a ruler. This is the only one that moves the part itself.
12

Inertia, in one picture

Two weights on a bar. Slide them outward and the number climbs far faster than the distance does. That square is the whole idea.

Two weights on a bar: drag them in and out
Optional — formulas, the hand-check, and a calculator that writes the tag
1. what it is, in one sentence

Mass is how hard something is to push. Inertia is how hard it is to twist. They are separate properties and we need both.

A broom weighs almost nothing, so it is easy to push along. Spinning it end over end and it resists. Low mass, high inertia. Held in the middle instead, it spins easily: suddenly it is easy. Same broom, same mass, different inertia, because we changed where the mass sits relative to the axis.

2. the formula, and why distance is squared

Inertia is the sum of every bit of mass multiplied by the square of its distance from the axis.

the whole ideaI = Σ m r² mass times distance-from-the-axis, squared, added up over the whole part

That square is why it matters so much where the mass is. Move a weight twice as far out and it contributes four times as much. Drag the sliders on the left and watch the number climb far faster than the distance does.

3. formulas for the shapes we will actually use
ShapeAbout which axisFormula
4. the proof: the wheel, worked by hand

A wheel is close enough to a solid disc. The file gives mass and the mesh gives the radius and thickness, so we can compute what the inertia should be and compare it with what CAD wrote.

Within about 5 to 11 percent. The small excess is real: a tyre carries extra rubber at the rim, and mass further from the axis raises inertia. So the wheel numbers in the file are trustworthy, and now we know how to check that rather than take it on faith.

5. the check that needs no CAD at all

Every inertia has a hard ceiling. The most inertia a part can possibly have is when all of its mass sits at the furthest corner from the axis. Anything above that is impossible.

the sanity checkImax = m × r⊂max² and k = √(I / m) must be smaller than the part

That second one, k, is the radius of gyration: the distance the whole mass would sit at if we squashed it into a ring. It must be smaller than the part’s own half-width, always.

6. run the check on the own file
Inertia calculator and sanity checker

7. the cross terms, briefly

The six numbers are a 3×3 table folded in half. ixx iyy izz on the diagonal are resistance about each axis. ixy ixz iyz are the products of inertia, and they measure lopsidedness: they are zero for a part that is symmetric about its axes, and grow when it is not. In the wheel they are around 1e-10, which is the file showing the wheel is almost perfectly symmetric. We will almost never set these by hand; leaving them at 0 is normal and fine.

13

The inertial rpy, on a slider

The fix was explained on the chassis in section 03. This is a bench for it: rotate the frame and watch how little the numbers actually move.


rotate the inertia frame and watch the tensor change
Optional — the full reasoning, already covered in section 03
the xyz: where the weight balances

This one appeared on the chassis, in section 03. 0 0 0.04 means the centre of mass sits 40 mm above the link origin. We get it from the CAD mass-properties panel, from the weighted-average formula, or by balancing the part on a ruler. It is a position.

the rpy: which way the inertia frame is turned

This one is not a position and not an orientation of the part. It answers a narrower question: the six numbers in <inertia> were measured along some set of axes. Which axes?

An inertia tensor only means something relative to a set of axes. Write the same physical chassis along different axes and we get six different numbers for the same object. The rpy tells the simulator which axes these six numbers belong to, so it can convert them into the link’s own axes before using them.

which means there are exactly two correct ways to fill this in
Stylerpythe six inertia valueswhen to use it
Style A is what we want, nearly always. Ask CAD for the tensor about the centre of mass with the output axes set to match the link frame, paste all six numbers, and write rpy="0 0 0". Done. Style B only appears when a datasheet gives us three principal moments and nothing else.
now hold the file up against that

The base_link does both at once, which is not either style:

A non-zero rpy says “my numbers are in a rotated frame”, and a rotated frame that is the principal frame is exactly the one where ixy, ixz and iyz are zero. The file supplies a rotation and three non-zero products. That combination is legal URDF, and it is not automatically wrong: rpy simply declares which axes the six values were measured along, and a tensor can carry cross terms in that frame. What makes it suspect here is the evidence, not the syntax.

I checked whether the rotation at least matches the tensor. The smallest rotation that would actually diagonalise these six numbers is about 12 degrees, as rpy = -0.004 -0.164 -0.130. The file writes 22 degrees, as rpy = 0.0 0.25 0.3. Same family, right pattern of no roll with some pitch and yaw, but the wrong magnitudes and the wrong signs. It reads like a principal-axis rotation that was rounded and sign-flipped on its way into the file.

so how much damage does it do?

Almost none, which is why nobody noticed. Drag the sliders and watch: at the file’s values the diagonal shifts by about a fifth of a percent. The products of inertia change more, but they were already small enough not to matter for a robot that only ever turns about Z.

What to actually do about it. Set rpy="0.0 0.0 0.0" and leave the six numbers exactly as they are. That makes the line say what the exporter almost certainly meant: “these six values are measured along the link’s own axes, about the centre of mass.” It is the honest version of the same data, and it removes a contradiction a reviewer would otherwise query. Note this is a separate problem from the magnitude issue in section 12: the tensor is also about 2.6 times larger than physically possible, and fixing the rpy does not fix that.
and why is it zero on every other part?

Look at the wheels and the casters: all of them say rpy="0 0 0". Those are Style A, done correctly. Only base_link carries this rotation, which is another reason to treat it as a slip in that one export rather than something meaningful.

14

Which numbers come from CAD, and which are chosen

One table, sorted into three columns. Worth a skim even if nothing else here is.

ValueWhere it comes fromThe job
How to get the CAD half out of SolidWorks. Open the part, then Tools → Evaluate → Mass Properties. That panel prints the mass, the centre of mass, and the full inertia tensor. Set the output coordinate system to the link origin we are exporting about, not the default, or the inertial origin will be measured from the wrong place. The sw2urdf exporter reads exactly this panel, which is why the numbers in the file have sixteen decimal places.
And if we have no CAD at all. Weigh the part on a kitchen scale, measure it with calipers, pick the closest shape from the formula table above, and compute the three diagonal inertias. Set the three cross terms to 0. That is a perfectly respectable URDF, and for a robot this size it will behave almost identically to the exported one.
part three of four

The second file: bumperbot_gazebo.xacro

File 1 described the robot. This one describes what happens when it touches the floor. Same treatment, same order.

15

What this file is, and how it gets in

Line 6 of file 1 is the hinge between the two files.

The four points file 2 talks about

What that line does

A copy-paste carried out before ROS ever sees the file. Xacro finds the package, opens that file, and drops its contents in at that spot. By the time the robot loads there is only one description containing both files.

So why not write it all in one file?

Because the two answer different questions and change at different times. File 1 changes when we redesign the robot. File 2 changes when the robot slips and we tune it. Keeping them apart means tuning physics cannot break the geometry.

The four blocks inside

One per part that touches the ground: two wheels, two casters. Nothing is addressed to the chassis, because the chassis never touches anything.

The whole file in one sentence: give the drive wheels absurd grip so they never slip, and give the casters almost none so they slide while the robot turns.
16

The wheel block, setting by setting

Seven settings. Pick one, drag it, drive the robot and see what it was holding together.

17

The caster block, setting by setting

Six settings instead of seven, and every one of them pushed to the opposite extreme from the wheel. Same treatment: pick a setting, see what it is for, and see what the wheel does differently.

Optional: the two blocks side by side in one table
SettingWheelCasterWhy
The missing line. The caster blocks have no fdir1. That line picks which direction mu1 applies along, and it only means something when mu1 and mu2 differ. The caster has equal grip in every direction on purpose, so there is nothing to point at.
18

Where do the Gazebo numbers come from? Nothing measures these.

This is the honest answer, and it is different from file 1. There is no CAD panel, no ruler and no datasheet for mu1, kp, kd, minDepth or maxVel. They are not properties of the robot. They are knobs on the physics solver, and we set them by starting from known-good values and adjusting until the robot behaves.

1. why they cannot be measured

mu1 is the only one with a real-world counterpart, the coefficient of friction, and the file deliberately ignores that counterpart: real rubber is about 0.9, the file says 1e15. The others describe how the solver resolves a contact, not how the robot is built. Ask “what is the kp of my wheel” and the question has no answer outside a simulator.

2. so where did these exact values come from?

They come from the standard set that circulates in ROS differential-drive tutorials and templates. They are a known-good starting point for a small indoor two-wheeled robot, and nearly every bumperbot-style project uses the same figures. That is not a criticism: starting from values known to work and adjusting is the correct method here.

3. sensible starting values, by what the part is for
SettingDrive wheelSliding supportWhat it is doing
4. how these are actually tuned: symptom first

We do not calculate these. We run the simulation, watch what goes wrong, and look up the symptom.

What we seeMost likely causeWhat to change
Change one number at a time, by a factor of ten. These values span fifteen orders of magnitude, so nudging kp from 1e12 to 2e12 does nothing we can see. Move it to 1e11 or 1e13 and watch. When the behaviour flips, we have bracketed the value and can close in.
One number in this file is worth deriving rather than guessing: the caster friction. It exists only to imitate a castor wheel that can swivel. The right value is the lowest one that still lets the robot stop and stay put on a slope. 0.1 is the usual answer. If the robot slides downhill when parked, raise it; if it fights every turn, lower it.
19

Read file 2 straight through: all 45 lines

Why is this line here?

Where is it on the robot?

Change it and…

Go look at this

part four of four

Why it takes both files

A side-by-side test of what each file contributes.

20

Drop one file and watch what breaks

Same command to all three robots: both wheels forward at the same speed. The grey dashed line is where they should go.

Which files is this robot built from?
what each file is responsible for
QuestionAnswered byIf that file is missing
the division of labour
bumperbot.urdf.xacroShape, size, mass and attachment. Everything that would still be true if the robot sat in a box on a shelf.
bumperbot_gazebo.xacroWhat happens at the four points where the robot meets the ground. Everything that only becomes true once it is on a floor.
neither fileMotors, controllers, sensors, topics. Those live in the controller YAML and launch files. A URDF never makes anything move.
The short answer. File 1 describes an object. File 2 describes a relationship between that object and the world. We can build the object without deciding how slippery the floor is, and retune the floor without rebuilding the object.
21

Checkpoint