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

But, you're never returning a value from the service callback now? The subscribe callback function is completely unrelated to the service callback function.

If you want the service to return a value received on the topic, you have to let the topic CB store the value in some shared variable. As your service function already has a wait loop, you could poll this value there to see if it's been set. You probably want to have some global boolean also to make sure the value has been updated since the service was called (unless returning an old value is fine).

Don't know if I'd call this solution a good design, though...