Function rcl_publish_loaned_message

Function Documentation

rcl_ret_t rcl_publish_loaned_message(const rcl_publisher_t *publisher, void *ros_message, rmw_publisher_allocation_t *allocation)

Publish a loaned message on a topic using a publisher.

A previously borrowed loaned message can be sent via this call to rcl_publish_loaned_message(). By calling this function, the ownership of the loaned message is getting transferred back to the middleware. The pointer to the ros_message

is not guaranteed to be valid after as the middleware migth deallocate the memory for this message internally. It is thus recommended to call this function only in combination with

Apart from this, the

publish_loaned_message function has the same behavior as rcl_publish() except that no serialization step is done.

Attribute

Adherence

Allocates Memory

No [0]

Thread-Safe

Yes [1]

Uses Atomics

No

Lock-Free

Yes

[0] the middleware might deallocate the loaned message. The RCL function however does not allocate any memory. [1] for unique pairs of publishers and messages, see above for more

Parameters:
  • publisher[in] handle to the publisher which will do the publishing

  • ros_message[in] pointer to the previously borrow loaned message

  • allocation[in] structure pointer, used for memory preallocation (may be NULL)

Returns:

RCL_RET_OK if the message was published successfully, or

Returns:

RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or

Returns:

RCL_RET_PUBLISHER_INVALID if the publisher is invalid, or

Returns:

RCL_RET_UNSUPPORTED if the middleware does not support that feature, or

Returns:

RCL_RET_ERROR if an unspecified error occurs.