Open
Description
pub = rospy.Publisher("my_topic_name", String)
msg = String()
msg.data = "Open"
pub.publish(msg)
the above code will not work in which the publisher only publishing once after the publisher creation.
Solution:
- add
latch=True
when create the publisher
pub = rospy.Publisher("my_topic_name", String, latch=True)
msg = String()
msg.data = "Open"
pub.publish(msg)
- add sleep seconds after creation
pub = rospy.Publisher("my_topic_name", String)
rospy.sleep(2.0)
msg = String()
msg.data = "Open"
pub.publish(msg)
You should design your nodes in a way that they either do not rely on each message to arrive or consider using latched topics to at least get the last message when the connections is established after it was initially published. —— ros/ros_comm#176 (comment)
Reference
Metadata
Metadata
Assignees
Labels
No labels