Tutorials

Illustration of a compact wheeled robot on a dark floor, with a teal fan of lidar rays stopping at a gold obstacle block and a glass lattice in the background. Simulation only.
Tutorial

How I built a headless ROS 2 and Gazebo CI harness for a teaching safety-stop demo

A portfolio walkthrough of gazebo-robot-ci: a small C++ ROS 2 waypoint follower and teaching safety-stop overlay, tested with gtest and four headless Gazebo Jetty scenarios on GitHub Actions. How to build it, what the recorded CI report shows, and the honest gaps, including GPU lidar with Mesa software rendering. Simulation only. The dashboard is recorded CI output and does not run Gazebo.

Arpan Bom9 min read
ShareXLinkedIn

This is a simulation only

This is a portfolio demo. It is not a real robot, not Nav2, not SLAM, not Gazebo Classic, and not a certified safety function. A small C++ ROS 2 waypoint follower and a teaching safety-stop overlay run headlessly in Gazebo Jetty on GitHub Actions. The GitHub Pages dashboard shows recorded CI output only. It does not run Gazebo in the browser. I did not invent headless Gazebo CI, launch testing, lidar range gating, or contact oracles.

Try the live demo

The fastest way to see the recorded result is the static dashboard on GitHub Pages: https://applycoding.github.io/gazebo-robot-ci/

The page title is "gazebo-robot-ci dashboard (simulation only)." The header repeats "Simulation only." and "Recorded CI output; this page does not run Gazebo." The dashboard loads ci-report.json from the same origin, draws four recorded trajectories, and lists the four scenario rows. It does not open a network connection to a simulator.

The live GitHub Pages dashboard of gazebo-robot-ci, with the simulation-only title, a commit SHA, a 4/4 badge, a trajectory canvas, and four scenario rows. Simulation only. Recorded CI output; this page does not run Gazebo.

Image: docs/demo.png from the Playwright e2e test of the Pages build on commit 8ad8585. Simulation only. applycoding.com.

What the project is

gazebo-robot-ci (repo: applycoding/gazebo-robot-ci, commit 8ad8585) is an original implementation of a small teaching follower plus a headless CI harness, inspired by the projects credited in REFERENCES.md and NOTICE: gazebosim/ros_gz and gz-sim (including DiffDrive, contact sensing, and lidar ideas), ros2/launch and launch_ros testing helpers, the shape of a small C++ ROS 2 node from ros2/examples, sdformat sensor ideas, and GoogleTest via ament. Those are references. I did not copy tutorial worlds, launch files, or robot models.

The stack at this commit is:

Layer Role
grc_robot C++ waypoint follower and safety-stop overlay, unit-tested with gtest and no Gazebo process
grc_bringup Two synthetic worlds, a launch file, and four launch_testing scenarios
Headless gz sim Gazebo Jetty 10.5.0 inside a digest-pinned ros:lyrical-ros-base container on ubuntu-26.04
artifacts/ci-report.json Schema version 1 report plus a 4/4 expectations passed badge
web/ Vite dashboard that renders that recorded report

ROS 2 Lyrical talks to Gazebo Jetty through ros-lyrical-ros-gz 3.0.10 (the exact metapackage string is 3.0.10-1resolute.20260930.020431 in apt-pins.txt). The plan targeted 3.0.12; the Resolute pool on hosted runners served 3.0.10.

The lidar path is also a deviation from the plan. The Lyrical vendor tree has no gz-sim-cpu-lidar-system. The shipped robot model uses type="gpu_lidar" with gz-sim-sensors-system, ogre2, SceneBroadcaster, and Mesa software rendering (LIBGL_ALWAYS_SOFTWARE=1). That is disclosed in DEVIATIONS.md and in the README.

The four scenario gates

