Navigation Diagnostics Capture
The IndoorNav diagnostics capture script collects ROS 2, system, and navigation
data for troubleshooting. Run it on the robot or on a remote ROS 2 Jazzy
computer that can see the robot's ROS graph. In either case,
scripts/nav_diagnostics_capture.py and
scripts/nav_diagnostics_config.yaml must remain together in the package
directory. The archive is created on the computer running the script.
The script checks for Matplotlib before capturing. If it is missing, the script
attempts to install python3-matplotlib with apt (using sudo unless already
running as root). This may prompt for sudo credentials and requires working apt
repositories. If installation or import fails, install Matplotlib for the
Python interpreter you use and rerun the capture.
Run on the robot
Source ROS 2 and the workspace, then run the script from the package directory. Use the robot's configured ROS domain ID if it is not the default.
source /opt/ros/jazzy/setup.bash
source <workspace>/install/setup.bash
cd <workspace>/src/clearpath_indoor_navigation
sudo -v
python3 scripts/nav_diagnostics_capture.py
The script itself runs as your normal user. By default, it reads the local
service journal using non-interactive sudo. sudo -v refreshes the sudo
credential cache before capture.
Run from a remote computer
The remote computer needs ROS 2 Jazzy and a working ROS connection to the robot. Use the same middleware and ROS domain ID as the robot. The connection helper discovers the robot namespace.
export ROS_DOMAIN_ID=0
source <workspace>/src/clearpath_indoor_navigation/middleware/connect_robot.sh \
zenoh <robot_ip> <robot_hostname>
source <workspace>/install/setup.bash
cd <workspace>/src/clearpath_indoor_navigation
python3 scripts/nav_diagnostics_capture.py --remote-service-logs
Replace 0 with the robot's domain ID. Use cyclone_dds instead of zenoh
if that is the robot's middleware. The connection helper also sources ROS 2
Jazzy, so the explicit /opt/ros/jazzy/setup.bash command is optional.
The script reads the journal on the computer where it runs by default. Use
--remote-service-logs to retrieve service logs from the robot over SSH.
Remote retrieval requires trusted SSH host keys and key or agent
authentication. Run sudo -v on the robot first or configure passwordless
sudo; the script uses non-interactive sudo.
Service-log retrieval collects only the latest
clearpath-platform-extras.service invocation, including its startup
messages. It excludes earlier restarts using systemd's InvocationID and
reports an error rather than falling back to older logs if no valid invocation
ID is available. Retrieval has a 60-second timeout. Errors are recorded in
logs/service_logs.json and
logs/clearpath-platform-extras.stderr.txt without discarding the rest of the
capture. Use --ssh-host and --ssh-user to override the SSH target and user.
Setting either option alone does not enable remote retrieval.
Capture output
The monitoring window defaults to 120 seconds. Discovery, service requests,
and archive creation take additional time. By default, the script saves a
nav_diag_<namespace>_<timestamp>.tar.gz archive in the current directory and
removes the unpacked capture directory. The archive is organized as follows;
some files appear only when data is available or an option is enabled:
nav_diag_<namespace>_<timestamp>/
├── summary.md
├── navigation/ # goals, trajectory, localization, velocity data and plots
├── logs/ # rosout, service journal, service status, bag recording log
├── parameters/ # ROS 2 node parameter dumps and parameter errors
├── ros/ # graph, topic rates, lifecycle, diagnostics, TF, optional bag/
└── system/ # environment, ping, middleware and capture configuration
The summary links to relevant files. Existing archives are not overwritten. If capture or archiving fails, the temporary staging directory is retained and its path is printed.
The capture observes navigation actions and their results; it does not send, cancel, or change goals. The summary reports:
| Analysis | What it shows |
|---|---|
| Navigation goals | Goal status, observed duration, recoveries, distance remaining, matching goal pose, and Nav2 errors. Goals that finished shortly before capture may also be included. |
| Goal trajectories | Per-goal trajectories and path updates, plus a color-coded overview. Separate plots are produced for different coordinate frames. |
| Localization quality | During Navigation mode, AMCL position and yaw uncertainty, map-to-odom corrections and jumps, and initial-pose events. |
| Velocity command chain | Commands through the navigation, smoother, collision-monitor, and mux stages, compared with odometry. This helps identify stopped commands, safety locks, teleoperation overrides, and whether the robot moved when commanded. |
Trajectory samples and path updates are associated with goals using observed goal-status times. Data before a goal's first observed status is not assigned to it; for goals already active when capture starts, only samples after their first observed status are shown. Data during overlapping goals is omitted from per-goal plots rather than attributed to either goal. The whole-capture trajectory plot still shows all captured poses and global path updates; path updates are drawn separately across replans. Whole-capture path-following statistics compare captured poses with the latest path and may span multiple goals or replans.
Configure a capture
The navigation topics, action lists, velocity-chain stages, and analysis
thresholds are configured in scripts/nav_diagnostics_config.yaml. The
capture includes the exact configuration it used as
system/nav_diagnostics_config.yaml.
Useful command-line options include:
| Option | Description |
|---|---|
--duration SECONDS | Set the monitoring window (default: 120.0). |
--namespace NAME | Choose the robot namespace; by default it uses $ROBOT_NAMESPACE or detects the namespace from the ROS graph. |
--bag | Also record the monitored ROS topics with ros2 bag. |
--topics [TOPIC ...] | Add topics to rate monitoring. Names can be namespace-relative or absolute. |
--include-heavy | Include point clouds and images in topic-rate monitoring. |
--skip-params | Skip parameter dumps from nodes in the robot namespace. |
--remote-service-logs | Retrieve service logs from the robot over SSH; local journal collection is the default. |
--skip-service-logs | Omit service-log collection. Mutually exclusive with --remote-service-logs. |
--no-archive | Keep the capture directory instead of creating an archive. |
Run python3 scripts/nav_diagnostics_capture.py --help for all options,
including output-directory and timeout settings.