Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rospy publisher publishing not work immediately after creation #74

Open
jacknlliu opened this issue Aug 27, 2019 · 0 comments
Open

rospy publisher publishing not work immediately after creation #74

jacknlliu opened this issue Aug 27, 2019 · 0 comments

Comments

@jacknlliu
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant