Function rmw_send_response

Function Documentation

rmw_ret_t rmw_send_response(const rmw_service_t *service, rmw_request_id_t *request_header, void *ros_response)

Send a ROS service response.

Send a ROS service response to the service client, with matching QoS policies, from which the previously taken ROS service request was originally sent.

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 response 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 responses may need to perform additional memory allocations when dealing with unbounded (dynamically-sized) fields.

Thread-safety

Service servers are thread-safe objects, and so are all operations on them except for finalization. Therefore, it is safe to send responses using the same service server concurrently. However:

  • Access to the given ROS service request header is read-only but it is not synchronized. Concurrent request_header reads are safe, but concurrent reads and writes are not.

  • Access to the given ROS service response is read-only but it is not synchronized. Concurrent ros_request reads are safe, but concurrent reads and writes are not.

Parameters:
  • service[in] Service server to send a response with.

  • request_header[in] Service response header, same as the one taken with the corresponding ROS service request.

  • ros_response[in] ROS service response to be sent.

Pre:

Given service must be a valid service server, as returned by rmw_create_service().

Pre:

Given request_header must be the one previously taken along with the ROS service request to which we reply.

Pre:

Given ros_response must be a valid service response, whose type matches the service type support registered with the service on creation.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_BAD_ALLOC if memory allocation fails, or

Returns:

RMW_RET_INVALID_ARGUMENT if service is NULL, or

Returns:

RMW_RET_INVALID_ARGUMENT if request_header is NULL, or

Returns:

RMW_RET_INVALID_ARGUMENT if ros_response is NULL, or

Returns:

RMW_RET_INCORRECT_RMW_IMPLEMENTATION if the service implementation identifier does not match this implementation, or

Returns:

RMW_RET_TIMEOUT if a response reader is not ready yet, or

Returns:

RMW_RET_ERROR if an unexpected error occurs.