When a new publisher becomes active:
- It informs the ROS master.
- The ROS master sends a callback to all of the nodes that are subscribed to that topic, informing them that there is a new publisher, and giving its address.
- The subscribers then use this address to open a new connection directly to the publisher so that they can receive messages.
- messages are then passed over this TCP socket from publisher to subscriber
All of the steps in this process take a nonzero amount of time. The end result is usually that the first one or two messages sent by the publisher are not seen by subscribers.
This process can also fail if the master cannot contact the subscriber for some reason (for example, it can't resolve the hostname that the subscriber is running on), or if the subscriber cannot contact the publisher for some reason (again, hostname resolution is often the problem here).
Originally posted by ahendrix with karma: 47576 on 2014-08-06
This answer was ACCEPTED on the original site
Post score: 4
Original comments
Comment by Ashesh Goswami on 2014-08-06:
I see..so does that mean that the publisher needs to be publishing for the subscriber to subscribe to the topic being published by the publisher? In other words, the talker node needs to be running and publishing before I can run the listener node? thanks a lot
Comment by ahendrix on 2014-08-06:
No. You can start the publisher and the subscriber in any order.
Comment by Ashesh Goswami on 2014-08-06:
but thats the problem I am facing. If I start the talker first it works but if I start the talker(publisher) after the subscriber node, it does not. I am trying this with the default beginner_tutorial package. What do you think might be the issue? thanks
Comment by ahendrix on 2014-08-06:
"This process can also fail if the master cannot contact the subscriber for some reason (for example, it can't resolve the hostname that the subscriber is running on), or if the subscriber cannot contact the publisher for some reason (again, hostname resolution is often the problem here)."
Comment by Ashesh Goswami on 2014-08-06:
my bad I missed that part earlier..thanks!!