armchaos
Does your arm stack notice when something breaks? Break a ros2_control arm on purpose (frozen, late, noisy, NaN or spoofed joint states, a deactivated controller), then restore it. Pair it with armdoc to check the doctor names each fault.
A real UR5e model (MuJoCo Menagerie) moves through a loop. The five faults reshape the joint-state stream with the real armchaos fault models; the arm drawn is the arm as the stack sees it, and the bar underneath is what the real armdoc checks say. Simulated time, no ROS: PYTHONPATH=.:../armdoc python3 examples/make_demo_gif.py. A model, not a real robot.
All four tools in one run (armchaos faults, armdoc names each one, trajlens scores the damage, forcetrace reads the squeezed joint's effort as a force proxy), no ROS: PYTHONPATH=.:../armdoc:../trajlens:../forcetrace python3 examples/pipeline_demo.py.
Part of ros2-doctor-tools, an index of my ROS 2 diagnosis, fault injection and evaluation tools.
Quick start
# install (ROS 2 Humble sourced; C++ package also built in CI on Jazzy and Lyrical; use --system-site-packages if you use a venv)
pip install armchaos # or: colcon build --packages-select armchaos
armchaos list # the faults and their parameters
armchaos inject freeze --for 8 --dry-run # show the plan, touch nothing
armchaos inject freeze --for 8 # joint_states stop for 8 s (point your stack at /joint_states_chaos)
A pip install puts the armchaos command on your PATH; run it directly. The ros2 run form below needs the colcon build.
Try it without a robot, from a clone of this repo (a fake arm and controller manager, plus armdoc on PYTHONPATH):
python3 test/fake_cm.py & # publishes /joint_states_raw, serves list/switch_controller
armchaos run test/scenario_expect.yaml --armdoc --source /joint_states_raw
The last command ends with a pass/fail table and exits non-zero if an expected armdoc code did not fire, so it works as a CI test:
# fault when expect armdoc said result
- ------------------------------------- --------- --------------------------------- --------------------------------- ------
1 freeze t=2s +6s JOINT_STATES_STALE JOINT_STATES_STALE PASS
2 nan(joint=j1) t=12s +5s JOINT_NAN JOINT_NAN PASS
3 deactivate(controller=arm_controller) t=21s +7s CTRL_INACTIVE, NO_ACTIVE_ARM_CTRL CTRL_INACTIVE, NO_ACTIVE_ARM_CTRL PASS
4 noise(sigma=0.02, seed=0) t=32s +5s - nothing -
(Real output against armdoc 0.2.0 and test/fake_cm.py: docs/e2e_expect.txt.)
Commands
ros2 run armchaos armchaos list # faults and their parameters
ros2 run armchaos armchaos inject freeze --for 8 # joint_states stop for 8 s
ros2 run armchaos armchaos inject spoof joint=shoulder_pan_joint offset=7 --at 5 --for 6
ros2 run armchaos armchaos inject deactivate controller=arm_controller --for 10
ros2 run armchaos armchaos run scenario.yaml --events out.jsonl # several faults on a timeline
ros2 run armchaos armchaos inject nan --dry-run # show the plan, touch nothing
# scenario.yaml: each fault starts at `at` seconds and lasts `for` seconds
faults:
- {at: 4, for: 8, fault: freeze, expect: JOINT_STATES_STALE}
- {at: 20, for: 8, fault: spoof, joint: shoulder_pan_joint, offset: 7.0, expect: LIMIT_POS}
- {at: 40, for: 10, fault: deactivate, controller: arm_controller, expect: [CTRL_INACTIVE, NO_ACTIVE_ARM_CTRL]}
Checking armdoc: --armdoc and expect:
expect: names the armdoc codes that must appear while a fault is active: one code, a list (all of them must appear), or none (armdoc must stay quiet). A step without expect: is only reported, not judged.
With --armdoc, armchaos starts armdoc (it must be importable: installed, or on PYTHONPATH) on the faulted stream, waits --armdoc-lead seconds (default 4) so armdoc sees a healthy baseline, then runs the scenario and compares each step's window, plus 1.5 s after it ends, with the codes armdoc printed. It runs armdoc live for the whole run (one report per second), not once per step, so that short and intermittent faults are not missed. inject takes --expect CODE (repeatable) the same way. Without --armdoc, expect: is ignored and armchaos says so.
Exit codes: 0 ok, 1 an expect: failed, 2 bad usage or a scenario longer than --max-duration, 3 a controller could not be restored, 130 / 143 stopped by Ctrl-C / SIGTERM.
Safety
- Controllers are always put back. If a run stops early (Ctrl-C, SIGTERM, an error, or the guard below), armchaos reactivates every controller it switched off, blocking with retries, and exits
3if it cannot (it prints which controller to switch on by hand).--no-restore-on-exitleaves them off instead. A fault that ends normally always reactivates its controller. - Nothing runs forever.
--max-duration SECONDS(default 600) refuses a scenario that is longer, and also stops the relay if the run overshoots it, restoring controllers first. - Stream faults never touch the real
/joint_states; onlydeactivatechanges the running system.
How it works
Stream faults: armchaos subscribes to --source (default /joint_states), passes each sample through the active faults, and publishes the result on --out (default /joint_states_chaos). The real /joint_states is never touched, so point the thing under test at --out (a topic remap is enough), or move your real source to another topic and relay it back onto /joint_states.
Controller fault: deactivate calls controller_manager/switch_controller on the real controller manager and reactivates the controller when the fault ends (and on Ctrl-C or SIGTERM, see Safety). Unlike the stream faults this one does change the running system.
Faults, and what armdoc said
Real runs, one fault at a time with 6 s of recovery in between, armdoc live with a 1 s report period. "+2.2s" is how long after the fault started the first report named it. Raw output: docs/e2e_*.txt and .json.
| Fault | What it does | armdoc code | Fake arm | UR3 in Gazebo |
|---|---|---|---|---|
freeze |
joint_states stop | JOINT_STATES_STALE |
+2.2 s | +2.2 s |
slow hz=0.2 |
one sample every 5 s | JOINT_STATES_STALE |
+3.0 s | +2.3 s |
stutter up=1 down=4 |
1 s on, 4 s silent, repeating | JOINT_STATES_STALE |
+3.8 s | +3.4 s |
lag delay=3 |
every sample 3 s late | JOINT_STATES_STALE |
+2.4 s | +2.5 s |
noise sigma=0.02 |
Gaussian noise on positions | none (armdoc has no noise check) | none | none |
nan |
one joint position is NaN | JOINT_NAN |
+0.7 s | +0.5 s |
spoof offset=... |
one joint shifted past its limit | LIMIT_POS |
+0.8 s | +0.5 s |
squeeze effort=100 |
one joint reports effort above its limit | EFFORT_SAT |
+2.9 s | +2.5 s |
spike velocity=10 |
one joint reports a velocity above its limit | LIMIT_VEL |
+0.0 s | +0.5 s |
deactivate |
arm controller switched off | CTRL_INACTIVE, NO_ACTIVE_ARM_CTRL |
+2.0 s | +1.6 s |
Every fault was followed by an OK report within 6 s of it ending, on both setups.
Two honest notes on those rows:
lagis reported as stale, not as late: the firstdelayseconds are silent, and after that the stream flows normally, only shifted. armdoc has no check for a constant delay.noiseis a real gap in armdoc, not a bug in armchaos. Small position noise does not break a limit, so nothing fires.
C++ relay (low overhead)
armchaos_cpp is a sibling colcon package with the same stream faults in C++, so the relay itself adds little CPU and memory next to a fast controller:
colcon build --packages-select armchaos_cpp && source install/setup.bash
ros2 run armchaos_cpp armchaos_fast --ros-args -p "faults:=['2,6,freeze','10,5,spoof,joint=shoulder_pan_joint,offset=7']"
Each fault is "at,for,name[,key=value...]" with the same parameters and defaults as the Python tool; other parameters are source (default /joint_states, like the Python tool; use -p source:=/joint_states_raw for the fake arm), out (default /joint_states_chaos), lead, linger and max_duration (hard guard). deactivate,controller=NAME works too (parameter controller_manager, default /controller_manager): the relay switches the controller off, back on when the fault ends, and restores it on Ctrl-C, SIGTERM and the max_duration guard (exit 130 / 143, or 3 if it could not restore), checked by test/cpp_restore_check.py against fake_cm.py. Run the binary directly if you need signals to reach it (ros2 run is a wrapper). On a 500 Hz stream (one 15 s run each, busy machine) the C++ relay used 4.6% of a core and 22 MB, the Python relay 18.2% and 60 MB, with median latency 235 us against 326 us (the latency includes a Python publisher and subscriber, so read the CPU and memory gap, not the latency gap). A test replays the same event sequences through both and requires identical output.
What was and wasn't tested
- Fake arm (
test/fake_arm_raw.py, armdoc's fake graph on a remapped topic): all nine stream faults.deactivateran againsttest/fake_cm.py, a small stateful fake controller manager, because the fake arm's controller list is fixed. - UR3 in Gazebo Harmonic (ros2_control,
arm_controller+joint_state_broadcaster, peg tool, no MoveIt): all nine stream faults plusdeactivateon the real controller manager. The sim reportedarm_controlleractive again after the run. - Armdoc was pointed at the faulted stream with a ROS remap (
test/armdoc_remap.py); the sim's real/joint_statesstayed untouched. - Unit tests (
pytest test) cover the fault models and the scheduler without ROS. - Safety (0.2.0):
test/restore_check.pyruns againsttest/fake_cm.py, a fake controller manager, and checks five cases: SIGINT and SIGTERM restore the controller and exit 130 / 143, the--max-durationguard stops a run and restores,--no-restore-on-exitleaves it off, and a normal run restores. All five pass. This was not run against the realros2_controlcontroller manager (a Gazebo run was out of scope), so the switching is only verified against the fake one. --armdocsummary (0.2.0): run on the fake graph with armdoc v0.2.0: three expectations passed. With a newer armdoc that has a noise check, a step withexpect: nonefailed as it should (exit 1).pip install .was tested in a clean venv andcolcon buildstill works.- Two arms that are not URs, on the real ros2_control controller manager (Humble, mock hardware from
moveit_resources_*_moveit_config, started headless withtest/fanuc_headless.launch.pyandtest/panda_headless.launch.py): FANUC (6 joints,fanuc_controller;test/scenario_fanuc.yaml, outputdocs/e2e_fanuc_ros2_control.txt) and Franka Panda (7 joints,panda_arm_controllerplus a separate gripper controller;test/scenario_panda.yaml, outputdocs/e2e_panda_ros2_control.txt). Every fault was named by the expected armdoc code on both (10 of 10), and the arm controller was active again afterwards. Differences worth knowing: the Fanuc URDF has effort limit 0 and the mock hardware reports no effort, sosqueezeis expected to go unnoticed there (the scenario saysexpect: none); the Panda has effort limits, sosqueezeraisesEFFORT_SAT. Mock hardware, not a real arm. - ROS 2 Jazzy (docker
ros:jazzy-ros-base): thearmchaos_cpppackage builds, its 26 equivalence tests pass, and the C++ relay applies a freeze on the fake controller manager; armdoc andarmdoc_cppagree on the fake arm there too. Only the C++ packages and the fake graph were run on Jazzy, not the Python relay against a Jazzy simulator. - Not tested: MoveIt, a real robot, two arms at once, a Jazzy simulator, the new Jazzy CI jobs (only their commands, in docker).
Reproduce
For a ros2_control stack without a simulator: ros2 launch test/panda_headless.launch.py (needs ros-humble-moveit-resources-panda-moveit-config), then armchaos run test/scenario_panda.yaml --armdoc --source /joint_states. If the controller manager says it cannot find the mock_components library, run the launch from a clean shell with only /opt/ros/humble/setup.bash sourced: stale entries in AMENT_PREFIX_PATH from old workspaces broke the plugin lookup here.
python3 test/fake_arm_raw.py & # or a simulator publishing /joint_states_raw
python3 test/e2e.py test/scenario_stream.yaml --source /joint_states_raw
test/e2e.py starts armchaos and a remapped armdoc, then prints the fault-to-code table above (for pass/fail checks use armchaos run ... --armdoc instead). For a simulator, use --source /joint_states and test/scenario_gazebo.yaml (UR3 joint names).
Limits
- Verified against
armdocon a UR3 and a UR5e in Gazebo (all ten faults,docs/e2e_ur5e_gazebo.txtfor the UR5e run) and on a fake arm. No real robot and no non-UR arm yet. - Joint-state faults only, plus one controller fault. No TF, camera or force-sensor faults yet.
- Stream faults apply to the relayed topic, so they need a remap in the stack under test.
- YAML reads
on,off,yesandnoas booleans, sostutterusesupanddown; a boolean key gets a clear error. - Needs
controller_manager_msgsand PyYAML.
Metadata
Release files for armchaos 0.3.2
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 |
|---|---|---|---|---|
| armchaos-0.3.2.tar.gz | 31.4 kB | With provenance | Details for armchaos-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| armchaos-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for armchaos-0.3.2-py3-none-any.whl |
Total release size: 55.5 kB
Release files / armchaos-0.3.2.tar.gz
| Download URL | armchaos-0.3.2.tar.gz |
|---|---|
| Size | 31.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa797a2fe4ea511798b37c893933ff097379d27003f1d80e4be73b1558f2b1b8
|
|
BLAKE2b-256 checksum How to use checksums |
3bb6fa3bbdd112c437081897ec3e7131969d76203c66f5af997388fcc0fc4b1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / armchaos-0.3.2-py3-none-any.whl
| Download URL | armchaos-0.3.2-py3-none-any.whl |
|---|---|
| Size | 24.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97224aba617bf42a9c4ceaba0f8ad4cbb8ccbbc1a0e744927c5d6d858bf31781
|
|
BLAKE2b-256 checksum How to use checksums |
ea44a8581baae81e6b91eb5b35ea28db3dea9597ff3d974a47d5b0bb8cd86374
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for armchaos 0.3.2
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.
Attestation for armchaos-0.3.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA 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.