Function rcl_send_request

Function Documentation

rcl_ret_t rcl_send_request(const rcl_client_t *client, const void *ros_request, int64_t *sequence_number)

Send a ROS request using a client.

It is the job of the caller to ensure that the type of the ros_request parameter and the type associate with the client (via the type support) match. Passing a different type to send_request produces undefined behavior and cannot be checked by this function and therefore no deliberate error will occur.

rcl_send_request() is an non-blocking call.

The ROS request message given by the ros_request void pointer is always owned by the calling code, but should remain constant during send_request.

This function is thread safe so long as access to both the client and the ros_request is synchronized. That means that calling rcl_send_request() from multiple threads is allowed, but calling rcl_send_request() at the same time as non-thread safe client functions is not, e.g. calling rcl_send_request() and rcl_client_fini() concurrently is not allowed. Before calling rcl_send_request() the message can change and after calling rcl_send_request() the message can change, but it cannot be changed during the send_request call. The same ros_request, however, can be passed to multiple calls of rcl_send_request() simultaneously, even if the clients differ. The ros_request is unmodified by rcl_send_request().

Attribute

Adherence

Allocates Memory

No

Thread-Safe

Yes [1]

Uses Atomics

No

Lock-Free

Yes

[1] for unique pairs of clients and requests, see above for more

Parameters:
  • client[in] handle to the client which will make the response

  • ros_request[in] type-erased pointer to the ROS request message

  • sequence_number[out] the sequence number

Returns:

RCL_RET_OK if the request was sent successfully, or

Returns:

RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or

Returns:

RCL_RET_CLIENT_INVALID if the client is invalid, or

Returns:

RCL_RET_ERROR if an unspecified error occurs.