Theme
Stage 3 · lesson 1 of 7 · 30 min

A simulator that runs in CI

You will: Run Gazebo with no GPU and no display, and confirm every controller came up.

Builds on Docker, and nothing else.

Simulation here is a requirement, not a convenience: almost all of this course must be completable without a robot. That has an architectural consequence. The simulator must run headless, because one that needs a screen cannot run in CI, and a test that cannot run in CI eventually stops being true.

Everything renders in software. There is no GPU inside the container and no X server on a Mac, so physics and rendering share the CPU. The arm can move in something like slow motion when the machine is busy. That is CPU physics, not a fault, and the next lessons explain why it matters and why you should not trust any single measurement of it.

make play starts the SO-101 in headless Gazebo, plus RViz in the browser. RViz shows more than Gazebo's own window would, for less: the robot drawn from its description at the joint positions it reports, which is what every other tool in this course sees too.

In simulation, the controller manager lives inside the Gazebo process, started by a plugin when the robot spawns. So controllers cannot be started until the model exists, and the launch file chains each controller's spawner off the previous one finishing. On a busy machine one of them can still miss its activation window — the pitfall below is the most common thing to go wrong in this whole stage.

In the simulation

RViz draws the arm at the joint positions joint_state_broadcaster publishes; with that controller missing, the picture freezes. This page draws its arm the same way, from its own joint states. It runs no Gazebo and no ROS: it is a kinematic arm, with no physics.

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 /joint_states. This is the topic RViz and the teleop both read.
  2. Drag the shoulder_lift slider back past -0.5 rad (about -29°) and watch its position change in the inspector.
  3. Press h (or the home button). Upper arm vertical, forearm and gripper level, the pose RViz shows first.

Do it

  1. Start the robot.

    make play
    

    Expect: Launch output scrolling, then quiet. Leave this terminal running.

  2. Open http://localhost:8106/vnc.html in a browser.

    Expect: RViz, with the SO-101 on a grid in its home pose: upper arm vertical, forearm and gripper level. The first frame can take a few seconds.

  3. In a second terminal, check the controllers.

    make shell
    ros2 control list_controllers
    

    Expect: Three controllers, all active: arm_controller, gripper_controller and joint_state_broadcaster.

  4. Check the hardware side of the seam.

    ros2 control list_hardware_components
    

    Expect: One component, so101_follower, active, listing the six position interfaces it has claimed: five arm joints and the gripper. In Gazebo the thing behind them is the physics engine.

  5. When you are done, stop everything from the host.

    make stop
    
You will know it worked when: Gazebo runs headless, RViz shows the arm at port 8106, and all three controllers report active.

When it goes wrong

One controller is missing, with "Switch controller timed out" in the log.

Why: A loaded machine. Activation must complete inside the controller manager's update loop, which runs in a simulator already short of CPU. The launch files allow 30 seconds, but a build or a test run alongside can still starve it.

Fix: Stop the other work, then make stop && make play. Confirm with ros2 control list_controllers every time rather than assuming.

RViz shows the arm frozen in one pose, and the teleop cannot read it.

Why: joint_state_broadcaster is the controller that failed to start, so there is no /joint_states.

Fix: Same as above — restart on a quieter machine and confirm all three.

make play fails at once, saying so101.urdf is missing.

Why: The SO-101's description is fetched, not committed, and has not been fetched on this machine.

Fix: Run make so101-fetch once.

Gazebo disappears mid-run with nothing useful in the log.

Why: Docker's VM ran out of memory.

Fix: Give Docker 6 GB or more; make doctor checks it.

Terms

Headless simulation
Running the physics server with no GUI, so it works on CI runners and in containers with no display.
Software rendering
Drawing frames on the CPU — here with Mesa's llvmpipe — because the container has no GPU.
Controller manager
The ros2_control process that loads controllers and runs the control loop. In simulation it lives inside Gazebo.

Every term in the course: glossary.

Check yourself

Answer in your head first, then open it.

Why must the simulator run headless by default, rather than headless only in CI?

If the default needs a screen, the default is not what CI runs, and the two drift apart. Headless everywhere means one path, tested.

Why can controllers not be spawned as soon as Gazebo starts?

The controller manager is started by a plugin on the robot model. Until the robot has spawned, there is no controller manager to talk to — so spawners are chained off the spawn finishing.

Stretch

Run make play while make test runs in another terminal, a few times. Does a controller ever fail to activate? Write down what you would put in a CI job's setup to make that failure impossible to miss, rather than impossible to happen.

Going deeper