Hi, I’ve been missing a Heartbeat type of message for quite long in ROS (talking about ROS 1, but this probably also applies to 2). I’m about to open an issue/PR in ROS repos asking for adding it, but before that I wanted to collect some ideas here.
Why: If you have some system diagnostics that checks your sensors are running, you basically have two options now, none of which is easy and good:
- Use TopicDiagnostics on the publisher and publish whether the expected rate/delay is okay to
/diagnostics
. - Subscribe to the output topic of the sensor and check the delays/rates on the subscriber end.
I think 1. is almost good, except it’s usually a lot of lines of code to set up diagnostics for a node. Also, to find and check the rate of the node in postprocessing, it requires going through all diagnostics messages and parsing them to find the relevant reports. Option 2. is not good at all for large sensor data, where you create unnecessary CPU and network load just to check the frequency.
The idea of the Heartbeat message is that it has the following definition:
Header header
That’s it. A code path that publishes the sensor data would just copy the header of the message to the Heartbeat message and publish the heartbeat right after publishing the sensor message (or before it?).
The postprocessing step is then made super-easy if you record the heartbeats. Also, writing diagnostic analyzers for this would be pretty easy and there could even be a generic one usable for all heartbeat greatly simplifying setting up the diagnostics. And there is of course no unnecessary CPU or network load.
Taking the idea further, NodeHandle
could provide a method like advertiseWithHeartbeat()
that would automatically set up and control the heartbeat publisher in addition to the normal sensor data publisher. The publish()
call on the sensor publisher would automatically call the heartbeat publish, too. The heartbeat publisher could be automatically created with a standard topic suffix, so e.g. sensor publisher on topic /scan
would also create the heartbeat publisher on topic /scan/heartbeat
. This naming convention could be further utilized in e.g. rqt_graph or similar analytics tools. But that’s for future, now I’d like to concentrate on adding the Heartbeat message itself.
We have already implemented a custom Heartbeat message to our Ouster lidar driver and used it during the SubT challenge to verify the sensor is working as expected. It worked quite well. We can now also create “stripped” bag files which do not contain the large sensor data (so they are 1 GB instead of 40 GB), while still having an idea whether the sensor worked as expected at a given time point (thanks to the heartbeat messages).
One question remains: where should this message go? diagnostic_msgs
would probably be a good place. But maybe std_msgs
or e.g. sensor_msgs
?
What are your opinions on this Heartbeat message?