[ROS2] Best Practices: /rosout versus /diagnostics
I want to monitor the status of my different ROS2 nodes and act accordingly if something happens. Some of these nodes are hardware drivers, while others are not, working on things such as image processing, data upload, etc.
One way of monitoring the status is to subscribe to /rosout
and filter messages on severity, and filtering further on message string if needed. This filtering then determines how the system responds.
Another approach that i am entertaining is to use the diagnostics system to monitor status.
From the ROS wiki I quote:
The diagnostics system is designed to collect information from hardware drivers and robot hardware to users and operators for analysis, troubleshooting, and logging.
Furthermore when looking at the message definition that both use, DiagnosticStatus and Log, their definitions seem very similar.
Considering the above information, I find it difficult to determine which to use. This has lead to two questions:
Do I use
/diagnostics
only for hardware drivers as suggested and subscribe to/rosout
for the rest?Is it bad practice to subscribe to
/rosout
for status monitoring?
from q33503, it states that subscribing to/rosout
might lead to many socket connections to all the nodes running on your system.
However I wonder if this is still the case with the DDS system that ROS2 uses .