nav2_fault_inject
Does your robot notice when something dies? Freeze any node of a running ROS 2 stack for a few seconds and watch what happens. No remaps, no rebuild, no root.
Real run on a Gazebo maze sim: the bridge is frozen for 8 s, nav2_doctor names the cause about 3 s later, and both recover when it resumes. Raw logs: docs/demo_raw.txt, docs/demo_events.txt; renderer: docs/make_demo_gif.py.
Built alongside rosnav, a ROS 2 Nav2 stack with SLAM, frontier exploration and multi-robot fleets, and tested on its live Gazebo maze sim.
Install
pip install nav2_fault_inject # Linux; latest main instead: pip install git+https://github.com/darshmenon/nav2_fault_inject
A pip install puts the nav2_fault_inject command on your PATH; run it directly. The ros2 run form below needs the colcon build.
Quick start
ros2 run nav2_fault_inject nav2_fault_inject list # nodes you can target
ros2 run nav2_fault_inject nav2_fault_inject hang parameter_bridge --for 10 # sim bridge: sensor and TF dropout for 10 s
ros2 run nav2_fault_inject nav2_fault_inject hang controller_server --for 5 # a hung controller
ros2 run nav2_fault_inject nav2_fault_inject run scenario.yaml --timeline out.json
ros2 run nav2_fault_inject nav2_fault_inject --dry-run hang bt_navigator --for 3 # show it, touch nothing
# scenario.yaml - each node is frozen at `at` seconds for `for` seconds
faults:
- {at: 20, node: parameter_bridge, for: 8}
- {at: 45, node: controller_server, for: 5}
Add expect: and run --check to turn a scenario into a pass/fail test (needs nav2_doctor):
faults:
- at: 20
node: parameter_bridge
for: 8
expect: {detect: [SCAN_STALE], within: 8, clear_within: 20, forbid: [GOAL_FLAPPING]}
PASS parameter_bridge @20s for 8s
ok detect SCAN_STALE: seen 2.1s after the pause
ok clear: healthy 3.0s after the resume
Output (each line carries wall-clock time, so it lines up with other tools' logs):
13:58:10 [ 0.02s] PAUSE parameter_bridge (pid 511740)
13:58:18 [ 8.02s] RESUME parameter_bridge (pid 511740)
How it works
Pausing the process that hosts a node (SIGSTOP, then SIGCONT) freezes everything it publishes. Freezing the sim bridge is a sensor and TF dropout; freezing controller_server is a hang.
- Safe by construction. Only processes in your own
ROS_DOMAIN_IDthat were started with--ros-argsare touched, and the node name or executable name must match exactly. Every paused process is resumed on exit, on error, on Ctrl+C and onSIGTERM. - Fails before it breaks anything. A scenario that names a missing node aborts before pausing anything.
- Reproducible. Scenarios are timed files, and
--timelinewrites what was paused and resumed, and when. - Tested for real. The test suite freezes and thaws an actual throw-away process, checks that Ctrl+C never leaves it frozen, and needs no ROS.
Why
Most robot stacks are only ever tested on the happy path. This makes "what if the lidar bridge dies for 8 seconds?" a one-line experiment. Pair it with nav2_doctor to see whether anything notices, and with nav_explore_eval to measure what the fault cost an exploration run.
Limits
- A node composed inside another process pauses together with that whole process.
- Pausing models a hang or a silent sensor, not corrupted data, a slow topic or a dropped network link.
- Linux only (
/procand POSIX signals).
Roadmap
- topic faults through a relay: drop, delay, rate limit;
cmd_velblackhole; clock jump - seeded random chaos mode; kill-and-respawn checks; CPU load
Build: colcon build --packages-select nav2_fault_inject. Tests: python3 -m pytest test (no ROS needed).
Metadata
Release files for nav2-fault-inject 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nav2_fault_inject-0.2.3.tar.gz | 19.8 kB | With provenance | Details for nav2_fault_inject-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nav2_fault_inject-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for nav2_fault_inject-0.2.3-py3-none-any.whl |
Total release size: 35.7 kB
Security for nav2-fault-inject 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.