Unreliable subscribers based on launch order
How do you ensure your node subscribes to a topic? I'm finding launch order effects if a node is able to successfully subscribe.
For example, say node A publishes /A/topic, and node B consumes it.
I found that if I launch A, then B...B never receives any messages from A even though I can see A's messages with rostopic echo /A/topic
. If I kill A and restart it, or launch it after B, then B receives the messages.
Is this a bug in ROS or am I misunderstanding how ROS messages work? I would expect a node to subscribe and receive messages on a topic regardless of when it was launched relative to the publisher. As long as both nodes are running, the launch order shouldn't matter.
The docs say launch order shouldn't matter, but this doesn't seem to be the case. Why is this?
This even seems to effect rostopic echo
. If you call it after the publisher, it can receive messages, but if you kill and restart the publisher, rostopic echo
shows nothing until it too is restarted.
I've found this is causing some very obscure and difficult to diagnose bugs. The only workaround I've found is to kill every single node in my system and restart...which seems hacky and inefficient.
Do you have a dedicated terminal window running a ROS core, or are you relying on roslaunch to bring up a core?
I'm using roslaunch.