Exactly four rows appear in the report. For the two negative cases, pass: true means the test expectation succeeded, not that the healthy follower reached the goal.

  1. s1 reach_goal. Empty plane, waypoint at (4, 0, 0), 20 s of sim. Pass if the robot arrives with xy error at most 0.20 m and yaw error at most 0.30 rad, contact count 0, state arrived, and no scan_timeout.
  2. s2 stop_obstacle. Same start and goal, with a 0.40 m cube centered at (2.0, 0.0, 0.20). Pass if a trip range is recorded strictly below 0.50 m, the stop reason is obstacle, command and speed fall after the trip, contact_count is 0, min circle-to-AABB clearance is at least 0.15 m, and the sampled pose stays short of x = 2.0 m. Reaching the goal is not required.
  3. s2_mutant_expects_contact. Same world, with the obstacle overlay off (safety_stop.enable:=false) and the goal moved to x = 2.2 m so the follower drives into the cube. The plan wanted a robot-box Contacts message. The current gate is weaker: it also accepts geometric overlap (min_clearance_m < 0) when bridged contacts stay empty.
  4. s1_brake_expects_miss. The follower is not started. Zero cmd_vel is published. Pass if, with a healthy clock and odom through 20 s of sim, the pose is not at the goal.

S2 on the obstacle world also launches with stop_distance:=0.515 and latch_release_enable:=false. The default overlay trip in unit tests remains 0.50 m. If the observer misses the following-to-stopped transition, the S2 gate may fill trip_range_m from the run-minimum forward range and accept a final-command and final-speed check instead of the 0.20 s and 1.0 s post-trip windows. The trip threshold, the zero-contact requirement, and the 0.15 m clearance floor were not loosened.

On commit 8ad8585, GitHub Actions run 43024173129 recorded these measured values (not the pass bounds):

Scenario Observed Measured at this SHA
s1 reach_goal final xy error 0.112 m, yaw error about 0 rad, state arrived, contact count 0
s2 obstacle_stop trip range 0.433 m, min clearance 0.330 m, contact count 0, time to stop 3.561 s, state stopped
s2_mutant_expects_contact box_contact min clearance -0.15 m, contact count 0, box_touch_fired false
s1_brake_expects_miss miss_goal state idle, final xy error 4.00 m

The mutant row passed on geometry alone. That weaker gate is disclosed in DEVIATIONS.md.

Build and run locally

CI uses the digest-pinned image ros:lyrical-ros-base@sha256:3224ee150cb02eb89a5e0811bc267b57ed3a91b9c10191df57810726a7e916d7 on ubuntu-26.04 (never ubuntu-latest). A local container session looks like this:

docker run --rm --init --platform linux/amd64 \
  -v "$PWD:/ws" -w /ws --shm-size=1g \
  -e DISPLAY= -e LIBGL_ALWAYS_SOFTWARE=1 \
  ros:lyrical-ros-base@sha256:3224ee150cb02eb89a5e0811bc267b57ed3a91b9c10191df57810726a7e916d7 \
  bash
# inside: source /opt/ros/lyrical/setup.bash, install ros-gz per apt-pins.txt, colcon build, colcon test

The dashboard preview is separate: cd web && npm ci && npm run dev loads sample-report.json. The deployed Pages report must have sample: false. The app does not fall back to the sample on a production build.

A unit job also rejects U+2014, U+2013, and U+2212 in the tree with grep -P before the container build starts.

Results from the tests

On commit 8ad8585, GitHub Actions run 43024173129 completed every job in ci.yml (unit, sim, web, and pages). The actor and triggering_actor were applycoding.

  • The unit job reported 18 gtests passed: 5 follower tests, 11 safety-stop tests, 1 node test, and 1 S2-predicate test (100% tests passed, 0 tests failed out of 4 gtest binaries).
  • gcovr 8.8 measured 82.7% line coverage (129 / 156) on the core-library set only (follower.cpp, safety_stop.cpp, and their headers). The node translation unit is not in that denominator. The floor is 80% (--fail-under-line 80). Branch coverage was 77.4% (82 / 106). Function coverage was 80.0% (12 / 15).
  • The sim job reported 4 passed in 113.44s for the four scenario tests, and the badge text is 4/4 expectations passed.
  • The web job reported Vitest 1 passed (1 file) and Playwright 1 passed (3.1s).
  • The report at this SHA has git_sha 8ad85852df569de70d53b033010b8bf20b1d7a05, runner_image 20261101.186.1, ros_distro lyrical, gz_version 10.5.0, and sample false.

The live Pages site at this SHA returned HTTP 200, and its ci-report.json carried the same SHA and runner image.

License and references

