A small deterministic gate between the planner and the wheels: ROS 2 Jazzy node, simulation and CI only

I’ve been building a small supervisor node for differential-drive mobile robots that sits between a high-level velocity source (such as Nav2, an LLM agent, or teleoperation) and the base controller. Following the classic Simplex architecture (Sha et al.), the node treats complex high-level planners as unverified proposers and acts as a minimal, deterministic gatekeeper on /cmd_vel.

I work alone and I’m self-taught, based in Greece. I have no access to physical robot hardware, so everything described below is evaluated in Webots simulation (PAL Robotics TIAGo base) and verified in GitHub Actions Linux containers. I want to share what the node does, what the CI shows and doesn’t show, and the specific mistakes I made getting it through CI, in the hope it saves someone else an afternoon, or not :blush:

What it is

The package is qerra_core (node qerra_gate_node, version 0.3.0, Apache-2.0, ROS 2 Jazzy). It subscribes to /cmd_vel, /scan, and an operator reset topic, and publishes /cmd_vel_safe and diagnostic JSON on /gate/state.

planner (Nav2, teleop, etc.) --/cmd_vel–> [ qerra_gate_node ] --/cmd_vel_safe–> base controller
/scan ------^
distress input (UDP 5008) --^

The core decision logic is a pure function—step(state, params, inputs)—implemented using standard-library integer arithmetic with no external dependencies and with timestamps passed in as inputs. This design allows control cycles to be replayed and verified offline bit-for-bit.

Key behaviors:

  1. Kinematic stopping envelope: Clamps wheel velocity commands against a swept forward lidar corridor:
    d_stop = ceil(v^2 / (2*a)) + ceil(v * t_react) + margin
    (where a = 0.5 m/s², t_react = 32 ms, margin = 300 mm).
  2. Fail-closed trips: Commands zero velocity and latches on obstacle breach, stale/invalid proposals (≥ 150 ms), sensor stalls, or acute distress telemetry.
  3. Calm dwell & operator reset: Once tripped, the robot remains stationary. Resuming motion strictly requires a continuous 1.0-second clear dwell window followed by an explicit operator reset message (/gate/reset). Reset is strictly refused while a hazard is present.
  4. Distress reflex input (Layer 1B): Ingests non-blocking UDP telemetry (port 5008) inspired by ISO 13482 assistive cobot principles, tripping the gate on CRITICAL distress. (“HSR” in my documentation is my internal project name for this reflex layer and has no connection to Toyota’s robot).
  5. Node-level fault latch: If an unhandled exception occurs inside the 32 ms control tick, the node latches into a permanent FAULT state, continually publishes a zero velocity command, reports the fault reason over /gate/state, and refuses to move until the process is restarted.
  6. Topology note: The base controller is intended to be wired to /cmd_vel_safe, and nothing else should publish to it. ROS 2 topic namespaces do not enforce sole write authority.

