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

Revision history [back]

This is normal (also... I assume you have a rospy.spin() after you publish, or else things are getting destructed too early). See http://answers.ros.org/question/9665/test-for-when-a-rospy-publisher-become-available?answer=14125#post-id-14125

Basically, there is a nonzero amount of time where a subscriber actually subscribes to a publisher. If a publisher publishes a message during that time, the subscriber will not receive it, as it was not yet subscribed when the message was sent. If you want any subscriber to get the last message the publisher sent when it connects, you should use a latched topic.

When you do rospy.sleep(1) before publishing, you are allowing some time for the subscribers to connect before you actually publish the message. Therefore, the subscriber does receive the message.