Skip to content
Nav2 Doctor

Nav2 Doctor

github.com • November 29, 2026

Rendered from real output captured on a Gazebo maze sim: healthy, then the bridge is paused and the doctor names the dead TF edges, odom and scan, and the Nav2 nodes that never activated. Source: docs/demo_raw.txt , docs/make_demo_gif.py .

Born in rosnav , a ROS 2 Nav2 stack with SLAM, frontier exploration and multi-robot fleets; rosnav ships this as scripts/nav2_doctor.py and tested it on its live Gazebo maze sim.

Part of ros2-doctor-tools , an index of my ROS 2 diagnosis, fault injection and evaluation tools.

nav2_doctor needs a ROS 2 environment (Humble, Jazzy or Lyrical; on Lyrical it is checked by CI only): rclpy comes from the ROS install, not from PyPI. Source ROS first ( source /opt/ros/ /setup.bash ), then either install it with pip into that same environment or build it in a colcon workspace. Without ROS the command prints a short message and exits with code 2.

A pip install puts the nav2_doctor command on your PATH; run it directly. The ros2 run form needs the colcon build.

A real report, 3.5 s after the sim bridge was frozen:

Checked servers: controller_server , planner_server , bt_navigator , behavior_server , smoother_server , waypoint_follower . Verified on Humble against a live Gazebo sim (a frozen bridge is caught within 3 s and clears on recovery) and in CI on Humble and Jazzy against a fake Nav2 graph.

A matplotlib replay of a robot driving a planned path while two faults are injected: a paused bridge (TF, odom and scan stop, 12 to 24 s) and a stalled controller ( cmd_vel is zero, 40 to 56 s). The trail is coloured by the doctor's verdict at each moment, and the timeline shows which finding fires when. The robot, obstacles and faults are simulated; the verdicts come from the real Doctor class (here with --progress-time 8 so the run stays short). Regenerate with python3 docs/nav_sim.py (needs matplotlib and pillow).

The same run as a graph: ovals are nodes, boxes are topics, and an edge turns red when a finding covers it ( /scan , /tf and /odom for a frozen bridge, /cmd_vel for a zero command). The layout is hand-placed for clarity, not read from a live ros2 node list .

Fixed thresholds do not fit every robot: a 5 Hz lidar is healthy on one machine and broken on another. Record what normal looks like once, then get warned when a stream drifts from it:

For a hard floor on any topic, use --min-rate instead:

The rate is the median messages per second (so bursts and a few stalls do not skew it); there is no model and no training data, and each finding states the learned number it is compared with. A silent stream is still reported by the stale checks, not here. Re-learn after you change a driver or a bridge setting on purpose.

Fault-injection scoreboard

Measured with nav2_fault_inject : one headless single-robot maze sim, nine injected pauses ( parameter_bridge for SCAN_STALE , controller_server for NO_CMD_VEL , slam_toolbox for TF_EDGE_STALE , three each), a finding must appear within 10 s.

The run 2 misses were measured: a 3 s controller_server pause leaves /cmd_vel silent for only 1.25 to 1.75 s (the velocity smoother keeps repeating), under the 2.0 s threshold, while /cmd_vel_nav is silent for 2.5 to 2.75 s. Caveat: the /cmd_vel_nav fix was tuned on data from this same scenario, so 9/9 is not a fresh benchmark. Held-out run (2026-11-23, cafe world, other pause lengths, two new targets, nothing tuned on it): 7/9. slam_toolbox and parameter_bridge 4/4, velocity_smoother and ekf_filter_node 3/3, the 2.5 s controller_server pauses 0/2. The 200 s no-fault control before it gave no errors or warnings in 199 reports (a small sample).

Since then the controller check expects /cmd_vel_nav only while the behaviour tree says FollowPath is running, because recovery behaviours publish straight to /cmd_vel (the earlier check would have called that a hung controller), and uses a 1.0 s threshold then (2.0 s if no BT log is seen). That change is unit-tested; since it was motivated by the 7/9 misses it needs a fresh scenario before any new score is quoted.

When Nav2 sits still, finding the cause means juggling ros2 topic hz , tf2_echo , ros2 lifecycle get and the logs. nav2_doctor runs those checks together. Pair it with nav2_fault_inject to break a stack on purpose and watch the doctor name the cause.

Thresholds are tunable with --stale , --flap-count , --flap-window , --progress-time , --progress-dist , --progress-yaw (turning in place counts as movement).

The costmap check needs /local_costmap/costmap ; the goal checks need navigate_to_pose .

One robot per run; use --ns once per robot.

Reports to the terminal (text or --json ); --diagnostics also publishes a DiagnosticArray on /diagnostics ( / /diagnostics with --ns ).

repeating recovery behaviours; AMCL covariance too high

a map-distortion check ( map->odom yaw ramp); inert costmap filters are done ( FILTER_NO_MASK , FILTER_NO_INFO )

multi-robot auto-discovery; ERROR lines from /rosout tied to the cause

a live Jazzy test, and the first PyPI release (the workflow job is ready but off until a trusted publisher exists on pypi.org, see .github/workflows/release.yml )

Build: colcon build --packages-select nav2_doctor . Tests: python3 -m pytest test (unit tests need no ROS; the integration tests run the real CLI against a fake Nav2 graph when ROS 2 is sourced).

Extracted Entities