ROS nodes can provide diagnostic information using the diagnostics
topic. For that, there is an API that helps to publish diagnostic information in a standard way. The information follows the diagnostic_msgs/DiagnosticStatus
message type, which allows us to specify a level (OK
, WARN
, ERROR
), name, message, and hardware ID as well as a list of diagnostic_msgs/KeyValue
, which are pairs of key
and value
strings.
The interesting part comes with the tools that collect and visualize this diagnostic information. At the basic level, rqt_runtime_monitor
allows us to visualize the information directly published through the diagnostics
topic. Run the example7
node, which publishes information through the diagnostics topic, and this visualization tool, to see the diagnostic information:
$ roslaunch chapter3_tutorials example7.launch $ rosrun rqt_runtime_monitor rqt_runtime_monitor
The previous commands display the following output:
When the system is large, we can aggregate diagnostic information using the diagnostic_aggregator
. It processes and categorizes the diagnostics
topic messages and republishes them on diagnostics_agg
. These aggregated diagnostic messages can be visualized with rqt_robot_monitor
. The diagnostic aggregator is configured with a configuration file, such as the following one (see config/diagnostic_aggregator.yaml
in chapter3_tutorials
), where we define different analyzers
, in this case using an AnalyzerGroup
:
type: AnalyzerGroup path: Sensors analyzers: status: type: GenericAnalyzer path: Status startswith: example7 num_items: 1
The launch
file used in the previous code already runs the diagnostic aggregator_node
with the previous configuration, so you can run the following command:
$ rosrun rqt_robot_monitor rqt_robot_monitor
Now, we can compare the visualization of rqt_runtime_monitor
with the one of rqt_robot_monitor
, as shown in the following screenshot: