Check a number you did not derive
You will: Check an inertia tensor you did not compute, and know what a wrong one does to a simulation.
Builds on One source of physical truth.
An inertia tensor describes how a body's mass is distributed — how hard it is to spin about each axis. Physics engines need one for every link. If it disagrees with the shape it describes, nothing throws: the engine turns the disagreement into NaN the first time something touches something else, or into a simulation that "explodes", which looks like an unstable simulator rather than a wrong number.
The usual rule is never to type a number you can derive: compute each tensor from the same mass and dimensions that produced the geometry, so it cannot contradict the shape. The SO-101 reverses that. Its inertias are upstream's, exported from CAD, and nothing in this project derived them. So the lesson becomes check a number you did not derive.
Three checks catch nearly every impossible tensor, with no simulator:
- the tensor is symmetric
- it is positive definite — no axis has zero or negative resistance to rotation
- its principal moments satisfy the triangle inequality — no one moment exceeds the other two combined, which no real body can do
Plus a floor, because a near-zero value is another reliable way to produce NaN on first contact.
A CAD export has failure modes of its own. A part exported in millimetres where metres were meant is out by a factor of a million in inertia. A tensor taken about the wrong point is plausible and wrong. And unlike a box aligned to its axes, a printed part has real off-diagonal terms, so a tensor with zeros there is not automatically right.
The suite runs those three checks on the descriptions this project generates itself, but not yet on the SO-101's, so here you run them by hand. Catching a wrong tensor in a check that takes a second is the cheapest place it will ever be caught.
In the simulation
This page has no masses, no inertia and no gravity: it moves joints at their speed limit, so a bad tensor could never make it explode. What it can show is the one link that failed the checks, gripper_frame_link, and that it is a frame, not a body.
Kinematic: joints move at their real speed limit, but there is no gravity, no load and no physics. That is what the steps below are for.
The SO-101 loads as you reach it.
In this lesson
- Open Inspect, then its tf view. It prints where
gripper_frame_linkis inbase_link. - Roll the wrist past +90°. The tool frame turns with the gripper link, because a fixed joint gives it no motion of its own.
- Turn on Frames and find the tool frame's axes at the tip of the fixed jaw. That is all it is.
- Switch the inspector to /joint_states.
effortis empty; here nothing has mass to push against.
Joints · SO-101 follower
Limits from the description; speed capped at 1.7434 rad/s, the servo's datasheet derated. Poses from the profile.
Inspector
Code
The repository's own code behind what you do here appears once you move the arm.
Do it
Look at upstream's inertia tensors.
make urdf 2>/dev/null | grep "<inertia " | head -8Expect: Non-zero
ixy,ixzandiyzon most links. CAD exports a tensor about each link's own frame, not about its principal axes, so the off-diagonal terms are real. A box aligned to its own axes would have zeros there.Confirm this project left them exactly as upstream wrote them.
diff -w <(grep "<inertia " vendor/so101/so101.urdf) \ <(make urdf 2>/dev/null | grep "<inertia ") echo "exit status: $?"Expect:
exit status: 0. Every tensor is upstream's.Run the three checks on every link, inside the container.
make shell ros2 run threevn_robot_description describe so101_follower > /tmp/so101.urdf python3 - <<'PY' import xml.etree.ElementTree as ET import numpy as np total = 0.0 for link in ET.parse('/tmp/so101.urdf').getroot().iter('link'): inertial = link.find('inertial') if inertial is None: continue total += float(inertial.find('mass').get('value')) i = {k: float(v) for k, v in inertial.find('inertia').attrib.items()} t = np.array([[i['ixx'], i['ixy'], i['ixz']], [i['ixy'], i['iyy'], i['iyz']], [i['ixz'], i['iyz'], i['izz']]]) a, b, c = sorted(np.linalg.eigvalsh(t)) print(f"{link.get('name'):26} positive definite: {a > 0} triangle: {a + b >= c}") print(f'total mass {total:.3f} kg') PYExpect: Seven links pass both checks.
gripper_frame_linkfails positive definite: its tensor is all zeros. Total mass 0.632 kg.Look at the link that failed.
grep -n -A8 '<link name="gripper_frame_link"' /tmp/so101.urdfExpect: A mass of
1e-9and a zero tensor. It is not a body at all: it is the tool frame, on a fixed joint, and upstream gave it a token inertial block.
When it goes wrong
The python3 step fails on import numpy.
Why: You ran it on the host rather than inside the container.
Fix: Run make shell first. The container has numpy; your laptop may not.
A check fails on gripper_frame_link, and the obvious fix is to give it a tensor.
Why: The check assumes every link is a body, and this one is a frame. Gazebo folds links on fixed joints into their parent, so its token mass does nothing there. A tensor typed in to make the check pass would be a number nobody derived.
Fix: Leave upstream's file alone. Teach the check to skip massless frames, and write the reason into the test.
Terms
- Inertia tensor
- A 3×3 matrix describing how a body's mass is distributed about its axes — how hard it is to rotate. Required for every simulated link.
- Positive definite
- For an inertia tensor: every axis resists rotation with a positive moment. A tensor that is not is physically impossible.
Every term in the course: glossary.
Check yourself
Answer in your head first, then open it.
Why can you not check upstream's upper_arm_link by hand the way the lesson checks a box?
It is a printed part with a servo inside, not a box. Its tensor came from integrating a CAD model, and there is no closed form to compare against. What you can check is that it describes a possible body.
gripper_frame_link fails "positive definite". Is that a bug?
Not in the simulation: it is a massless frame on a fixed joint, and Gazebo folds it into its parent. It is a finding about the check, which assumes every link is a body.
Stretch
The suite's inertia tests are parametrised over the profiles this project generates itself, the threevn_*.yaml files, and not the SO-101's. Write down what it would take to run them on the SO-101 too: which fixture would describe it, what the tests should do with a massless frame, and whether a min_inertia floor even makes sense for numbers this project did not choose.
Hint
Look at ALL_PROFILES in src/threevn_robot_description/test/conftest.py, and at how test_so101_profile.py skips when the description has not been fetched.