What I can show (The Evidence)

  • Simulation replays: Webots runs logging each tick with a SHA-256 rolling hash chain that verifies offline via verify_log.py --replay. In Demo 7, an obstacle trip fired at 337 mm clearance, reaching standstill at 301 mm (36 mm coasting). In Demo 9, injected human distress tripped the gate within the same 32 ms tick (cycle 125), held standstill through dwell stabilization, and motion resumed only after an authorized reset.
  • Native ROS 2 Jazzy CI (workflow file: QERRA-v2-classical/.github/workflows/ros2_jazzy.yml at main · marunigno-ship-it/QERRA-v2-classical · GitHub Running on Ubuntu 24.04 in an official ros:jazzy container, GitHub Actions builds the package with colcon, verifies discovery in lib/qerra_core, starts the executable from a neutral directory (/tmp), captures a live /gate/state message, sends SIGINT, and strictly asserts that the process exits with code 0 and logs zero tick exceptions.

What I cannot show (Honesty Boundaries)

  • No hardware validation: Everything is simulation and CI. A 0.0 velocity command is a software setpoint delivered to motor drivers, not a certified hardware Safe Torque Off (STO), brake coil, or emergency stop. If the gate process dies, the base controller will maintain its last command unless the base has its own hardware or software command timeout.
  • Timing and jitter: The node runs on a Python timer at 31.25 Hz on general-purpose Linux. I have not profiled execution jitter under heavy system load.
  • Reaction time (t_react): The 32 ms figure is a simulation assumption. On a real robot, total reaction latency includes physical sensor scan time (a Hokuyo URG-04LX operates at ~10 Hz / 100 ms), executor queueing, DDS transport, and motor deceleration ramps. Until measured, d_stop is likely optimistic for real hardware.
  • Comparison with Nav2: I have not benchmarked this against nav2_collision_monitor. nav2_collision_monitor is far more mature and feature-complete. My implementation is an exploration of Simplex state-latching, explicit calm dwells, and replayable pure-function cores.
  • Standards are informative: References to ISO 13849-1, ISO 13482, and ISO 3691-4 are conceptual references only; no formal compliance is claimed.

What went wrong in CI (Lessons Learned)

Getting the standalone node to build, tick, and terminate cleanly under native Jazzy CI exposed five subtle issues:

  1. Missing setup.cfg: The console script was initially installed into bin/ rather than lib//, leaving ros2 pkg executables completely blank. Adding setup.cfg with explicit script directories fixed discovery.
  2. False confidence from GNU timeout: I initially ran the node under timeout -s INT 5 and treated exit code 124 as proof of clean operation. However, GNU timeout returns 124 whenever the time expires, regardless of whether the child process handled SIGINT cleanly or hung. I switched to launching in the background, issuing kill -INT, and checking the child’s actual exit status.
  3. The SIGINT shutdown crash: The actual exit status turned out to be 1. In ROS 2 Jazzy, rclpy.spin() raises ExternalShutdownException upon SIGINT. My finally: block was calling rclpy.shutdown() unconditionally on a context that had already been shut down, throwing an RCLError via pybind11. The fix was catching ExternalShutdownException and guarding if rclpy.ok(): rclpy.shutdown().
  4. Swallowed tick exceptions: Wrapping the control loop in except Exception: and publishing zero commands masked runtime failures during CI smoke testing. The step now inspects the log to fail the build if any “Tick exception” occurred, and the node now latches fail-closed.
  5. Sensor beam count mismatch: The Webots TIAGo lidar outputs 667 samples, while a physical Hokuyo URG-04LX outputs 682. My first iteration auto-configured the gate parameters from the first scan received—which made length validation useless because it compared the scan against itself. Geometry parameters are now immutable at startup, and mismatched scans are discarded (TRIP_SENSOR_INVALID).

Where this sits

This supervisory gate is the physical foundation (Layer 1) of a broader research framework. A text-based moral filter (SEMEV-12) and a values-based action ranker (QERRA-THRIVE) sit upstream in deliberation; they are purely advisory and do not form part of the safety function.

Repository & Documentation: GitHub - marunigno-ship-it/QERRA-v2-classical: Three-layer deterministic safety & ethical execution guard for autonomous robots (ROS 2 & Behavior Trees). Sub-ms physical reflex (QERRA-HSR) + moral filter (SEMEV-12) + values ranker (THRIVE). Fully auditable. · GitHub

Complete README: QERRA-v2-classical/README.md at main · marunigno-ship-it/QERRA-v2-classical · GitHub

Questions for the Community

  1. Bounding reaction latency: How do you measure and bound worst-case end-to-end reaction time in ROS 2 (sensor packet arrival → executor dispatch → supervisor decision → base controller command)? Is ros2_tracing the standard tool for this, and what instrumentation points would you recommend?
  2. Integration topology: For safety gatekeepers on /cmd_vel_safe, do you prefer direct topic remapping to the motor base, or integrating the supervisor into a twist_mux priority hierarchy?
  3. Lifecycle node management: Should a supervisory gate of this type be structured as a LifecycleNode? If so, how do you model a persistent “fault latched until restart” state without an external lifecycle manager inadvertently resetting the node before inspection?
  4. Benchmarking with nav2_collision_monitor: What would a fair, reproducible evaluation between a Simplex-style state machine and nav2_collision_monitor look like (e.g., standard bag replays, deceleration envelope metrics)?

I built this with AI coding assistance (documented in the README) and verified every claim against test suites (192 unit tests passing) and CI logs. If you spot an error, architectural blind spot, or flawed assumption, please let me know. :slightly_smiling_face:






Following up on my previous post, I’ve continued expanding the test harness and hardening the ROS 2 node (qerra_gate_node v0.3.1, package qerra_core v2.4.0).

The initial CI pipeline was essentially a smoke test — checking that the executable was discoverable under lib/, capturing a single message, and asserting a clean exit on SIGINT. I wanted to see how the node would behave under real pub/sub traffic and dual-protocol execution inside the official ros:jazzy container, specifically to exercise message flow and expose integration problems.

Here is what changed, what broke, and what the evidence shows today:

1. What was added (Release v2.4.0)

  • Live DDS topic traffic tests in CI (test_gate_ros2_live_traffic.py, 4 tests): A test harness feeds live /cmd_vel proposals and /scan messages over real DDS topics inside the container, asserting:

    1. Clean corridor cruise passthrough, followed by immediate fail-closed clamping to 0.0 m/s when an obstacle breaches the envelope.
    2. The configured 96 ms scan-freshness threshold (TRIP_SENSOR_INVALID) when /scan messages stop arriving.
    3. The 150 ms command-input timeout (TRIP_PROPOSER_STALE) when no new /cmd_vel messages are received.
    4. Active hazard reset refusal (RESET_REJECTED_HAZARD exposed in /gate/state diagnostic JSON).
  • Dual-protocol co-execution (test_gate_ros2_dual_protocol.py, 2 tests): The node co-executes live DDS topic traffic alongside an asynchronous Layer 1B UDP reflex stream on port 5008 under hsr_required=true. This tests:

    1. Acute distress clamping (TRIP_HSR_CRITICAL / 0.0 m/s clamp) during an active cruise.
    2. The 96 ms stale heartbeat watchdog (TRIP_HSR_STALE) when the UDP producer is severed.
  • Timing profile separation & startup guard: I separated the 32 ms control tick (31.25 Hz) from the reaction-time budget (t_react). The node exposes a 96 ms simulation profile and a 160 ms hardware profile for a 10 Hz scanner. At boot, the node enforces the invariant:
    lidar_stale_ms >= 2 * lidar_period_ms + dt_ms
    and refuses to start if misconfigured.

  • Test Baseline: The local Windows 11 host run collected 217 tests: 211 passed and 6 were skipped because rclpy was unavailable. The ROS 2 Jazzy container suite passed all 31/31 integration tests, including live DDS topic traffic and dual-protocol DDS/UDP scenarios.

2. Practical lessons & what went wrong during this sprint

  1. The Best Effort QoS trap: Standard ROS 2 laser scanner drivers publish /scan using sensor_msgs/msg/LaserScan with Best Effort reliability. If your node subscribes with default Reliable QoS, DDS silently refuses to match endpoints without throwing an error. I changed the /scan subscription to qos_profile_sensor_data (Best Effort + Volatile) to match the common ROS 2 sensor-data profile. The actual QoS settings of a target LiDAR driver still need to be verified during physical integration.
  2. UDP processing inside the Gate timer: I kept UDP reception non-blocking and poll the HSR stream synchronously inside the Gate timer callback, rather than introducing a separate worker thread. This keeps processing serialized within the node’s single-threaded executor without mutex overhead, but UDP processing consumes time on the timer callback path. The receiver processes at most 256 datagrams per tick. This limits the packet count per poll, not worst-case execution time. An adversarial test documents that a sufficiently large burst can delay a trailing CRITICAL packet across ticks, which remains a known limitation.
  3. Reset edge-triggering: In my first pass, if an operator reset message arrived while an obstacle was still present, the node rejected it but left the reset flag latched True. As soon as the obstacle moved away, the gate immediately cleared itself without a new human command. I corrected the logic so a reset request is consumed on the next Gate evaluation after its callback is processed. If rejected, it is discarded immediately, requiring a deliberate fresh message from the operator once the corridor is clear.

3. What remains unproven (Honesty boundaries)

  • Zero hardware testing: Everything described is evaluated in Webots simulation and Linux Docker CI containers. A 0.0 m/s output is a software velocity command published on /cmd_vel_safe. It is not a hardware emergency stop, Safe Torque Off (STO), or certified braking function. No physical downstream controller or motor response has been tested.

  • Unmeasured physical latency: The 96 ms and 160 ms reaction profiles are engineering estimates of the signal chain, not measured worst-case execution times (WCET). Real scanner acquisition jitter, executor latency, and actuator ramp-down times on physical hardware remain unmeasured.

  • Scan freshness model limitation: As documented in the technical brief, the 96 ms simulation and 300 ms hardware freshness limits permit scans to be up to two periods older than the one-scan-period delay assumed in the dynamic stopping envelope calculation. This leaves an unaccounted sensing age of roughly 64 ms in simulation and 200 ms on hardware that needs reconciliation on physical platforms.

  • Actuator authority: Publishing to /cmd_vel_safe does not prevent another node on the ROS graph from publishing directly to the base controller. True isolation requires SROS2 or physical gateway separation.

I’ve documented the full systems-engineering brief, timing profiles, and residual exploit scenarios in the repository:

Repository: GitHub - marunigno-ship-it/QERRA-v2-classical: Three-layer deterministic safety & ethical execution guard for autonomous robots (ROS 2 & Behavior Trees). Sub-ms physical reflex (QERRA-HSR) + moral filter (SEMEV-12) + values ranker (THRIVE). Fully auditable. · GitHub

Technical Brief (v1.2.0): QERRA-v2-classical/TECHNICAL_BRIEF_ROS2_GATE.md at main · marunigno-ship-it/QERRA-v2-classical · GitHub

Zenodo Archive: QERRA-v2 Classical: Three-Layer Deterministic Safety & Ethical Execution Guard for Autonomous Robotics

I would be interested in how other developers handle bounded UDP ingestion inside an executor callback without spawning worker threads, especially where delayed processing of a critical packet during a burst is a concern.

(Note: I used AI assistance during development and to help draft and refine this post. All implementation decisions, code reviews, and test assertions were checked and validated by me against container CI logs.)

Hi everyone, quick follow-up on the ROS 2 supervisory gate (qerra_core, still simulation and Docker CI only

Since my Nov 9 post, I fixed a few real edge cases I found (and had pointed out during review). I added a standard launch file (qerra_gate.launch.py) with topic remapping so it can sit between a Nav2-compatible command source and a base controller (tested with a topic harness, not a full Nav2 stack), fixed a timing bug where running the loop at 10 Hz instead of 31.25 Hz broke the clear-dwell check, and stopped wiping the UDP receiver on RESET_ACCEPTED so slower telemetry streams don’t false-trip right after a reset. I also fixed how NaN or Inf commands on /cmd_vel behave — instead of leaving the old velocity active until the 150 ms watchdog expires, it now drops the wheel command to zero right away while keeping the watchdog running.

The catch that bothered me most was in my own UDP parser for the distress reflex: two context fields (hazard_proximity and persons_nearby_count) used silent defaults when omitted, meaning an incomplete packet could fail open instead of failing closed. All six fields are now mandatory, and the receiver keeps monotonic dropped-packet counters with short sanitized reasons in /gate/state. I also expanded the standard-library unittest coverage (now 257 host tests with 14 ROS-gated skips on non-ROS hosts, 43 passing inside the ROS 2 Jazzy container, plus 20 HSR tests).

One thing I’m genuinely unsure about and would love your take on: right now, if an incoming UDP packet fails parsing because the bytes got scrambled on the network, or because the JSON is completely intact yet contradicts itself (for example, sending distress_permille = 900 with state = “CLEAR”), my receiver drops both the exact same way, counts them, and lets the 96 ms staleness watchdog catch sustained failure. In practice, would you keep treating contradictory packets like ordinary packet loss, or immediately trip a fault the moment a live sender violates the contract?

Repo: GitHub - marunigno-ship-it/QERRA-v2-classical: Deterministic supervisory velocity gate & reflex companion for autonomous mobile robots in ROS 2 Jazzy. Enforces dynamic stopping envelopes, fail-closed recovery, and hash-chained flight logging, with layered ethical deliberation research. · GitHub

Technical Brief: QERRA-v2-classical/TECHNICAL_BRIEF_ROS2_GATE.md at main · marunigno-ship-it/QERRA-v2-classical · GitHub

Zenodo: https://doi.org/10.5281/zenodo.24337026

(Note: I drafted this post with AI tool assistance, and verified all code changes, test assertions, and CI runs myself against local tests and GitHub Actions Jazzy logs.)