ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

ROS2 how can I call a service and wait for the response from within a subscriber callback?

asked 2018-06-21 09:51:35 -0500

vandy2000 gravatar image

I'd like to continue to spin but know when the request is available, using C++

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-06-21 13:34:01 -0500

William gravatar image

This is not currently possible, so you'll have to do an asynchronous service call, starting it in the subscription callback and finishing it in a callback when the response is received. Here's an example:

https://github.com/ros2/demos/blob/06...

In general, it's a bad idea to block in a subscription (or service, or timer) callback since that prevents other callbacks from being handled.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-06-21 09:51:35 -0500

Seen: 3,646 times

Last updated: Jun 21 '18