Function rcl_publish_serialized_message

Function Documentation

rcl_ret_t rcl_publish_serialized_message(const rcl_publisher_t *publisher, const rcl_serialized_message_t *serialized_message, rmw_publisher_allocation_t *allocation)

Publish a serialized message on a topic using a publisher.

It is the job of the caller to ensure that the type of the serialized message parameter and the type associate with the publisher (via the type support) match. Even though this call to publish takes an already serialized serialized message, the publisher has to register its type as a ROS known message type. Passing a serialized message from a different type leads to undefined behavior on the subscriber side. The publish call might be able to send any abitrary serialized message, it is however not garantueed that the subscriber side successfully deserializes this byte stream.

Apart from this, the publish_serialized function has the same behavior as rcl_publish() expect that no serialization step is done.

Attribute

Adherence

Allocates Memory

No

Thread-Safe

Yes [1]

Uses Atomics

No

Lock-Free

Yes

[1] for unique pairs of publishers and messages, see above for more

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

  • serialized_message[in] pointer to the already serialized message in raw form

  • 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_BAD_ALLOC if allocating memory failed, 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_ERROR if an unspecified error occurs.