Navigation turns "go to that spot on the map" into wheel commands that steer around everything the LiDAR and the depth camera can see. This robot uses the stock ROS 2 navigation stack, Nav2, from apt, plus NVIDIA's nvblox for the depth camera, with as few parts of its own as possible: a parameter file, a behaviour tree with two recoveries taken out, a small gate for the depth images, and a supervisor that starts, checks and heals the stack. Navigation runs all the time from boot, and everything that wants to drive waits for it to say "ready" and then sends goals.
The second half of the chapter is about stopping. A robot that drives itself is only as safe as its slowest stop. You'll install a contact reflex, then measure every way the wheels can be stopped, first with the wheels in the air and then on the floor. Do both before you let the robot drive the room. This chapter is also the one with the most failures in this build. They're all in "Doesn't work yet" at the end, and you should read that section before you trust the robot on its own.
Plan on a day for navigation and half a day for the stop proofs.
Nav2 keeps two costmaps. A costmap is a grid over the floor, 5 cm cells here, where each cell holds a number from 0 for free to 254 for lethal, meaning an obstacle is there. It's built in layers. A static layer copies the walls from the map, an obstacle layer marks what the LiDAR sees right now, the nvblox layer marks what the depth camera sees, a keepout filter marks where the robot must never go, and an inflation layer spreads a falling cost around every obstacle so paths keep their distance. The global costmap covers the whole room in the map frame and is used for planning. The local costmap is a 3 by 3 metre window that moves with the robot, in the odom frame, and is used for steering.
The planner finds a route through the global costmap from the robot to the goal. Here that's NavFn, a grid search, about once a second. The controller follows the route. Twenty times a second it tries a few hundred short possible motions, simulates each for 1.7 seconds on the local costmap, scores them for staying near the path, heading for the goal, keeping clear of obstacles and going forward, and sends the best one as a velocity command. This robot uses DWB, Nav2's sampling controller.
What happens when something fails is decided by a behaviour tree, an XML file of small nodes that each return success, failure or running. Changing the XML changes what the robot does when it's stuck, without touching code.
Nav2's servers are lifecycle nodes. Each one starts unconfigured, is told to configure, then to activate. A lifecycle manager walks a list of nodes through those steps. On Humble the manager never retries: if one node fails to come up, the stack stays half alive until someone resets it and starts it again. That's one of the supervisor's jobs.
Commands from the controller don't go straight to the wheels. They pass a velocity smoother, which limits speed and acceleration, then a collision monitor, which slows or stops a command that would hit something the LiDAR sees right now. Only that last stage publishes /cmd_vel. The driver latches an e-stop the moment /cmd_vel has more than one publisher (chapter 6), so inside navigation exactly one node may publish it: the collision monitor.
You need everything from chapter 9 running: the base with the EKF, rf2o and the camera odometry. You need the camera from chapter 7. And you need the CUDA 12.6 libraries from chapter 8's install_vision.sh, because nvblox and the GPU localizer load them without saying so.
You also need chapter 9's map files in ~/maps: the kept graph room.posegraph and room.data, the map's image and YAML room_20260928.pgm and .yaml, and the keepout mask room_live_keepout.yaml and .pgm. Chapter 9 has no tested way to make these for a new room; mine came from an earlier build. There's an optional home pose, ~/maps/home_pose.json, holding {"x": ..., "y": ..., "yaw": ...} in your map's frame. Don't copy mine to your map; it would sit in the wrong place.
All the install scripts read their files from ~/setup on the robot. Copy them there from your laptop, and again each time a script or unit changes:
cd ~/CCode/rosorin-pro
ssh rosorin 'mkdir -p ~/setup/tests'
scp -q scripts/install_isaac_ros.sh scripts/rollback_isaac_ros.sh \
scripts/install_nav2_behaviors_fix.sh scripts/rollback_nav2_behaviors_fix.sh \
scripts/install_nav_service.sh scripts/nav_stop.sh systemd/rosorin-nav.service rosorin:~/setup/
scp -q scripts/tests/nav2_isolated_checks.sh scripts/tests/nav2_isolated_checks.py \
scripts/tests/nav2_bringup_check.sh rosorin:~/setup/tests/
Nav2 comes from the ROS apt repository you added in chapter 6, and chapter 6 already installed it. Run the install anyway as the check that it's there. --no-install-recommends keeps out the desktop and simulation extras:
sudo apt-get install -y --no-install-recommends ros-humble-navigation2 ros-humble-nav2-bringup
On my robot it said 0 upgraded, 0 newly installed, 0 to remove. Then count the held NVIDIA packages, to make sure nothing was upgraded underneath you, and read the versions:
dpkg -l | grep -c "^hi.*nvidia-l4t"
dpkg -l | grep -E "ros-humble-(nav2-(amcl|controller|collision)|dwb-core)" | awk '{print $2, $3}'
The count should be 46: chapter 6's 45 plus the one chapter 8's install holds. The four packages should all be version 1.1.20. Everything in this chapter was measured on 1.1.20. apt serves only the newest build, so if you get a newer release, the nav2_behaviors fix below will refuse to run, by design, and the behaviours I measured may differ.
NVIDIA publishes ready-built Isaac ROS packages for JetPack 6 and Humble in its own apt repository. Two of them are used here. nvblox builds a 3D grid of 5 cm cubes from the depth images on the GPU, cuts a horizontal slice through it and publishes that as a 2D obstacle map, which Nav2's costmaps read through a plugin. So a chair seat, a low box or a table edge that the LiDAR's plane misses, about 16 cm above the floor, still ends up in the costmap. The Occupancy Grid Localizer searches the whole map on the GPU for where one LiDAR scan fits, to give the robot a starting guess.
scripts/install_isaac_ros.sh adds NVIDIA's key and the release-3.0 repository, which is Isaac ROS 3.2 for JetPack 6.2 and Humble. Isaac ROS 5.0 needs a newer JetPack and a different ROS release, so don't use it here. Its apt-get update refreshes only the new list, so nothing else on the robot is touched. It installs nvblox, its Nav2 plugin, the localizer, a scan converter and visual SLAM, plus libnvvpi3 and cuda-nvtx-12-6, two parts of JetPack that this system doesn't otherwise have and that nvblox won't start without. It ends with the cuVSLAM wheel from chapter 9, which it skips when the same version is already installed.
sudo bash ~/setup/install_isaac_ros.sh
It took about a minute on my robot. Then check the versions and that nvblox finds every library it needs:
dpkg-query -W -f='${Package} ${Version}\n' ros-humble-isaac-ros-nvblox ros-humble-nvblox-nav2 ros-humble-nvblox-examples-bringup
source /opt/ros/humble/setup.bash
ldd /opt/ros/humble/lib/nvblox_ros/nvblox_node | grep -c "not found"
ros-humble-isaac-ros-nvblox 3.2.5-0jammy
ros-humble-nvblox-examples-bringup 3.2.13-0jammy
ros-humble-nvblox-nav2 3.2.5-0jammy
0
The 0 means no missing libraries. If you get 12, with libcudart.so.12 among them, chapter 8's CUDA libraries aren't installed. Run its install_vision.sh, which ends with sudo ldconfig, then the ldd line again.
The repo also has scripts/rollback_isaac_ros.sh. Don't run it as it is. It contains apt-get autoremove -y, and on this robot autoremove offers to remove initramfs-tools, which the Jetson needs to boot. To roll back, run its other lines by hand.
AssistedTeleop is one of Nav2's behaviours. A client sends it a velocity, and it projects the robot forward for a second in 0.1 s steps, checks the robot's outline against the local costmap at each step, and slows or zeroes the command if it would hit something. The robot's practice skill drives all its practice moves through it, sideways ones included.
On Humble the sideways part of that projection has the wrong sign. A strafe to the left is checked on the right side. Upstream confirmed it (navigation2 issue #6534) and fixed it on the main branch, but no Humble release has the fix. I measured it on my robot: with a wall on the left, a 0.2 m/s strafe to the left came out at 0.20, not slowed; with the wall on the right, the same strafe was slowed to 0.14, for the wrong side.
scripts/install_nav2_behaviors_fix.sh applies upstream's own two-line change as an overlay: a copy of just the nav2_behaviors package, built in ~/ros2_ws, which shadows the apt build for every process that sources ~/ros2_ws/install/setup.bash. Navigation does. The script refuses to run against any version but 1.1.20. It fetches only that package's folder from the upstream tag, swaps the sign of the two sideways terms in assisted_teleop.cpp, and stops if those lines aren't exactly what it expects, so it never patches a file it doesn't understand. Then it builds the one package. Run it with the wheels disabled:
bash ~/setup/install_nav2_behaviors_fix.sh
It should end like this:
Finished <<< nav2_behaviors [55.9s]
nav2_behaviors now from: /home/burgerbarn/ros2_ws/install/nav2_behaviors
The last line must name ~/ros2_ws/install, not /opt/ros/humble. A plain colcon build in ~/ros2_ws rebuilds the overlay too, which takes about a minute. To go back to the apt build, run bash ~/setup/rollback_nav2_behaviors_fix.sh.
ros2/rosorin_base/config/nav2.yaml is Nav2's stock parameter file with this robot's changes. One rule sets most of the numbers: no reverse. The LiDAR is blind over the rear 65 degrees or so, where the arm tower sits, so navigation never drives the robot backwards. The forward limit is 0.0 to 0.35 m/s, sideways only plus or minus 0.08 m/s, and turning 1.0 rad/s. Sideways stays small because the robot stalls strafing onto the edge of a rug, which it gets over at an angle, and because the camera only sees ahead. The slowest the controller will command is 0.1 m/s and 0.4 rad/s; on the rug, slower commands stall and Nav2 reports it isn't making progress. The same limits are repeated in the velocity smoother, the behaviour server and the driver, and the lowest one wins.
The controller samples 10 forward speeds, 5 sideways and 10 turn rates. It used to try 2000 motions per cycle, which took 95 percent of a core and made it miss its 20 Hz loop nearly every cycle. 500 take 31 percent. Its critics check the whole outline of the robot, not just its centre point, and penalise strafing in favour of driving forward.
A goal counts as reached inside 0.2 m and 0.3 radians. A tighter tolerance of 8 cm made the robot dither for a minute 10 cm from a goal. A goal is aborted when the robot hasn't moved 0.25 m in 10 seconds. The navigator waits up to a second for a service to answer, not the stock 20 ms; clearing the local costmap can take 400 ms on this Jetson, and with the stock value every clear timed out.
The robot's outline comes from the chassis, 30.5 by 23.5 cm, with 1 cm of padding:
footprint: '[[0.155, 0.12], [0.155, -0.115], [-0.15, -0.115], [-0.15, 0.12]]'
footprint_padding: 0.01
The local costmap uses the LiDAR, nvblox and inflation (0.55 m). The keepout filter is on the global costmap only. On the local one, before the robot was placed, the mask landed under the robot and every turn was refused. The global costmap uses the static walls, the LiDAR, nvblox, inflation and the keepout filter, so every planned path respects the mask. The depth camera reaches the costmaps only through nvblox. Feeding its point cloud straight in once marked 38 percent of the global costmap lethal.
A parameter key that no node reads raises no error anywhere. Once an edit deleted the forward speed limit, Nav2 said nothing, and for five runs the robot could only strafe and turn. scripts/tests/check_nav2_config.py exists for that. It checks that each limit is there and in a sane range, that every costmap plugin has parameters, and that the behaviour tree has no Spin or BackUp. Run it on your laptop, in the repo, after any edit and before copying anything to the robot:
cd ~/CCode/rosorin-pro
python3 scripts/tests/check_nav2_config.py
git diff ros2/rosorin_base/config/
nav2.yaml ok: vx 0..0.35, vy -0.08..0.08, wz 1.0
ros2/rosorin_base/bt/navigate_no_backup.xml is Nav2's stock tree with replanning and recovery, with two recoveries removed. What's left is clear the costmaps, wait, try again, which is also what NVIDIA's own reference robot does:
<root main_tree_to_execute="MainTree">
<BehaviorTree ID="MainTree">
<RecoveryNode number_of_retries="6" name="NavigateRecovery">
<PipelineSequence name="NavigateWithReplanning">
<RateController hz="1.0">
<RecoveryNode number_of_retries="1" name="ComputePathToPose">
<ComputePathToPose goal="{goal}" path="{path}" planner_id="GridBased"/>
<ClearEntireCostmap name="ClearGlobalCostmap-Context" service_name="global_costmap/clear_entirely_global_costmap"/>
</RecoveryNode>
</RateController>
<RecoveryNode number_of_retries="1" name="FollowPath">
<FollowPath path="{path}" controller_id="FollowPath"/>
<ClearEntireCostmap name="ClearLocalCostmap-Context" service_name="local_costmap/clear_entirely_local_costmap"/>
</RecoveryNode>
</PipelineSequence>
<ReactiveFallback name="RecoveryFallback">
<GoalUpdated/>
<RoundRobin name="RecoveryActions">
<Sequence name="ClearingActions">
<ClearEntireCostmap name="ClearLocalCostmap-Subtree" service_name="local_costmap/clear_entirely_local_costmap"/>
<ClearEntireCostmap name="ClearGlobalCostmap-Subtree" service_name="global_costmap/clear_entirely_global_costmap"/>
</Sequence>
<Wait wait_duration="5"/>
</RoundRobin>
</ReactiveFallback>
</RecoveryNode>
</BehaviorTree>
</root>
Read it from the inside out. The pipeline runs two things side by side: a new path once a second, and the controller following the latest path. Each has a small recovery of its own. If planning fails, clear the global costmap and plan once more; if following fails, clear the local costmap and follow once more. If the whole pipeline still fails, the outer node retries up to six times, taking turns between clearing both costmaps and waiting five seconds. A new goal cuts the recovery short.
BackUp is gone because it drives backwards 15 cm into the blind rear. When I put it back once, within the hour the robot tried to back out through a screen door. Spin is gone because Nav2 1.1.20 sends its first turn command without any collision check: with a post 3 cm from the robot's nose it turned at full speed for the whole run. A rectangular robot sweeps its corners when it turns. The price is that a robot that ends up inside the inflation ring of a soft obstacle, like a bean bag, can't plan its way out, and clearing changes nothing because the obstacle is marked again at once. The way out is a short sensed crawl in the explore skill, not in the tree.
nvblox loads NVIDIA's stock settings first and config/nvblox.yaml on top. The changes: depth only, no colour and no LiDAR, since the LiDAR is 2D and stays in Nav2's own layers; the slice runs from about 4.5 cm above the floor, so the rug stays floor, up to 60 cm, the top of the robot with the arm in the drive pose. How fast nvblox forgets what it no longer sees stays stock: about 14 seconds. I tried slower forgetting on a recording, and obstacle cells then stayed on floor the robot had driven over.
The camera sits on the arm, and its position in space comes from the arm's joint readings. While the arm moves, those readings don't match the image. Every time the wheels are enabled the driver moves the arm to the drive pose, and in the second that took, nvblox put 73 false obstacle cells on plain rug ahead of the robot. nvblox has no input gate of its own, so a small node, rosorin_base/depth_gate.py, passes a depth frame on only when the arm has been still for 0.6 s. It never decodes the image; it reads the timestamp straight out of the raw message and passes the bytes through untouched, which costs almost nothing. nvblox reads its output, /depth_gate/depth, not the camera.
Stock Nav2 on Humble has three gaps for a robot that keeps navigation running all day. The global costmap waits forever for the robot to have a pose on the map, so the lifecycle manager hangs inside its start-up without an error. The manager never retries a failed start. And "active" isn't "working": three times on my robot every navigation server stopped receiving the map to odom transform while localization kept publishing it, nothing logged it, and the status said ready all night. rosorin_base/nav_supervisor.py fills those gaps with stock calls only. It never moves the robot. It publishes one fact, /nav/status, as a JSON string that every skill reads.
First it places the robot. It turns the map into a distance image, how far every cell is from the nearest wall, and scores a pose by its fit: the share of scan points that land within 10 cm of a wall when the scan is laid down at that pose. It searches every free cell on a 10 cm grid at every 6 degrees, and also checks the pose localization already has, the remembered pose in ~/maps/last_pose.json, the home pose and the GPU localizer's answer. A pose is believed only with a fit of at least 0.65 and at least 0.10 better than the best other place. That second number matters more than the first. On a recording, near a wall, wrong places fit 0.83 to 0.98. A high fit alone protects nothing; the margin does. If no single place explains the scan, the status says lost and it looks again later, less and less often.
Once placed, it starts the navigation servers, and heals them with a reset and a fresh start if they drop. If the manager stops answering for 25 seconds, or a start fails twice, it exits, the launch shuts down, and systemd starts everything again. Every 30 seconds while ready it asks the planner for a path to the robot's own pose, and, with the wheels disabled, sends that path to the controller. A deaf server fails that question. Two failures in a row restart navigation. It also switches slam_toolbox between localization and mapping and keeps the map copies (chapter 9).
A skill waits for it with ros2 run rosorin_base nav_wait [seconds], which exits 0 as soon as the status says ready and is younger than 15 seconds, and exits 1 after the time with the last status printed.
The package is built without --symlink-install, so launch, config and tree files are copied into install/ at build time. Edits in src/ do nothing until you rebuild. After any change on your laptop, check, copy and rebuild:
cd ~/CCode/rosorin-pro
python3 scripts/tests/check_nav2_config.py
rsync -a --exclude __pycache__ ros2/rosorin_base/ rosorin:ros2_ws/src/rosorin_base/
source /opt/ros/humble/setup.bash
cd ~/ros2_ws && colcon build --packages-select rosorin_base 2>&1 | tail -1
Before anything turns a wheel, test the stack where it can't. Every ROS 2 process with the same ROS_DOMAIN_ID sees every other one. The robot's real nodes run on domain 0. Two test scripts set domain 77 and localhost only, start their own copies of the Nav2 servers with the deployed parameter files and the installed binaries, overlay included, and feed them a fake transform, scan and costmap. Whatever they publish on /cmd_vel goes nowhere. nav2_bringup_check.sh starts the five main servers and passes when all reach active; since the navigator loads the tree when it activates, that also proves the tree parses. nav2_isolated_checks.sh puts the behaviour server and the collision monitor in front of fake obstacles, case by case. Stop navigation first if it's already running:
sudo systemctl stop rosorin-nav # only if it is already installed (later in this chapter)
bash ~/setup/tests/nav2_bringup_check.sh
bash ~/setup/tests/nav2_isolated_checks.sh teleop spin cm 2>&1 | grep -v "Ignoring the source\|^JSON\|^\[WARN\]"
sudo systemctl start rosorin-nav # only if it was running
The bring-up check prints:
controller_server active
smoother_server active
planner_server active
behavior_server active
bt_navigator active
--- tree: default_nav_to_pose_bt_xml: /home/burgerbarn/ros2_ws/install/rosorin_base/share/rosorin_base/bt/navigate_no_backup.xml
and the behaviour checks, in m/s and rad/s for forward, sideways and turn:
teleop_free_strafe_left [0.0, 0.2, 0.0]
teleop_wall_left_strafe_left [0.0, 0.14, 0.0]
teleop_wall_right_strafe_left [0.0, 0.2, 0.0]
teleop_wall_ahead_forward [0.14, 0.0, 0.0]
spin_free {'commands': 20, 'first_wz': 1.0, 'max_wz': 1.0}
spin_post_at_nose {'commands': 21, 'first_wz': 1.0, 'max_wz': 1.0}
cm_free_forward [0.2, 0.0, 0.0]
cm_1pt_in_slow_zone [0.2, 0.0, 0.0]
cm_2pt_in_slow_zone [0.12, 0.0, 0.0]
cm_1pt_ahead_0.45 [0.35, 0.0, 0.0]
The left-wall line is the one that proves the fix: a wall on the strafe side slows the strafe to 0.14. The spin_post_at_nose line at full speed is why Spin isn't in the tree; it's expected. The last lines show what the collision monitor really does on Humble: one LiDAR return in the slow zone changes nothing, two slow the robot to 60 percent, and a single return 0.45 m ahead is ignored by the look-ahead. The script prints more collision monitor cases after these. On my robot they read 0.233 for two returns 0.45 m ahead at 0.35 m/s, 0.133 and -0.2 for a strafe toward and away from two returns on the left, and 0.2 for a wall at the nose with the scan silent. That last one means the command passed through untouched. More on that below. If you see behavior_server library: /opt/ros/humble, the overlay isn't built or isn't sourced, and the teleop lines will be mirrored.
scripts/nav_stop.sh disables the wheels first, then stops everything navigation started, by path, with SIGINT and then SIGKILL. Stopping the launch alone once left Nav2 nodes running, and a leftover server then answered for the next run. The unit, systemd/rosorin-nav.service, runs nav_stop.sh both before it starts and after it stops, so no leftover can answer and the wheels are disabled whenever navigation goes down. It requires rosorin-base, so it stops and restarts with the base. systemd never gives up restarting it, and waits 20 seconds before each restart: a stack started within seconds of the old one being killed failed to come up every time I tried, while one started 25 seconds later came up every time. It sources ~/ros2_ws, which brings in the overlay.
Don't type pkill -f "<pattern>" inside an ssh rosorin '...' command. The pattern matches the SSH shell's own command line and kills your session. Run nav_stop.sh as a file, as the unit does.
Navigation reads its map image from ~/maps/room_live.yaml. The supervisor writes room_live.* only while it runs placed and mapping, so make the first one from chapter 9's map. Without it the launch fails at the start with No such file or directory: '/home/burgerbarn/maps/room_live.yaml' and systemd restarts it about every 40 seconds. The [ -f ... ] part does nothing if the file already exists:
cd ~/maps
[ -f room_live.yaml ] || { cp room_20260928.pgm room_live.pgm; sed 's/room_20260928\.pgm/room_live.pgm/' room_20260928.yaml > room_live.yaml; }
head -1 room_live.yaml
ls ~/maps/room.posegraph ~/maps/room_live.yaml ~/maps/room_live.pgm ~/maps/room_live_keepout.yaml
head prints image: room_live.pgm and ls lists all four files. If any is missing, go back to chapter 9 before you install. Then install the service. install_nav_service.sh removes an older keeper unit if there is one, then installs, enables and starts rosorin-nav:
sudo bash ~/setup/install_nav_service.sh
It shows the unit active (running). Check that it's enabled and running:
systemctl is-enabled rosorin-nav; systemctl is-active rosorin-nav
Both lines should say enabled and active. The next thing should be ros2 run rosorin_base nav_wait 120 exiting 0 with "state": "ready". On my build it didn't, and the reason is the first item in "Doesn't work yet".
One thing to know about stopping it. sudo systemctl stop rosorin-nav stops the stack and disables the wheels, but the unit then reads failed, not inactive, because the supervisor shuts ROS down a second time after the launch already has. systemctl start rosorin-nav works anyway. sudo systemctl reset-failed rosorin-nav clears the state first if a script checks it.
While rosorin-nav is up, its collision monitor is a publisher on /cmd_vel even when nothing is driving. The driver counts publishers, not messages, so any other tool that publishes /cmd_vel, like the stop proofs below, trips the e-stop unless you stop navigation first.
The robot's controller board has no stop watchdog. One motor command followed by silence kept my wheels turning for five seconds, until an explicit zero arrived. Every stop in this section is a software stop sent to the board. If nothing sends it, nothing stops. The power switch is the last stop. Know where it is before every test.
The driver stops the wheels for any of these reasons, checked fifty times a second: an e-stop is latched, motion is disabled, no cmd_vel arrived for 0.3 s (the deadman), or no LiDAR scan arrived for 0.5 s while software commands are coming in (the scan gate). Any one of them means zero now, with no ramp. An e-stop is latched by a true on /estop, by any gamepad button except MODE on its very first frame, or by a second cmd_vel publisher. A trip writes the stop frame at once, holds the arm and drops the gamepad to locked. If the driver dies for any reason, even SIGKILL, the launch file runs stop_motors at once and systemd sends the stop frame again after the service stops; the driver then comes back disabled. On top of those, the contact reflex below latches the e-stop when the wheels are commanded and nothing moves, and the collision monitor scales commands near obstacles.
Latched means the stop stays after its cause is gone, until someone clears it. Clearing it with ros2 service call /rosorin_board_driver/reset_estop std_srvs/srv/Trigger, or holding the gamepad's MODE button for two seconds, removes the latch but leaves motion disabled. The wheels move again only after a new enable. Once the robot's own loop, rosorin-mind, runs, it clears an e-stop whose reason is estop topic by itself when no wheel skill is running. Chapter 13 describes that loop, but no chapter installs it with a tested step. A gamepad e-stop it never clears, so a gamepad button is meant to be the stop that keeps the robot stopped, but that was not tested on this build (see "Doesn't work yet"). When the robot must stay stopped, the power switch is the stop to count on. Stop rosorin-mind too if you have it.
Some stops work when the failure itself happens: the deadman stops the wheels when the program sending commands crashes or loses its link, because the commands stop arriving. Those are fail-safe. An e-stop message works only if the message gets through. You need both kinds, and you test each by making the thing it guards against actually happen.
One run is the reason for all this measuring. Early on, during a self-run exploration, my robot touched something and kept rolling. Every software stop was used in turn: disable, e-stop, stopping the base, killing the driver. Each time the software reported the robot stopped, and the driver reported zero body speed. It stopped only when the power was cut. The cause was never found, because the logs were lost with the power cycle; the journal has been persistent since (chapter 4). From then on, "stopped" means what the gyro, the LiDAR and the camera see, timed from the trigger, and every test keeps sending the drive command after the trigger, because the stop has to hold against it.
This robot has no bumpers and no wheel encoders. So "I hit something" is detected as a disagreement: the wheels are commanded to move, and the sensors that see the room say the robot isn't moving. behavior/contact_monitor.py compares the driver's commanded speed with rf2o and the camera odometry, both from chapter 9. It delays the command by 0.2 s to match rf2o's lag, averages over 0.3 s, and judges only commands faster than 0.08 m/s that have lasted half a second. A contact is measured motion along the commanded direction below 15 percent of the command, for 0.3 s. With fresh camera odometry both sensors must see the stall. Without it, rf2o may decide alone, but only for forward or backward commands, because rf2o can't see sideways motion. The first version trusted rf2o alone and e-stopped the robot on every sideways move. On contact it publishes true on /estop three times.
It runs under the vision virtual environment from chapter 8, because it uses NumPy and OpenCV. The unit, systemd/rosorin-contact.service:
[Unit]
Description=ROSOrin contact monitor: wheels commanded but LiDAR sees no motion = crashed -> e-stop (behavior/contact_monitor.py --act)
After=rosorin-base.service
Wants=rosorin-base.service
[Service]
User=burgerbarn
Environment=ROS_DOMAIN_ID=0
ExecStart=/bin/bash -c 'source /opt/ros/humble/setup.bash && source /home/burgerbarn/ros2_ws/install/setup.bash && source /home/burgerbarn/vision/venv/bin/activate && exec python /home/burgerbarn/behavior/contact_monitor.py --act --seconds 1e9'
KillSignal=SIGINT
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
--seconds 1e9 makes it run indefinitely. Wants= rather than Requires= keeps it running when the base restarts. Don't install it until chapter 9's floor numbers showed rf2o reading right; it trusts rf2o. From your laptop:
cd ~/CCode/rosorin-pro
ssh rosorin 'mkdir -p ~/behavior'
scp -q behavior/contact_monitor.py rosorin:~/behavior/
scp -q systemd/rosorin-contact.service rosorin:~/setup/
On the robot:
sudo install -m 0644 ~/setup/rosorin-contact.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now rosorin-contact
Then check:
systemctl is-enabled rosorin-contact; systemctl is-active rosorin-contact
journalctl -u rosorin-contact --since "-1 min" --no-pager -o cat | head -3
You should see enabled, active, and in the journal:
Started ROSOrin contact monitor: wheels commanded but LiDAR sees no motion = crashed -> e-stop (behavior/contact_monitor.py --act).
contact monitor running (ACT: e-stop on contact)
Only that last line proves the monitor runs. Without ~/vision/venv the journal shows No such file or directory for activate and a restart every five seconds, while is-active can still say active.
The collision monitor does less on Humble than its configuration file says. A scan older than its timeout is ignored, and with no points nothing triggers, so a silent LiDAR passes every command through unchanged; you saw that in the last isolated check. Stopping when the source goes silent only exists in later Nav2 releases. The contact reflex judges on rf2o ticks, so it stops judging too. A silent LiDAR removed every guard at once.
The fix is in the driver, because Humble's monitor has no option for it: software commands move the wheels only while the LiDAR publishes. That's the scan gate. The driver notes only the arrival time of each scan, without decoding it, and holds the wheels after 0.5 s of silence. It isn't latched; when scans return, the wheels follow the commands again by themselves. Gamepad commands are exempt, because a person holding the pad is looking, and the pad must still be able to move a robot whose LiDAR has died. The LiDAR reader also respawns by itself (chapter 7).
scripts/tests/scan_gate_live.py checks the loss path with the wheels disabled, so nothing moves. It kills the LiDAR reader, watches the driver's own view of the scan age, and checks that the reader comes back by itself. Check that the driver says "enabled": false first. From your laptop:
cd ~/CCode/rosorin-pro
scp -q scripts/tests/scan_gate_live.py rosorin:~/setup/tests/
On the robot:
source /opt/ros/humble/setup.bash
python3 ~/setup/tests/scan_gate_live.py
journalctl -u rosorin-base --since "-20 s" --no-pager | grep -iE "lidar|respawn|process has died" | tail -5
On my robot:
{"scan_age_before": 0.05, "killed_pids": ["122663"], "worst_scan_age_s": 5.85, "scans_back_after_s": 5.87, "reader_pids_now": ["123593"], "state_blocked": "disabled"}
PASS
The journal showed process has died [pid 122663, exit code -9, then process started with pid [123593] two seconds later and reading /dev/lidar (read-only) a second after that. state_blocked says disabled, not no scan, because disabled is checked first. Whether the wheels really stop while driving is measured in the stand proof.
The stand proof spins the wheels in the air and times every stop from the IMU. With the wheels in the air the robot doesn't move, but spinning wheels shake the body and the gyro sees it. On my robot the shaking measured about 0.0016 to 0.0025 rad/s with the wheels still, about 0.005 to 0.006 at 0.2 m/s and 0.006 to 0.010 at 0.35 m/s. The judge's threshold sits at 0.0035. It slides a 0.2 s window along the recording and reports the time from which the shaking stays below the threshold. A pass also needs clear spinning before the stop, the stop within two seconds, and at least two seconds of quiet afterwards. For the two paths that kill the driver, there's no driver left to publish the IMU, so the script opens the board's serial port itself and reads the IMU frames straight from it until the driver is back.
Each path spins up for three seconds, triggers the stop, and keeps publishing the drive command for five seconds. The paths, in order: deadman, e-stop topic and disable, each at 0.2 m/s, 0.35 m/s and 1.0 rad/s turning; the scan gate, which kills the LiDAR reader at 0.35 m/s and then checks the wheels turn again by themselves when scans return; killing the driver with SIGKILL; stopping rosorin-base; and the contact reflex, which drives at 0.2 m/s in the air and waits for the reflex to trip on its own. The script is scripts/stop_proof.py.
The wrapper, scripts/tests/stand_proof.sh, refuses to run while navigation is up, pauses the robot's mind, stops the contact reflex for the drive tests (with the wheels in the air every spin looks like a contact), starts it again for its own test, and logs everything to ~/setup/logs/. It imports ~/vision/mind_pause.py from chapter 8. If rosorin-mind isn't running, which on a robot built from this guide it won't be, it waits ten seconds for it and runs without pausing anything.
Put the robot on its stand with all four wheels in the air, charger unplugged and nothing in reach of the arm. Keep the power switch within reach of your hand for the whole run, and the gamepad too. From your laptop, copy the scripts:
cd ~/CCode/rosorin-pro
scp -q scripts/stop_proof.py rosorin:~/setup/
scp -q scripts/tests/stand_proof.sh rosorin:~/setup/tests/
On the robot, stop navigation and run the full proof. It takes about three minutes and spins the wheels about a dozen times:
sudo systemctl stop rosorin-nav
bash ~/setup/tests/stand_proof.sh
Every line has to say PASS. On my robot two paths needed a second go, both for reasons the judge can't help (see "Doesn't work yet"). Running only those two passed:
bash ~/setup/tests/stand_proof.sh estop,service
estop topic, rot 1.0 spinning 0.0041 -> still from 0.25 s on; worst after 0.0022 over 4.8 s PASS
driver service, fwd 0.35 spinning 0.0067 -> still from 0.45 s on; worst after 0.0035 over 3.1 s PASS
My times until the wheels were still, at 0.2 m/s, 0.35 m/s and turning: deadman 0.45, 0.65 and 0.50 s; e-stop topic 0.25, 0.50 and 0.25 s; disable 0.30, 0.35 and 0.20 s. The scan gate stopped the wheels 0.90 s after the reader was killed, killing the driver 0.55 s, stopping the service 0.45 s. The contact reflex tripped 1.49 s after the wheels started and the wheels were still 0.20 s later. Yours should be close. A stop that takes much longer, or a line that says NEVER settled, is a reason to stop and find out why before the wheels touch the floor.
Then read back and restore: navigation on, wheels disabled, no e-stop, the reflex running. If a script will check rosorin-nav, run sudo systemctl reset-failed rosorin-nav first (the failed state from above):
sudo systemctl start rosorin-nav
source /opt/ros/humble/setup.bash
timeout 5 ros2 topic echo --once --field data /rosorin_board_driver/state | grep -o '"enabled": [a-z]*\|"estop": [^,]*'
systemctl is-active rosorin-contact rosorin-nav
You want "enabled": false, "estop": null, and active twice. After the kill and service paths, the last end state: line of the proof itself can show the driver that was just stopped; this read-back is the one that counts.
The stand can't show stopping distance, and it can't reproduce a wheel loaded by the floor. scripts/stop_proof_floor.py drives short, slow legs on the floor and times each stop from measured motion, mainly the camera odometry, and the gyro for turns. It also reports how far the robot travelled after the trigger.
It guards itself. A forward leg of 1.5 s starts only into a corridor the LiDAR shows clear for 1.2 m and 0.6 m wide. A backward leg only retraces floor a forward leg covered seconds before, because the rear is blind. If anything comes within 0.45 m in the direction of travel, it stops everything. If a stop hasn't stopped the robot 0.8 s after its trigger, every other stop fires at once. It refuses to drive when the driver believes the charger is plugged in. A leg passes only if the robot was really moving, above 0.04 m/s, before the trigger. The judge reads the camera odometry and falls back to rf2o only after a full second without a camera frame, because rf2o jitters while the robot stands.
Take the robot off the stand onto clear floor, charger and network cable unplugged, and stay next to it with the power switch within reach. The judge needs the camera, and the camera is on the arm, so put the arm in the drive pose with the camera straight ahead, using the same drive_pan 500, arm/drive, drive_pan -- -1 block as in chapter 9's floor numbers. That moves the arm. Leave rosorin-contact running: the floor proof also counts its false trips. With no cable, use the Wi-Fi alias rosorin-wifi from chapter 5, here and for the session you run the proof in. From your laptop:
cd ~/CCode/rosorin-pro
scp -q scripts/stop_proof_floor.py rosorin-wifi:/tmp/
On the robot, stop navigation, and rosorin-mind if you have it, then look:
sudo systemctl stop rosorin-nav
sudo systemctl stop rosorin-mind 2>/dev/null
source /opt/ros/humble/setup.bash; source ~/ros2_ws/install/setup.bash
cd /tmp && python3 stop_proof_floor.py look
look prints the driver state, the battery, the number of camera and rf2o messages it heard, and the LiDAR's coverage by bearing. vslam msgs above 0 means the camera odometry is arriving. The bearings at -180 and -150 degrees are empty: that's the blind rear. If the state says 'plugged': True with the cable really out, the driver's belief is wrong. It learns the charger only from a voltage step, and near full charge there may be no step at all. Set the belief by hand; the driver reads the file at start:
echo '{"plugged": false}' > ~/battery/plugged.json && sudo systemctl restart rosorin-base
Wait about 20 seconds and run look again until it shows 'plugged': False. If a later run prints NOT RUN - corridor ahead, there's less than 1.2 m clear in the corridor. An object at the corridor's edge can do that with plenty of room straight ahead; on my robot a 15 degree turn in place cleared it. Move or turn the robot rather than lowering the limit.
Now run the proof in two halves. Each drives the wheels. The second half takes the base launch down, rf2o with it, so it measures with the camera odometry alone; the systemctl is-active rosorin-vslam && part skips it if that isn't running. Then count the reflex's trips and restore:
cd /tmp
timeout 170 python3 stop_proof_floor.py prove deadman,estop,disable
systemctl is-active rosorin-vslam && timeout 200 python3 stop_proof_floor.py prove kill,service
journalctl -u rosorin-contact --since "-10 min" --no-pager -o cat | grep -c CONTACT
sudo systemctl start rosorin-mind 2>/dev/null
sudo systemctl start rosorin-nav
The first half ended on my robot, on a rug, with:
RESULT: 10/10 passed
end state: {'enabled': False, 'estop': None} battery 11.89
The deadman stopped the robot 0.76 s after the trigger, the e-stop in 0.49 to 0.54 s, disable in 0.49 to 0.55 s, and turns in 0.33 and 0.60 s. The robot travelled 3 to 11 cm after the trigger. The deadman is the slowest because it first waits out its own 0.3 s. The second half printed RESULT: 4/4 passed: killing the driver stopped the robot in 0.69 s, stopping the service in 0.50 s. That service leg shows LiDAR nan cm, because rf2o went down with the base. The reflex count was 0: no false trips while the robot drove freely.
Afterwards the driver should read "enabled": false, "estop": null and "plugged": false, with the base, camera, camera odometry, navigation and the reflex all active. This proof cleared driving at up to 0.2 m/s and no faster.
Ten things failed in this chapter's build. Three were in navigation and seven in the stop tests. Read all of them before you let the robot drive on its own.
During the build, navigation never placed the robot. On the first start the supervisor loaded the map, switched slam_toolbox to localization and went straight to lost, with "no single place explains the scan". The two best places in its search fit 0.56 and 0.54, far too close to tell apart, and nav_wait exited 1. I added my old home pose; it fit 0.31 and changed nothing.
Then I put back the bigger kept map from the earlier build and tried three times: on the stand where it stood, on the stand at home, and on the floor at home. The best two places fit 0.75 and 0.75, then 0.77 and 0.71, then 0.71 and 0.70. The remembered pose fit 0.45 to 0.49 and the home pose 0.37 to 0.40. It stayed lost every time.
I found the cause by scoring one live scan against the map with the supervisor's own matcher. The room had changed since the map was made. An air mattress and a bean bag stood on what the map showed as open floor, one to one and a half metres from the robot, right in the LiDAR's plane. At the robot's true pose only 34 percent of the scan landed on known walls; most of the rest landed on the new furniture. The search's two best places would have sent 87 to 90 percent of the beams through walls. With two equal candidates and the true pose far below 0.65, staying lost was the right answer. I ruled out the code (identical to the earlier build that had placed itself), the LiDAR's handedness, its range scale and the mount. A score that tolerates furniture placed the robot closer but couldn't separate it from its neighbours, and on a recorded run it accepted three wrong poses where the current rule accepted none, so I didn't use it. Moving the robot to another spot doesn't help when the room itself has changed. The way out is a new map, or putting the room back. The matcher has a check for beams through walls, but place() doesn't use it yet.
So the placement step in this chapter failed, and I can't show you it passing. Later, outside this chapter's tests, navigation did place the robot. While I tested the robot API and the first live drives of chapter 13, the supervisor read ready with a fit of 0.78 to 0.79, and a goal 0.5 m ahead was reached. During that goal the fit fell from 0.88 to 0.59, and after the drive back, with the wheels off, the pose jumped 0.48 m at a fit of 0.82. The cause of that jump wasn't found. What changed between the failed placement and the later ready, a new map, the room put back or something else, isn't recorded, so I can't tell you which one fixed it.
Because the robot was never placed, the first navigation goal, 0.5 m ahead on the stand, never ran on this build. That test also needs the driver to believe the charger is in, so slam_toolbox stays in localization and spinning wheels can't spoil the map. With a full battery that belief couldn't be set: unplugging and replugging the charger at 12.67 V gave no voltage step, and the driver only learns the charger from a step of 190 mV. Later, at 11.6 V, the same plug gave a step of 193 mV and the driver logged battery: PLUGGED IN (+193 mV), three millivolts over the line. The opposite also happened before the floor proof: unplugged at 12.29 V, the driver saw no step and kept believing the charger was in, so look showed 'plugged': True with the cable out. That is why the floor proof has the plugged.json line. A belief that changes only on a voltage step isn't good enough near full charge.
NVIDIA's GPU localizer dies at start with GXF_FAILURE. Navigation places the robot without it, but there's no second opinion.
The contact reflex first failed because rf2o was wrong. Before the reflex was installed, rf2o on the floor read 8 cm of a true 80 cm leg, and a reflex trusting it would e-stop a robot that is driving freely. The fix, the /scan_rf2o copy, is in chapter 9. After it rf2o read 77 to 102 cm against the camera's 80 to 104, and only then did I install the reflex.
The stand proof's first full run passed 11 of 12 drive paths plus the reflex. The e-stop path at 1.0 rad/s turning was judged a fail, spinning 0.0037 -> still from 3.30 s on; worst after 0.0035 over 1.8 s FAIL. The wheels did stop; turning in the air shook the gyro barely above the 0.0035 threshold, and the standing noise reached it. Run alone, it read 0.0041 and stopped in 0.25 s. So a fail whose spinning value is within about half a thousandth of 0.0035 is the judge's margin; run that path alone, and count only a fail with clear spinning, above about 0.004. In the same run the service path didn't run at all. Right after the kill path it printed no IMU data while spinning up (driver gone?), because the driver wasn't back yet. Running it alone passed.
The floor proof refused my first spot. The corridor ahead was clear for only 0.94 m, under the 1.2 m it needs, and the robot had to be moved. At the second spot the corridor read 1.15 m because of an object at its left edge, 0.72 m away at 30 degrees. A 15 degree turn in place gave 2.11 m. The corridor is 0.6 m wide, so an object beside the path can refuse a spot with plenty of room straight ahead.
The floor proof then failed twice before it passed, and the stops weren't the problem. The first run said deadman 0.1 fwd: MOVED AGAIN after stopping. The old judge read rf2o first, and with chapter 9's fix rf2o measures real motion but jitters standing: 35 of 294 windows over 0.04 m/s in 30 seconds, while the camera never went above 0.005. Making the camera the first choice still failed, with estop 0.1 back: MOVED AGAIN, because the judge fell back to rf2o whenever a single camera frame was missing. A recording showed the camera still from 0.8 s on, the gyro at zero and the arm joints still. Only the rule that rf2o counts after a full second of camera silence passed, 10 of 10. The stop_proof_floor.py in the repo has that rule.
The scan gate passed, but scans came back 5.87 s after the kill. On an earlier build it was 3.03 s. The reader respawns after two seconds and the first scans take a few more, so expect anywhere from 3 to 6.
After the build, the robot made its first autonomous drives on its kept map. I have these only as reports of single runs, not as measurements I repeated. Nav2 reached goals in both, which it only does once the supervisor has placed the robot; the second ended with navigation lost. In the first run, the explore skill sent Nav2 goals for about eleven minutes: 6 goals reached and 9 aborted, no e-stops, and it ended 12 cm from where it started. It steered around a backpack tossed in its way. It also clipped the charging stand once, on a goal at the stand's own spot. The map shows that spot free and no scan point came nearer than 0.36 m, so the likely cause is a part of the stand below the LiDAR's plane, which the depth camera should have caught. That isn't confirmed. The run logged 0.05 m driven while the pose moved about 2.6 m, which isn't explained either. In the second run the robot went out through the doorway and got stuck there for four minutes. According to the report, the supervisor twice couldn't plan from the robot's own pose, restarted navigation, and crashed. On the restart the GPU localizer refused room_live.pgm, expecting .png, .jpg or .jpeg, because slam_toolbox saves a PGM, and navigation stayed lost. 26 seconds after the wheels stopped, the driver also decided the charger was plugged in: the battery voltage recovering after the drive looked like a charger's step. The wheels were disabled and the robot was carried back to its stand.
Some stops are still unproven. The gamepad e-stop was not tested on this build, here or in chapters 6 and 7, so treat the robot as having no tested gamepad stop. Until you have tested it yourself, count on the power switch, not the gamepad. If the board's USB link drops while driving, nothing can stop the wheels, because the board has no stop watchdog and keeps its last speed; the power switch is the only stop for that. A hang in the board's firmware was never tested. Stalled or loaded wheels, the situation of the "kept rolling" incident, can't be reproduced on the stand, and no floor test has stalled the wheels on purpose; the contact reflex is meant to be the stop for that case. The e-stop topic, the reflex, the enable service and the collision monitor all ride on ROS messaging, and the deadman and scan gate catch messages stopping, not a single lost stop message while commands keep arriving. The floor proof covered 0.1 and 0.2 m/s; navigation is configured for 0.35 m/s forward, and stops at that speed were measured only in the air. No stop was timed during a sideways move. The collision monitor's approach outline is the chassis plus 1 cm, not the 3 cm intended, because on Humble it uses the local costmap's footprint and ignores its own points.
Navigation itself has open items too. A long floor drive with mapping on hasn't been checked for what it does to the kept map over many drives; file size alone doesn't show a spoiled graph, so look at the saved image. Three times the navigation servers went deaf to the map to odom transform; the supervisor's probe is the heal, not a cure, and the root cause is unknown. And this chapter's install order, dependencies first, has not been run start to finish on a blank robot.
You're ready for the next chapter when check_nav2_config.py prints nav2.yaml ok: vx 0..0.35, vy -0.08..0.08, wz 1.0, the bring-up check shows five servers active, the isolated check shows teleop_wall_left_strafe_left [0.0, 0.14, 0.0], rosorin-nav is enabled and active, rosorin-contact is active with contact monitor running (ACT: e-stop on contact) in its journal, scan_gate_live.py printed PASS with a new reader PID, every stand proof path has passed with times close to mine, the floor proof printed RESULT: 10/10 passed and RESULT: 4/4 passed with 0 reflex trips, and after each test navigation and the reflex are running again with the driver at "enabled": false and no e-stop. Know which stops don't depend on the network (deadman, scan gate, the crash paths and the power switch, and the gamepad once you have tested it), and know where the power switch is. Don't let the robot drive on its own until nav_wait exits 0 where it stands. If the room has changed since your map, it needs a new map, and chapter 9 has no tested way to make one.