0
$\begingroup$

Rosanswers logo

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


Originally posted by vandy2000 on ROS Answers with karma: 38 on 2018-06-21

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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/06f25e9c8801ea95a0c25260cb38f2f0c6af3ea0/demo_nodes_cpp/src/services/add_two_ints_client_async.cpp#L62-L73

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.


Originally posted by William with karma: 17335 on 2018-06-21

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.