Rosanswers logo


I was running ROS package with one publisher and subscriber in below link. https://github.com/oroca/oroca_ros_tutorials/tree/master/src

Basically, publisher sends a number (add 1 every loop) and subscriber gets it.

So, I run subscriber first, then run publisher in a different terminal.
Then I could see that there was a loss.

Publisher starts with 0, but Subscriber gets from 3.

Is this normal? Is this solvable?

Thank you in advance.

Originally posted by _nobot.enter on ROS Answers with karma: 5 on 2017-10-03

Post score: 0


1 Answer 1


Rosanswers logo

When a publisher is created, there is some setup performed "behind the scenes", such as registering with the ROS Master and potential subscribers. This means that when one publishes immediately after creation of the publisher, messages might not actually get out because the Publisher wasn't "ready" yet. See for instance also other Q/As such as this one. Pretty sure that adding a sleep here in line 13 would fix the issue.

Originally posted by Stefan Kohlbrecher with karma: 24361 on 2017-10-05

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by _nobot.enter on 2017-10-05:
Thanks Stefan Kohlbrecher :D


Your Answer

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