Four layers of test, and what each is for
You will: Know which layer should catch a given bug, and why that layer and not another.
Builds on A test suite people actually run and Scenarios are tests you can watch.
The test pyramid you already use survives contact with robotics, but the layers mean different things. Each one earns its place by what it can catch that the layer below cannot:
| layer | needs | catches | takes |
|---|---|---|---|
make test |
nothing | config, structure, kinematics, the seam, the servo protocol and the hardware interface | under a minute |
make test-ros |
a ROS graph, mock hardware | node startup, interface contracts, limit enforcement, transforms | a couple of minutes |
make test-sim |
Gazebo | spawning, controllers under physics, real-time factor, scenarios | a few minutes |
make acceptance |
Gazebo and the dashboard | the whole sequence, with a report naming the build | a minute or two, plus setup |
Each is slower and less deterministic than the last, which is exactly the order you want to find things in. A bug caught in the fast layer costs seconds. The same bug found in simulation costs a launch, a wait, and a squint at a 3D view. Found on hardware, it can cost a part.
So the working rule is: push every check down to the cheapest layer that can express it. Only what genuinely needs physics goes in the simulation layer — and that layer is real-time-factor sensitive, which is why its steps poll rather than sleep.
It is worth noticing how much ends up in the bottom layer. Geometry, limits, inertia, naming, structure, package boundaries, forward kinematics, readiness logic, the HTTP contract of the dashboard, the servo bus protocol, and what the hardware interface does with a missing, quiet or garbled servo all run with no simulator and no hardware. That is deliberate: those tests run in seconds, so they run constantly.
In the simulation
This page is a kinematic model: no ROS, no physics. So it can show the things the fast layer checks (geometry, limits, where the tool ends up) and not what needs Gazebo. Do a bottom-layer check by hand, then meet one thing only physics can judge.
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.
make drive keysIn this lesson
- Open the tf view in the inspector. It prints what
tf2_echo base_link gripper_frame_linkwould. - Press the ready pose button. The fast suite asserts, from a hand-worked value, that the tool lands at about (0.279, 0, 0.095) m; read the translation and compare.
- Drive the arm into the bench. The lab can only say a link is below the surface; what that contact would do to the arm is a question for physics, the
make test-simlayer.
Joints · SO-101 follower
1–5 joint · , . jog · [ ] jaw · - + step · h home · f frames
the keys of make drive
The buttons do what the keys do: hold one to repeat.
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
Run the fast layer. It needs no robot, so it is the same command.
time make testRun the integration layer against the SO-101. It starts a real ROS graph against mock hardware.
time make test-rosRun the simulation layer. Go and make tea.
time make test-simStart the SO-101 in Gazebo, run the acceptance sequence against it, then copy its report out.
make sim make acceptance make acceptance-reportExpect:
./acceptance.mdin your checkout, naming the commit, the target and every step's result.
When it goes wrong
make test-ros or make test-sim fails on startup with errors about nodes or ports.
Why: A stack from an earlier run is still alive.
Fix: Both targets run make stop first. If you launched something by hand, stop it the same way.
Terms
- Test layer
- A tier of tests defined by what it needs to run — nothing, a ROS graph, a simulator, the whole system — and therefore what it can catch and what it costs.
- Acceptance test
- An end-to-end run of the whole system against a real target, with a report tying the result to the exact build.
Every term in the course: glossary.
Check yourself
Answer in your head first, then open it.
A joint limit in the profile is wrong by 10°. Which layer should catch it?
make test. It is a property of the description and needs no running code at all.
The launch file stops starting the gripper controller. Which layer?
make test-ros — it checks that the documented actions exist on a running graph, and needs no physics to do it.
The robot sinks into the floor when it spawns. Which layer?
make test-sim for the symptom, because only physics shows it. The cause is often cheaper to catch: a wrong inertia or a collision shape below the root is visible in the description alone, to a fast test, before anyone opens Gazebo.
Stretch
Take the last three bugs you fixed in your own work. For each, name the cheapest layer that could have caught it, and the layer that actually did. Where they differ, what would the cheaper test have needed?