ROS2 async_send_request callback

asked 2021-04-15 17:33:14 -0500 gravatar image

updated 2021-04-16 16:07:32 -0500

I have created code similar to this example:

However, in my code, when I call async_send_request

this->client_->async_send_request( request, callback );

I pass a callback of type

rclcpp::Client<cpp_rpispi::srv::Spixfer>::CallbackType && callback

However, in the callback, I am trying to publish to a topic, but the compiler states that the call to publish is not allowed since the callback has to be static, but the publisher is non-static.

So, how can I pass a non-static member function as the callback so I can publish a topic?



Problem solved by using a local anonymous function instead.

edit retag flag offensive close merge delete


Is there any way not using anonymous function?

DC pig gravatar image DC pig  ( 2022-03-28 21:47:39 -0500 )edit