Theme
Stage 1 · lesson 4 of 5 · 30 min

The decision everything else rests on

You will: Understand — and prove — why the same code can drive a simulator, a mock or a motor.

The application does not know what it is driving. A physics simulation, a mock, or a physical servo — they are implementations behind one interface, chosen by one argument:

           your code, controllers, tests, dashboard
                             │
              ros2_control / controller_manager
                             │
                  hardware_interface plugin
         ┌───────────────────┼────────────────────┐
   mock_components     gz_ros2_control      threevn_hardware
    (no physics)       (Gazebo physics)    (six bus servos, via
                                           FeetechSystemInterface)

You have made this decision before, every time you put a repository interface in front of a database. The difference in robotics is how tempting the alternatives are, so it is worth naming what the seam is not: not a node that talks serial and republishes topics (that is a private API the simulator does not share); not #ifdef; not two robot descriptions; not a second copy of the controllers for the real robot.

Two of the three implementations ship with ROS. That is why this project could prove the architecture before a single servo was bought. The third is this project's own: FeetechSystemInterface, which talks to the SO-101's six servos over their bus. Which plugin a robot uses for real hardware is a fact about the robot, so it is named in the robot's profile, and the choice is made in one place, describe.py, which builds the description every launch file and test reads.

The decoupling is enforced twice, by tests rather than by a README. A build for the mock or the servos must contain no trace of the simulator. And the package that runs on the robot must never declare a dependency on Gazebo — because if it did, installing it on a robot would pull in the whole simulator, and the claim would be quietly false.

Everything later in this course — Gazebo, a simulated servo bus, the real arm — plugs into this seam. Get it now and the rest is substitution.

In the simulation

Behind the seam, mock, gz or feetech, the application sees the same thing: the same joints, and the same /joint_states. This page is a kinematic stand-in, not any of the three, but what it prints is that shared interface. Command poses and watch only the interface, as your code would.

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, on its /joint_states view. These names and units are the same whatever the target.
  2. Send the arm to pick. Read shoulder_pan, −0.6 rad.
  3. Now send it to place, the mirror pose. Only the sign of shoulder_pan changes.

Do it

  1. Expand the SO-101's description for Gazebo and count the simulator plugin.

    make urdf TARGET=gz 2>/dev/null | grep -c GazeboSimSystem
    

    Expect: 1. If this prints 0, run it again without 2>/dev/null and read what it hid. A description that has not been fetched yet is an error, and an error also counts as zero.

  2. Expand it for the mock and count any reference to the Gazebo bridge.

    make urdf TARGET=mock 2>/dev/null | grep -c gz_ros2_control
    

    Expect: 0. The mock build cannot reach the simulator.

  3. Do the same for the real-hardware target, and find its plugin.

    make urdf TARGET=feetech 2>/dev/null | grep -c "<gazebo"
    make urdf TARGET=feetech 2>/dev/null | grep -c FeetechSystemInterface
    

    Expect: 0, then 1.

  4. Find where the choice is made. Two plugins are fixed in code; the third is named by the robot's profile.

    grep -n -A3 "^VENDOR_PLUGINS" src/threevn_robot_description/threevn_robot_description/describe.py
    grep -n -A1 "^  feetech:" src/threevn_robot_description/config/so101_follower.yaml
    

    Expect: mock and gz in the code, then plugin: threevn_hardware/FeetechSystemInterface in the profile. Swapping in a community driver would be a one-line change to the profile, and no code would change.

  5. Ask for a target this robot does not have.

    make urdf TARGET=esp32
    

    Expect: A refusal naming the targets that do exist: gz, mock and feetech. A mistyped target stops here rather than becoming a robot with no hardware behind it.

  6. Read the boundary test. The package rule is the same for every robot.

    less src/threevn_bringup/test/test_package_dependencies.py
    
You will know it worked when: The Gazebo count is 1, the mock and feetech counts of Gazebo are 0, and you can say where the hardware plugin is named and why it is named there rather than in code.

When it goes wrong

make urdf fails, saying so101.urdf is missing.

Why: The SO-101's description is Apache-2.0 upstream and is not committed to this repository. It is fetched, pinned to one upstream commit and checksummed.

Fix: Run make so101-fetch once. The error message names the same command.

Terms

Hardware seam
The single interface — a ros2_control SystemInterface plugin — between everything that decides what the robot does and whatever actually does it.
Execution target
Which implementation sits behind the seam: mock, gz (Gazebo) or feetech (the real servos). Chosen by one launch argument.

Every term in the course: glossary.

Check yourself

Answer in your head first, then open it.

"The mock build avoids the simulator" and "the mock build cannot reach the simulator" — which does the zero prove, and why does the difference matter?

It proves the stronger one: the dependency is absent, not unused. "Avoids" is a convention someone can break with one import; "cannot reach" is a property a robot install can rely on, because the simulator is never installed.

Why is the seam a ros2_control plugin rather than a node that talks serial and republishes topics?

A bridge node gives the application that node's interface, which differs from the simulator's — so the application would be coupled to its target. The plugin keeps every topic, service and action identical across all three.

Stretch

Add <exec_depend>ros_gz_sim</exec_depend> to src/threevn_bringup/package.xml and run make test. Which test fails, and does its message tell you what to do instead? Revert the change afterwards.

One way to do it

test_bringup_never_depends_on_gazebo fails and names the offending dependency, and says simulator-specific code belongs in threevn_sim, which depends on bringup — not the reverse. git checkout src/threevn_bringup/package.xml restores it.

Going deeper