Rosanswers logo

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.

Originally posted by Cerin on ROS Answers with karma: 940 on 2016-04-23

Post score: 0

Original comments

Comment by robustify on 2016-04-23:
Do you have a dedicated terminal window running a ROS core, or are you relying on roslaunch to bring up a core?

Comment by Cerin on 2016-04-23:
I'm using roslaunch.


1 Answer 1


Rosanswers logo

When the ROS core goes down, any running nodes with topic subscribers or publishers will have those topic connections terminated. They also will not automatically reconnect when a new core comes up, which is probably why you have to restart to the get the topics working again.

Therefore, I think if you always leave a terminal window/tab running a ROS core, your problems will go away. Another benefit of this is that any parameters that are set will continue to exist after stopping the launch file.

Originally posted by robustify with karma: 956 on 2016-04-23

This answer was ACCEPTED on the original site

Post score: 3


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.