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

rosservice is the recommended way of doing this. That link will help understand when to use each.

That being said, sometimes if I'm just trying to hack something together quick and am not worried about overhead, and if a node that I want to get info from is already setup as a topic publisher, I'll just subscribe to the topic. An easy way to do this and only poll it periodically, is to have the subscriber's callback funciton simply copy the data to a member variable if you're using a class (or a global varible, which is messy). That way, elsewhere in your application, you can just poll your member variable when ever you need the info, and it will always have the most recent value.

Hope that helps.