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

Revision history [back]

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.