Robotics StackExchange | Archived questions

Using service client to get data in rviz2 plguin

In a custom rviz2 plugin, I try to display data received by client from server.

I got the following error.

terminate called after throwing an instance of 'std::runtimeerror' what(): spinonce() called while already spinning

My code is similar to the following

https://github.com/introlab/rtabmap_ros/blob/humble-devel/src/rviz/MapCloudDisplay.cpp#L557

Is it possible at the moment to use client in rviz2 plugin to get receive data.

This is related to rviz2 not on user level code.

Asked by bvbdort on 2023-03-13 07:45:41 UTC

Comments

Answers

You're gonna need to either use asynchronous requests, or make a new rclcpp::Node, and create your client off of it, and spin that node.

For reference, the async_send_request method does take a second argument, which is the callback to run when the response is relieved. See https://github.com/ros2/examples/blob/humble/rclcpp/services/async_client/main.cpp#L97 for an example.

Asked by ChuiV on 2023-03-17 18:53:31 UTC

Comments