Messages lost in ROS ELECTRIC
Why do certain message packets get lost? Is this normal? I have attached a image for reference. Clearly, packets 0,1,2 were lost.
Please help
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
You lose only the first few messages. This probably doesn't have anything to do with buffer sizes but that subscribing takes a while. Your publisher node always publishes something although the connection to your subscriber is not completely established yet. This behavior directly follows from the way ros works.
Normally nodes are written in a way that this doesn't matter. However, roscpp provides callbacks when nodes subscribe or unsubscribe (connect_cb and disconnect_cb as shown here) and you can get the number of subscribed nodes from the publisher object. That way, the publisher can start publishing only when the subscriber is present.
Latched topics are used more commonly though. With a latched topic, the subscriber always receives the newest message that has been published right after the connection to the publisher is established.
This definitely seems to be the case, not the queue stuff I mention in my answer. :)
you can also look at https://answers.ros.org/question/3410...
Depending on the queue size you define on your publisher (or subscriber), and the rate at which you are publishing (or processing the incoming messages) it is perfectly possible that the publisher (or subscriber) is dropping messages.
Try to increase the publisher and subscriber queue sizes and see if this still happens.
Asked: 2012-05-17 22:10:06 -0600
Seen: 1,601 times
Last updated: May 18 '12
This problem is similar to another one, which also detailed solutions: http://answers.ros.org/question/11167/how-do-i-publish-exactly-one-message/