Question

I'm implementing a control node for a device with four wheels. So far I have the following nodes:

TALKER:
--Publishes messages for movement of vehicle

LISTENER:
--Listens to messages for movement of vehicle and controls vehicle directly

The communication between these two works and my only problem is what to do if either one shuts down in order to prevent uncontrolled movement of the vehicle. ros::isShuttingDown() call in the LISTENER so it detects when it's about to be killed.

However, if the TALKER is shut down the LISTENER keeps moving the vehicle according to the last message received from TALKER. First I tried to use ros::isShuttingDown() in TALKER as well in order to send a final "stop" message to LISTENER, but it seems that once the node is shutting down, no communication is possible.

Therefore I'm looking for a way to check inside LISTENER if the node TALKER is still alive (or if new messages are still being received).

Anyone an idea on how to see if a node (in this case TALKER) is still alive? Or is there an easy method for detecting how long it has been since the last ROS message was received?

Was it helpful?

Solution

Take a look at the bond package. I believe it does exactly what you need.

OTHER TIPS

Found another interesting and already built-in way with including "ros/network.h":

// master.h:
....

/**
* \brief Retreives the currently-known list of nodes from the master
*/
ROSCPP_DECL bool getNodes(V_string& nodes);

....

However, I didnt figure out how to use it from within another cpp file...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top