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

Revision history [back]

click to hide/show revision 1
initial version

I also face the same issue, when i publish the message, the subscriber always missed the first message. The reason was already answered by @wim and it was correct.

To solve this issue, i used sleep() method with some milliseconds after publisher creation. So, meanwhile the publisher will make connection with all waiting subscribers. Then, you can start publishing message, and subscriber will receive all messages.

pub = rospy.Publisher('counter',Int32,queue_size=10)

rate = rospy.Rate(2)

rate.sleep() #sleep for 500ms

counter = 1;

while not rospy.is_shutdown(): pub.publish(counter) counter += 1 rate.sleep()

I also face the same issue, when i publish the message, the subscriber always missed the first message. The reason was already answered by @wim and it was correct.

To solve this issue, i used sleep() method with some milliseconds after publisher creation. So, meanwhile the publisher will make connection with all waiting subscribers. Then, you can start publishing message, and subscriber will receive all messages.

pub = rospy.Publisher('counter',Int32,queue_size=10)

rospy.Publisher('counter',Int32,queue_size=10)

rate = rospy.Rate(2)

rospy.Rate(2)

rate.sleep() #sleep for 500ms

500ms

counter = 1;

1;

while not rospy.is_shutdown(): pub.publish(counter) counter += 1 rate.sleep()

rate.sleep()