Send request function for client
Is there a way to make a generic send request function for the client in ROS2 services? Or is each send request unique to the service
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Is there a way to make a generic send request function for the client in ROS2 services? Or is each send request unique to the service
Client-Server communication via services is a 1 to 1 communication. When you create a client
auto client = node->create_client<ServiceT>(service_name, qos);
This client can only send requests to the service specified by service name
. In order to change its service you need to create again the object.
From your question it looks like you want to send the same ServiceT::Request
object to multiple servers.
The ServiceT::Request
object is not linked to any specific server or client and it can be reused as many times you want.
Assuming that you created multiple clients, what you can do is
ServiceT::Request request;
client1->send_request(request);
client2->send_request(request);
Asked: 2019-08-02 09:44:20 -0500
Seen: 299 times
Last updated: Aug 02 '19
Declaring a dependency on a system package that is not available on Windows
[ROS2] Using colcon doesn't create any file inside the install/<package>/share directory
Create Dockerfile for ros2 package : ament_cmake error
ROS2 nodes launched with systemd aren't discovered
Optitrack Motion Capture system and robot localization in Nav2 stack
How to use WS2812B LED lights with ROS 2 node
ros2 include a launch file from a launch file