I have written a ROS node, just publishing to a topic, using roscpp that runs on a separate machine to the ROS master. It is based on the simple publisher/subscriber tutorials. If the ROS master gets restarted my node no-longer appears when I query the new master with rosnode list. It needs to be able to detect that the ROS master has gone down and re-advertise it's topics when it comes back up. I haven't managed to get this to work without killing and restarting my entire process.
I can detect that the connection to the ROS master has dropped by periodically checking ros::master::check () (would love a better way). When it returns true again after the master comes back up, none of the following work:
Call .advertise() on the old NodeHandle and get a new publisher. I thought this would work but it doesn't seem to.
Create a new NodeHandle and re-advertise on that.
Re-run ros::init
Call ros::shutdown and then call ros::init core dumps.
Also: I'm assuming ros::master::check () returns false if the connection is interrupted as well as if the master is restarted, do I need to handle that case differently or will re-advertising on the same master be OK?
Originally posted by techno74 on ROS Answers with karma: 90 on 2015-02-03
Post score: 6
Original comments
Comment by EpicZa on 2018-03-21:
Ever find a solution to this?