Theme
Stage 2 · lesson 5 of 6 · 30 min

Test it with two parsers, not one

You will: Check a description with independent tools, and know which bugs only raw XML reveals.

Builds on A test suite people actually run.

The description is checked by two parsers written by different people in different languages: urdf_parser_py, in Python, which the unit tests use, and check_urdf, the C++ reference parser that ships with ROS. They have different leniencies, so a disagreement between them is itself a finding.

Some bugs are invisible to any parser, though, and the best example is a duplicated link name. urdf_parser_py builds a dictionary keyed by name, so the second link silently replaces the first and the parsed tree looks perfectly healthy. The duplicate only exists before parsing. So that check reads the raw XML.

This is not hypothetical. On this project's first robot, mounting an arm on a mobile base brought two links called imu_link into one description: not a parse error, just a quiet loss of one of them. A test now asserts both survive.

One more principle is easy to violate without noticing. Every test gets its description from the same function, describe(), with the same arguments that ros2 launch uses at runtime. A test that built its URDF some other way would be testing itself — a description nobody runs.

Here is the honest part. make lint runs check_urdf on every profile named threevn_*.yaml, and the duplicate-name test is parametrised over the same set, so the SO-101's overlay is skipped by both. That is a gap. This lesson has you run the second parser by hand and look at the gap, rather than pretend it is closed.

In the simulation

This page reads upstream's URDF with a parser of its own, written for the site and neither urdf_parser_py nor check_urdf. Where its numbers agree with the ones tf2_echo prints from the running description, that is a third independent reading agreeing.

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

  1. Open Inspect, then its tf view.
  2. Send the arm to ready. The tool should read about x 0.279, z 0.095: the same as tf2_echo on the real stack.
  3. Drag shoulder_pan to its lower limit. The page found that stop in the same <limit> line check_urdf reads.
  4. Switch to /joint_states and read shoulder_pan, −1.9199. One number, two readers, the same answer.

Do it

  1. See why the automatic check skips this robot.

    grep -n "threevn_\*" scripts/check_description.sh
    

    Expect: The loop globs threevn_*.yaml. The SO-101's profile is named so that it does not match, because its description is not built from this project's xacro.

  2. Run the C++ parser on all three of the SO-101's targets, inside the container.

    make shell
    for t in mock gz feetech; do
      ros2 run threevn_robot_description describe so101_follower --target $t > /tmp/so101_$t.urdf
      check_urdf /tmp/so101_$t.urdf > /dev/null && echo "ok    $t" || echo "FAIL  $t"
    done
    

    Expect: ok for mock, gz and feetech.

  3. Check for duplicate link names in the raw XML, the way the suite's duplicate-name test does.

    grep -o '<link name="[^"]*"' /tmp/so101_gz.urdf | sort | uniq -d
    

    Expect: No output: no name appears twice. A parsed model could not have told you, because it keeps only one link per name.

  4. Confirm the launch files and the tests describe the robot the same way.

    grep -n "describe(" src/threevn_robot_description/launch/view_robot.launch.py src/threevn_sim/launch/sim.launch.py src/threevn_bringup/launch/robot.launch.py
    

    Expect: The viewer, the simulator and the real-hardware launch all call describe(). The SO-101's tests call the same function, so they check the description that actually runs.

You will know it worked when: check_urdf accepts the SO-101 on all three targets, no link name is duplicated, and you can say which automatic checks do not cover this robot yet and why.

When it goes wrong

make lint passes and you assume the SO-101 was checked.

Why: The script globs threevn_*.yaml, and a green run only covers what it ran.

Fix: Read the per-profile lines it prints. The SO-101 is not among them until the script learns about vendor arms.

describe fails, and every check_urdf line says FAIL.

Why: The upstream description has not been fetched into vendor/, so there was nothing to check.

Fix: Run make so101-fetch on the host, then try again.

Terms

Independent oracle
A second, separately written implementation used to check the first. Agreement means something; disagreement is a finding.
Shared fixture
One function every test uses to build its input, so all tests check the artefact that actually runs.

Every term in the course: glossary.

Check yourself

Answer in your head first, then open it.

Why does a parsed-model check miss a duplicated link name?

The parser stores links in a dictionary keyed by name, so the second silently overwrites the first. After parsing there is only one — and the tree looks fine.

What is wrong with a test that builds its URDF with slightly different arguments from the launch file?

It checks a description nobody runs. It can pass while the real one is broken.

Stretch

Sketch the change that would put the SO-101 into make lint: how check_description.sh should find vendor arms, which targets it should expand for each, and what it should do when the upstream description has not been fetched, as on a fresh CI runner.

Hint

describe.py has a targets() function, and test_so101_profile.py shows one way to handle a missing description without hiding it.

Going deeper