Chaos Engineering for Robotics — Battle-Test Your ROS2 Stack Before the Field Does
If your robot has never been tested under chaos, it has never truly been tested.
Why Chaos Engineering? • Features • Quick Start • Architecture • Examples
Your ROS2 system works perfectly in simulation. But the real world is chaos:
- Sensor wires vibrate loose → random spikes in
/imu/data - WiFi congestion hits →
/cmd_velpackets arrive 300ms late - Hardware glitches → entire
/scantopic drops for 2 seconds
If you haven't tested these failures deliberately, you will discover them catastrophically. The ros-fault-injector lets you inject these exact failure modes into any live ROS2 topic — in a controlled, reproducible, configurable way.
| Fault Type | Description |
|---|---|
| 🔊 Gaussian Noise | Adds realistic sensor noise to Float32, Vector3, Twist topics |
| ⏱️ Latency Injection | Artificially delays message delivery (fixed or random) |
| 💀 Message Drop | Drops messages at a configurable probability (0.0–1.0) |
| 📦 Topic Replay | Re-publishes stale data to simulate a frozen sensor |
# 1. Clone and build
cd ~/ros2_ws/src
git clone https://github.com/EngineerAbdullahBinZafar/ros-fault-injector.git
cd ~/ros2_ws
colcon build --packages-select ros_fault_injector
source install/setup.bash
# 2. Launch the injector on any topic (e.g., inject noise into /imu/data)
ros2 run ros_fault_injector fault_node \
--ros-args \
-p input_topic:=/imu/data \
-p output_topic:=/imu/data/faulty \
-p fault_type:=noise \
-p noise_std:=0.05
# 3. Visualize the difference in RViz2 or rqt_plot
ros2 run rqt_plot rqt_plot /imu/data/angular_velocity/x /imu/data/faulty/angular_velocity/xflowchart LR
A["/real_topic\n(Any ROS2 Topic)"] -->|Subscribe| B["🔥 Fault Node\n(ros_fault_injector)"]
B --> C{Fault Strategy}
C -->|noise| D["Gaussian Noise\nInjector"]
C -->|latency| E["Latency\nBuffer"]
C -->|drop| F["Probabilistic\nDropper"]
D --> G["/topic/faulty\n(Degraded Output)"]
E --> G
F --> G
G -->|Subscribe| H["🤖 Your Robot's\nControl Nodes"]
# Inject 5% Gaussian noise into your LiDAR scan
ros2 run ros_fault_injector fault_node \
--ros-args -p input_topic:=/scan \
-p fault_type:=noise \
-p noise_std:=0.05# Add 250ms random latency to velocity commands
ros2 run ros_fault_injector fault_node \
--ros-args -p input_topic:=/cmd_vel \
-p fault_type:=latency \
-p latency_ms:=250# Drop 40% of GPS messages
ros2 run ros_fault_injector fault_node \
--ros-args -p input_topic:=/fix \
-p fault_type:=drop \
-p drop_probability:=0.4See CONTRIBUTING.md and CODE_OF_CONDUCT.md.
Open Bounties:
- Support for custom message type injection
- YAML-based fault scenario files (e.g.
scenario_wifi_failure.yaml) - RViz2 overlay plugin to visualize active faults
MIT License — See LICENSE for details.
Built by Engineer Abdullah Bin Zafar — GitHub · LinkedIn
If this saved your robot from a real-world disaster, drop a ⭐!