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

You can get the next message in a topic using ros::topic::waitForMessage().

Note that internally this creates a subscriber on the topic you're interested in, waits for the next message to arrive, and then closes itself down and returns that message to you, so it's a fairly heavy operation, and requires that the topic it's listening to is either a latched topic, or is published frequently.