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

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.