Apache-2.0. Copyright 2026 Arpan Bom. See LICENSE and NOTICE.

NOTICE lists the pinned apt, Node, and Actions dependencies with licenses, including ros-lyrical-ros-gz 3.0.10, Gazebo Jetty libraries pulled by the vendor packages, Mesa (libegl-mesa0 and libgl1-mesa-dri 26.0.8-1ubuntu0.3), GoogleTest 1.17.0-1build1, gcovr 8.8, Vite 8.3.7, Vitest 5.1.0, jsdom 26.1.0, Playwright 1.65.0 with Chrome for Testing 158.0.8127.18, and the GitHub Actions SHA pins. It points at REFERENCES.md for idea-only references.

NOTICE also states that ros-lyrical-rosgraph-msgs and ros-lyrical-tf2-ros are present in the digest-pinned image, Apache-2.0, but that no dpkg-query line was recorded for them in CI. That is an honest gap. This tutorial does not invent those versions.

How this was verified

I ran the standard portfolio-tutorial checks against commit 8ad85852df569de70d53b033010b8bf20b1d7a05 on main.

  • The GitHub repo is not a fork. gh api repos/applycoding/gazebo-robot-ci reports "fork": false.
  • main has three commits, all with author and committer Arpan Bom (applycoding@gmail.com): the original harness commit a21d05e, then 0be8480 and 8ad8585. git log --format=%B main has no Co-authored-by trailers. The only remote branch at this SHA is main.
  • A search of the tree found no third_party, vendor, or external directories, and no "ported from", "adapted from", or "copied from" markers in the authored source. There are no U+2014, U+2013, or U+2212 characters in project-authored files. The unit job's grep -P dash gate ran on this SHA, and a local probe confirmed that injecting each of those three characters would fail the gate, while an ASCII hyphen would not.
  • This is an original implementation of a small teaching follower and a headless Gazebo CI harness, inspired by the projects and references credited above. I did not invent those methods, and I did not copy those sources.
  • At 8ad8585, NOTICE names the direct apt, Node, and Actions pins with licenses, and it points at REFERENCES.md. The README describes GPU lidar with Mesa software rendering, which matches model.sdf and the world plugins. The repo license is Apache-2.0. The LICENSE file is byte-identical to the official Apache-2.0 text from apache.org (sha256 cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30).
  • Commands, paths, APIs, and the numbers in this tutorial were checked against the repo at 8ad8585 and against the live demo. The 18 gtest passes, 82.7% core-library line coverage, 4 passed in 113.44s, Vitest 1 passed, and Playwright 1 passed (3.1s) are from GitHub Actions run 43024173129 on that commit. That run also deployed Pages. The live ci-report.json has git_sha 8ad85852df569de70d53b033010b8bf20b1d7a05 and runner_image 20261101.186.1. The live document title includes "simulation only." Both the actor and the triggering actor of the run are applycoding.
  • Independent checks at this SHA: the S2 gate in run_scenario_test.py still requires trip_range_m < 0.50, contact_count == 0, and min_clearance_m >= 0.15 (unchanged from a21d05e); web/tests/dashboard.test.ts records canvas calls and asserts the mapped geometry for known samples (fill 640 by 360, plot frame 40, 20, 560, 300, and the points (0, 0) and (1, 0.1) at pixel (40, 240) and (152, 232)); the live Pages honesty lines and title match the labels above.
  • This project is a simulation-only portfolio demo. The dashboard is recorded CI output and does not run Gazebo.

Limits

This is a portfolio demo. It is simulation only, on synthetic worlds, and not a certified safety function. The Pages dashboard does not run Gazebo. The lidar used in CI is a GPU lidar with Mesa software rendering, not the CPU lidar from the original plan. The obstacle-world overlay trips at 0.515 m, and S2 holds the latch until the scenario ends. The mutant check can pass on geometry alone when Contacts stay empty; on this SHA it did (min_clearance_m = -0.15, contact_count 0). The S2 timing path may fall back to a final-command and final-speed check if the following-to-stopped transition is missed. Coverage of 82.7% applies to the core follower and safety-stop sources only. NOTICE has no recorded dpkg-query version for ros-lyrical-rosgraph-msgs and ros-lyrical-tf2-ros.