ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Data loss between publisher and subscriber

asked 2017-10-03 17:15:12 -0600

_nobot.enter gravatar image


I was running ROS package with one publisher and subscriber in below link.

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-05 04:21:17 -0600

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.

edit flag offensive delete link more


Thanks Stefan Kohlbrecher :D

_nobot.enter gravatar image _nobot.enter  ( 2017-10-05 13:50:17 -0600 )edit

Question Tools



Asked: 2017-10-03 17:15:12 -0600

Seen: 342 times

Last updated: Oct 05 '17