Phase 4 of 4 · Study weeks 13-16
Safety, reliability and the real robot
This phase makes the last checkpoint possible: a robot that fails safely, with tests that prove it and a clear line between what simulation shows and what it cannot.
Topics every week
- Week 138 h
- Hazards and a safe state
- A command watchdog and velocity limits
- The collision monitor
- Stopping distance arithmetic
Hand inA hazard table (hazard, control, residual risk) and the stopping distance derivation
- Week 148 h
- Lifecycle management and restart
- DDS discovery and network faults
- Executors, callback groups and timing
- Tracing with
ros2_tracing
Hand inA timing report for the control path, and the watchdog written in C++ and Python
- Week 158 h
launch_testingand simulation in CI- Replaying bags as regression tests
- Fault injection (dropout, delay, node kill)
- Diagnostics and logging
Hand inA CI job that runs three seeded faults and fails when the robot does not stop
- Week 168 h
- The sim-to-real gap
- Bridging a microcontroller and motor driver (micro-ROS or a serial driver)
- A field checklist
- Writing the safety case
Hand inCheckpoint 4, the safety case and the decision memo
Practice projects
- Practice 1, the watchdog (Week 13): add a watchdog that zeroes velocity after 0.3 s without a command. Done when: a test kills the controller and the robot stops within the stated distance, with the number in a table.
- Practice 2, the language comparison (Week 14): write the watchdog in Python and in C++. Done when: a table gives the p99 reaction time of each over 10,000 messages, and says whether the difference matters for the 0.3 s budget.
- Practice 3, the fault suite (Week 15): write tests for a 5 s lidar dropout, a killed node and 200 ms of delay. Done when: each runs in CI, and a deliberately broken watchdog makes the job fail.
- Optional, a real motor on the bench: drive one wheel from a microcontroller with the wheels off the ground. Done when: a stop command halts it within the time you stated, measured with a stopwatch video or a logic analyzer.
GitHub repos to study
Status checked 22 Nov 2026 by shallow clone, as above.
| Repo | What to read | Week |
|---|---|---|
| ros-navigation/navigation2 | The collision monitor and the velocity smoother | 13 |
| ros2/ros2_tracing | How callbacks and message passing are traced | 14 |
| ros2/rclcpp | Lifecycle nodes and executor internals | 14 |
| micro-ROS/micro_ros_setup | Connecting a microcontroller to ROS 2 | 16 |
| ros-controls/ros2_control | How hardware faults are reported to the controller manager | 16 |
Milestone checkpoint
Run Checkpoint 4. Write the hazard table first. Add the watchdog and collision monitor, then the fault suite, and watch the suite fail without them. Run the 8-hour soak (fresher: 2 hours) with faults injected at random times. Write the safety case: each hazard, the control, how it was tested, and what the simulation cannot show. If you have the optional kit, run the wheels-off bench test. Hand in the fault table, the soak report (distance, interventions, stops), the CI run, ADR-6 (stop zone and command timeout, with the arithmetic) and the decision memo.
Check yourself
Answer each question in your head first, then open it to check.
How far does the robot travel before it stops at 0.5 m/s with 200 ms of latency and 0.5 m/s squared deceleration?
Reaction distance 0.5 x 0.2 = 0.10 m plus braking distance 0.5 x 0.5 / (2 x 0.5) = 0.25 m, so 0.35 m.Why have a watchdog on velocity commands?
If the controller crashes or hangs, the last command can stay in force. The watchdog turns silence into a stop.What is a lifecycle node, and what does it help with?
A node with managed states (unconfigured, inactive, active). It lets the system start in a set order, restart one part cleanly and know what is ready.Name three sources of the sim-to-real gap.
Sensor noise and timing, wheel slip and friction, actuator delay and limits, and the real environment (light, reflections, people).Why does a passing simulation not prove a robot is safe?
The simulator contains only the faults you modelled. It cannot show wiring faults, motor behaviour or brakes, so a hardware emergency stop that works without software is still required.