ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You can somewhat achieve this by setting the window size for statistics gathering. Set the parameters listed on that page appropriately and enable statistics, and when the traffic volume falls to zero it means the window is empty because there was nothing published in the period that the window covers. You might need to set the window min and max sizes to the same value to make it reliable.
However, I do not think this is a good way to know if messages have stopped being published to a topic. A better way is to create a node that subscribes to the topic and just watches for messages not coming in a certain time, without doing anything with the data it might receive.
You also need to keep in mind that there is a difference between messages not being published on a topic, and a node not publishing messages. There may be multiple publishers on the topic, in which case even if one stops publishing it will be hard to detect through subscription-side statistics (which is how the topic statistics tools work). If you want to know if a node has stopped publishing, you will need to use a heartbeat signal.
bond
package is a good way to do this.std_msgs/Empty
called heartbeat
or similar under their own namespace (to prevent them all publishing on the same topic) and listen to those signals.youbot_common
packages include a heartbeat_generator
node that does this using a boolean, but I think that Empty
is more appropriate because you are solely interested in if the message is published, not what it contains.node_alive
package provides not just the heartbeat signal but also a server to gather those signals and watch for dying nodes.node_monitoring
package but it hasn't been maintained in nearly 8 years so you would need to do some work to get it going again.