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

Revision history [back]

Latching works, but in case you do not want latching messages, a short wait between the Publisher declaration and the actual publishing of the message will do the trick, for example:

pub = rospy.Publisher('topic_name', String, queue_size=10)
rospy.sleep(0.5)
pub.publish("no delay")

Latching works, but in case you do not want latching messages, a short wait between the Publisher declaration and the actual publishing of the message will do the trick, for example:

pub = rospy.Publisher('topic_name', String, queue_size=10)
rospy.sleep(0.5)
pub.publish("no delay")

I mention this because your question seems to imply that the wait is needed for the message to be received, when it seems to me that it is actually needed for it to be published. in other words, messages do not seem to get published during the half second immediately following the publisher declaration.

Edit: Suboptimal answer. Please see comments by @NEngelhard and @gvdhoorn

Original Answer:

Latching works, but in case you do not want latching messages, a short wait between the Publisher declaration and the actual publishing of the message will do the trick, for example:

pub = rospy.Publisher('topic_name', String, queue_size=10)
rospy.sleep(0.5)
pub.publish("no delay")

I mention this because your question seems to imply that the wait is needed for the message to be received, when it seems to me that it is actually needed for it to be published. in other words, messages do not seem to get published during the half second immediately following the publisher declaration.