ROS2 async_send_request callback

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

scott.nortman@gmail.com gravatar image

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

I have created code similar to this example:

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

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?

Thanks

UPDATE

Problem solved by using a local anonymous function instead.

edit retag flag offensive close merge delete