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

The best way to implement something like this is rospy.wait_for_message(..). Creating Subscribers in callbacks is not a good idea.

If you're really only interested in a single message (which happens to be 'the last' only because of latching) then don't create the Subscriber, but use rospy.wait_for_message(..) only.

The best way to implement something like this is rospy.wait_for_message(..). Creating Subscribers in callbacks is not a good idea.

If you're really only interested in a single message (which happens to be 'the last' only because of latching) then don't create the Subscriber, but use rospy.wait_for_message(..) only.

Note btw that what you show in your question text is really brittle: there is no way to guarantee that globvar will contain an actual message object at that point.