[Documentation] [TitleIndex] [WordIndex

Note: This tutorial assumes that you have completed the previous tutorials: ROS tutorials.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Analyzing Diagnostic Logs Off-Line

Description: This tutorial uses the diagnostic_analysis package to analyze a robot log file. These files are generated automatically by the robots when they're running and contain the entire diagnostics history of the robot. You can convert these log files into CSV files (comma separated value) that can be opened with any spreadsheet editor. This only works with diagnostic_msgs/DiagnosticArray messages on the /diagnostics topic, used in the PR2 diagnostic toolchain.

Tutorial Level: BEGINNER

Types of Log Files

If you have any messages that aren't on the "/diagnostics" topic, they will be discarded.

Discarding message on topic: /turtle1/pose
Discarding message on topic: /turtle1/color_sensor
Discarding message on topic: /turtle1/pose
Discarding message on topic: /turtle1/color_sensor

The PR2 diagnostics toolchain uses diagnostic_msgs/DiagnosticArray messages on the "/diagnostics" topic, which is what this package is designed for. Only bag files of this type will work with the diagnostic_analysis package. To play other bag files, use rostopic.

Recover Log File

To recover the data from a robot's log file, look in the /hwlog folder on your pr2. Log files end with ".bag", and are recorded directly with the diagnostics data from the robot.

$ cd /hwlog

Files are stored with the label 'prX_runtime_automatic_YYYY-MM-DD-HH-MM-SS-topic.bag'.

You may want to copy these to a directory off the robot. E.g., if your computer is xxx and your username is "user":

$ scp prX_runtime_automatic_YYYY-MM-DD-HH-MM-SS-topic.bag user@xxx:<somewhere_you_want_it_path>

If the log file you're looking for isn't there, check in the folder:

stor6:/prdata/bag_repository

Log files are moved there during nightly syncs.

Convert Log Files to CSV's

Robot log files can be viewed with ordinary spreadsheet software after processing with the CSV exporter. When run on a bag file, this creates several CSV files into the output/log_filename directory.

$ rosrun diagnostic_analysis export_csv.py <bagfilename>

You can use the "-d" option to change the output directory. For example:

rosrun diagnostic_analysis export_csv.py <bagfilename> -d <dir>

will store the results in the "<dir>/output" directory.

Each "name" in the diagnostic status messages will have its own file. This means you'll see one file for the Power Board, another for EtherCAT Master, etc.

Thinning the Logs

Some bag files are too large to be viewed with ordinary spreadsheet software. The limit for Open Office and versions of Excel prior to Excel 2007 is 65,536 rows. If you have a long run to analyze, it may help to make the CSV "sparse", by only retaining every nth line.

To do this, use sparse_csv.py.

$ rosrun diagnostic_analysis sparse_csv.py <path/my_bagfile>.csv -m

This makes the file <path/my_bagfile>_sparse.csv, making it about 65000 lines max.

Analyzing

OpenOffice Calc is the preferred tool. For example,

$ oocalc output/BAG_DIRECTORY/<my_bagfile>.csv

opens the data in OpenOffice Calc. From there, you can analyze and graph data.


2019-12-07 12:33