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
- Open Inspect, on its /joint_states view. These names and units are the same whatever the target.
- Send the arm to pick. Read
shoulder_pan, −0.6 rad. - Now send it to place, the mirror pose. Only the sign of
shoulder_panchanges.
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
Expand the SO-101's description for Gazebo and count the simulator plugin.
make urdf TARGET=gz 2>/dev/null | grep -c GazeboSimSystemExpect:
1. If this prints0, run it again without2>/dev/nulland read what it hid. A description that has not been fetched yet is an error, and an error also counts as zero.Expand it for the mock and count any reference to the Gazebo bridge.
make urdf TARGET=mock 2>/dev/null | grep -c gz_ros2_controlExpect:
0. The mock build cannot reach the simulator.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 FeetechSystemInterfaceExpect:
0, then1.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.yamlExpect:
mockandgzin the code, thenplugin: threevn_hardware/FeetechSystemInterfacein the profile. Swapping in a community driver would be a one-line change to the profile, and no code would change.Ask for a target this robot does not have.
make urdf TARGET=esp32Expect: A refusal naming the targets that do exist:
gz,mockandfeetech. A mistyped target stops here rather than becoming a robot with no hardware behind it.Read the boundary test. The package rule is the same for every robot.
less src/threevn_bringup/test/test_package_dependencies.py
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_controlSystemInterfaceplugin — between everything that decides what the robot does and whatever actually does it. - Execution target
- Which implementation sits behind the seam:
mock,gz(Gazebo) orfeetech(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.