Function rmw_send_request
Defined in File rmw.h
Function Documentation
-
rmw_ret_t rmw_send_request(const rmw_client_t *client, const void *ros_request, int64_t *sequence_id)
Send a ROS service request.
Send a ROS service request to one or more service servers, with matching QoS policies, using the given client.
On success, this function will return a sequence number. It is up to callers to save the returned sequence number to pair the ROS service request just sent with future ROS service responses (taken using rmw_take_response()).
Attribute
Adherence
Allocates Memory
Maybe
Thread-Safe
Yes
Uses Atomics
Maybe [1]
Lock-Free
Maybe [1]
[1] implementation defined, check implementation documentation.
- Runtime behavior
It is implementation defined whether sending a ROS service request is a synchronous or asynchronous, and blocking or non-blocking, operation. However, asynchronous implementations are not allowed to access the given ROS service request after this function returns. Check the implementation documentation to learn about request behavior.
- Memory allocation
It is implementation defined whether memory will be allocated on send or not. For instance, implementations that serialize ROS service requests may need to perform additional memory allocations when dealing with unbounded (dynamically-sized) fields.
- Thread-safety
Service clients are thread-safe objects, and so are all operations on them except for finalization. Therefore, it is safe to send requests using the same service client concurrently. However:
Access to the given ROS service request is read-only but it is not synchronized. Concurrent
ros_request
reads are safe, but concurrent reads and writes are not.Access to given primitive data-type arguments is not synchronized. It is not safe to read or write
sequence_id
while rmw_send_request() uses it.
Note
It is implementation defined how many service servers may get, and potentially react to, the same request, considering there may be more than one server for the same service in the ROS graph.
- Parameters:
client – [in] Service client to send a request with.
ros_request – [in] ROS service request to be sent.
sequence_id – [out] Sequence number for the
ros_request
just sent i.e. a unique identification number for it, populated on success.
- Pre:
Given
client
must be a valid client, as returned by rmw_create_client().- Pre:
Given
ros_request
must be a valid service request, whose type matches the service type support registered with theclient
on creation.- Returns:
RMW_RET_OK
if successful, or- Returns:
RMW_RET_BAD_ALLOC
if memory allocation fails, or- Returns:
RMW_RET_INVALID_ARGUMENT
ifclient
is NULL, or- Returns:
RMW_RET_INVALID_ARGUMENT
ifros_request
is NULL, or- Returns:
RMW_RET_INVALID_ARGUMENT
ifsequence_id
is NULL, or- Returns:
RMW_RET_INCORRECT_RMW_IMPLEMENTATION
if theclient
implementation identifier does not match this implementation, or- Returns:
RMW_RET_ERROR
if an unexpected error occurs.