rmw  master
C API providing a middleware abstraction layer which is used to implement the rest of ROS.
Functions
rmw.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "rcutils/macros.h"
#include "rcutils/types.h"
#include "rosidl_runtime_c/message_type_support_struct.h"
#include "rosidl_runtime_c/service_type_support_struct.h"
#include "rosidl_runtime_c/sequence_bound.h"
#include "rmw/init.h"
#include "rmw/macros.h"
#include "rmw/qos_profiles.h"
#include "rmw/subscription_options.h"
#include "rmw/message_sequence.h"
#include "rmw/types.h"
#include "rmw/visibility_control.h"
Include dependency graph for rmw.h:

Go to the source code of this file.

Functions

const char * rmw_get_implementation_identifier (void)
 Get the name of the rmw implementation being used. More...
 
const char * rmw_get_serialization_format (void)
 Get the unique serialization format for this middleware. More...
 
rmw_node_trmw_create_node (rmw_context_t *context, const char *name, const char *namespace_, size_t domain_id, bool localhost_only)
 Create a node and return a handle to that node. More...
 
rmw_ret_t rmw_destroy_node (rmw_node_t *node)
 Finalize a given node handle, reclaim the resources, and deallocate the node handle. More...
 
 RCUTILS_DEPRECATED_WITH_MSG ("rmw_node_assert_liveliness implementation was removed." " If manual liveliness assertion is needed, use MANUAL_BY_TOPIC.") rmw_ret_t rmw_node_assert_liveliness(const rmw_node_t *node)
 
const rmw_guard_condition_trmw_node_get_graph_guard_condition (const rmw_node_t *node)
 Return a guard condition which is triggered when the ROS graph changes. More...
 
rmw_ret_t rmw_init_publisher_allocation (const rosidl_message_type_support_t *type_support, const rosidl_runtime_c__Sequence__bound *message_bounds, rmw_publisher_allocation_t *allocation)
 Initialize a publisher allocation to be used with later publications. More...
 
rmw_ret_t rmw_fini_publisher_allocation (rmw_publisher_allocation_t *allocation)
 Destroy a publisher allocation object. More...
 
rmw_publisher_options_t rmw_get_default_publisher_options (void)
 Return a rmw_publisher_options_t initialized with default values. More...
 
rmw_publisher_trmw_create_publisher (const rmw_node_t *node, const rosidl_message_type_support_t *type_support, const char *topic_name, const rmw_qos_profile_t *qos_policies, const rmw_publisher_options_t *publisher_options)
 Create and return an rmw publisher. More...
 
rmw_ret_t rmw_destroy_publisher (rmw_node_t *node, rmw_publisher_t *publisher)
 
rmw_ret_t rmw_borrow_loaned_message (const rmw_publisher_t *publisher, const rosidl_message_type_support_t *type_support, void **ros_message)
 Borrow a loaned message. More...
 
rmw_ret_t rmw_return_loaned_message_from_publisher (const rmw_publisher_t *publisher, void *loaned_message)
 Return a loaned message previously borrow from a publisher. More...
 
rmw_ret_t rmw_publish (const rmw_publisher_t *publisher, const void *ros_message, rmw_publisher_allocation_t *allocation)
 Publish a given ros_message. More...
 
rmw_ret_t rmw_publish_loaned_message (const rmw_publisher_t *publisher, void *ros_message, rmw_publisher_allocation_t *allocation)
 Publish a loaned ros_message. More...
 
rmw_ret_t rmw_publisher_count_matched_subscriptions (const rmw_publisher_t *publisher, size_t *subscription_count)
 Retrieve the number of matched subscriptions to a publisher. More...
 
rmw_ret_t rmw_publisher_get_actual_qos (const rmw_publisher_t *publisher, rmw_qos_profile_t *qos)
 Retrieve the actual qos settings of the publisher. More...
 
rmw_ret_t rmw_publish_serialized_message (const rmw_publisher_t *publisher, const rmw_serialized_message_t *serialized_message, rmw_publisher_allocation_t *allocation)
 Publish an already serialized message. More...
 
rmw_ret_t rmw_get_serialized_message_size (const rosidl_message_type_support_t *type_support, const rosidl_runtime_c__Sequence__bound *message_bounds, size_t *size)
 Compute the size of a serialized message. More...
 
rmw_ret_t rmw_publisher_assert_liveliness (const rmw_publisher_t *publisher)
 Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC) More...
 
rmw_ret_t rmw_serialize (const void *ros_message, const rosidl_message_type_support_t *type_support, rmw_serialized_message_t *serialized_message)
 Serialize a ROS message into a rmw_serialized_message_t. More...
 
rmw_ret_t rmw_deserialize (const rmw_serialized_message_t *serialized_message, const rosidl_message_type_support_t *type_support, void *ros_message)
 Deserialize a ROS message. More...
 
rmw_ret_t rmw_init_subscription_allocation (const rosidl_message_type_support_t *type_support, const rosidl_runtime_c__Sequence__bound *message_bounds, rmw_subscription_allocation_t *allocation)
 Initialize a subscription allocation to be used with later takes. More...
 
rmw_ret_t rmw_fini_subscription_allocation (rmw_subscription_allocation_t *allocation)
 Destroy a publisher allocation object. More...
 
rmw_subscription_trmw_create_subscription (const rmw_node_t *node, const rosidl_message_type_support_t *type_support, const char *topic_name, const rmw_qos_profile_t *qos_policies, const rmw_subscription_options_t *subscription_options)
 Create and return an rmw subscription. More...
 
rmw_ret_t rmw_destroy_subscription (rmw_node_t *node, rmw_subscription_t *subscription)
 
rmw_ret_t rmw_subscription_count_matched_publishers (const rmw_subscription_t *subscription, size_t *publisher_count)
 Retrieve the number of matched publishers to a subscription. More...
 
rmw_ret_t rmw_subscription_get_actual_qos (const rmw_subscription_t *subscription, rmw_qos_profile_t *qos)
 Retrieve the actual qos settings of the subscription. More...
 
rmw_ret_t rmw_take (const rmw_subscription_t *subscription, void *ros_message, bool *taken, rmw_subscription_allocation_t *allocation)
 Take an incoming message from a subscription. More...
 
rmw_ret_t rmw_take_with_info (const rmw_subscription_t *subscription, void *ros_message, bool *taken, rmw_message_info_t *message_info, rmw_subscription_allocation_t *allocation)
 Take an incoming message from a subscription with additional metadata. More...
 
rmw_ret_t rmw_take_sequence (const rmw_subscription_t *subscription, size_t count, rmw_message_sequence_t *message_sequence, rmw_message_info_sequence_t *message_info_sequence, size_t *taken, rmw_subscription_allocation_t *allocation)
 Take multiple incoming messages from a subscription with additional metadata. More...
 
rmw_ret_t rmw_take_serialized_message (const rmw_subscription_t *subscription, rmw_serialized_message_t *serialized_message, bool *taken, rmw_subscription_allocation_t *allocation)
 Take a message without deserializing it. More...
 
rmw_ret_t rmw_take_serialized_message_with_info (const rmw_subscription_t *subscription, rmw_serialized_message_t *serialized_message, bool *taken, rmw_message_info_t *message_info, rmw_subscription_allocation_t *allocation)
 Take a message without deserializing it and with its additional message information. More...
 
rmw_ret_t rmw_take_loaned_message (const rmw_subscription_t *subscription, void **loaned_message, bool *taken, rmw_subscription_allocation_t *allocation)
 Take a loaned message. More...
 
rmw_ret_t rmw_take_loaned_message_with_info (const rmw_subscription_t *subscription, void **loaned_message, bool *taken, rmw_message_info_t *message_info, rmw_subscription_allocation_t *allocation)
 Take a loaned message and with its additional message information. More...
 
rmw_ret_t rmw_return_loaned_message_from_subscription (const rmw_subscription_t *subscription, void *loaned_message)
 Return a loaned message previously taken from a subscription. More...
 
rmw_client_trmw_create_client (const rmw_node_t *node, const rosidl_service_type_support_t *type_support, const char *service_name, const rmw_qos_profile_t *qos_policies)
 Create an rmw client to communicate with the specified service. More...
 
rmw_ret_t rmw_destroy_client (rmw_node_t *node, rmw_client_t *client)
 Destroy and unregister a service client. More...
 
rmw_ret_t rmw_send_request (const rmw_client_t *client, const void *ros_request, int64_t *sequence_id)
 Send a service request to the rmw server. More...
 
rmw_ret_t rmw_take_response (const rmw_client_t *client, rmw_service_info_t *request_header, void *ros_response, bool *taken)
 Attempt to get the response from a service request. More...
 
rmw_service_trmw_create_service (const rmw_node_t *node, const rosidl_service_type_support_t *type_support, const char *service_name, const rmw_qos_profile_t *qos_policies)
 Create an rmw service server that responds to requests. More...
 
rmw_ret_t rmw_destroy_service (rmw_node_t *node, rmw_service_t *service)
 Destroy and unregister the service from this node. More...
 
rmw_ret_t rmw_take_request (const rmw_service_t *service, rmw_service_info_t *request_header, void *ros_request, bool *taken)
 Attempt to take a request from this service's request buffer. More...
 
rmw_ret_t rmw_send_response (const rmw_service_t *service, rmw_request_id_t *request_header, void *ros_response)
 Send response to a client's request. More...
 
rmw_guard_condition_trmw_create_guard_condition (rmw_context_t *context)
 Create a guard condition and return a handle to that guard condition. More...
 
rmw_ret_t rmw_destroy_guard_condition (rmw_guard_condition_t *guard_condition)
 Finalize a given guard condition handle, reclaim the resources, and deallocate the handle. More...
 
rmw_ret_t rmw_trigger_guard_condition (const rmw_guard_condition_t *guard_condition)
 
rmw_wait_set_trmw_create_wait_set (rmw_context_t *context, size_t max_conditions)
 Create a wait set to store conditions that the middleware will block on. More...
 
rmw_ret_t rmw_destroy_wait_set (rmw_wait_set_t *wait_set)
 Destroy and free memory of this wait_set. More...
 
rmw_ret_t rmw_wait (rmw_subscriptions_t *subscriptions, rmw_guard_conditions_t *guard_conditions, rmw_services_t *services, rmw_clients_t *clients, rmw_events_t *events, rmw_wait_set_t *wait_set, const rmw_time_t *wait_timeout)
 Waits on sets of different waitable entities and returns when one is ready. More...
 
rmw_ret_t rmw_get_node_names (const rmw_node_t *node, rcutils_string_array_t *node_names, rcutils_string_array_t *node_namespaces)
 Return a list of node name and namespaces discovered via a node. More...
 
rmw_ret_t rmw_get_node_names_with_enclaves (const rmw_node_t *node, rcutils_string_array_t *node_names, rcutils_string_array_t *node_namespaces, rcutils_string_array_t *enclaves)
 Return a list of node name and namespaces discovered via a node with its enclave. More...
 
rmw_ret_t rmw_count_publishers (const rmw_node_t *node, const char *topic_name, size_t *count)
 Count the number of publishers matching a topic name. More...
 
rmw_ret_t rmw_count_subscribers (const rmw_node_t *node, const char *topic_name, size_t *count)
 Count the number of subscribers matching a topic name. More...
 
rmw_ret_t rmw_get_gid_for_publisher (const rmw_publisher_t *publisher, rmw_gid_t *gid)
 Get the unique identifier of the publisher. More...
 
rmw_ret_t rmw_compare_gids_equal (const rmw_gid_t *gid1, const rmw_gid_t *gid2, bool *result)
 Check if two gid objects are the same. More...
 
rmw_ret_t rmw_service_server_is_available (const rmw_node_t *node, const rmw_client_t *client, bool *is_available)
 Check if a service server is available for the given service client. More...
 
rmw_ret_t rmw_set_log_severity (rmw_log_severity_t severity)
 Set the current log severity. More...
 

Function Documentation

◆ rmw_get_implementation_identifier()

const char* rmw_get_implementation_identifier ( void  )

Get the name of the rmw implementation being used.

Returns
Name of rmw implementation

◆ rmw_get_serialization_format()

const char* rmw_get_serialization_format ( void  )

Get the unique serialization format for this middleware.

Return the format in which binary data is serialized. One middleware can only have one encoding. In contrast to the implementation identifier, the serialization format can be equal between multiple RMW implementations. This means, that the same binary messages can be deserialized by RMW implementations with the same format.

See also
rmw_serialize
rmw_deserialize
Returns
serialization format

◆ rmw_create_node()

rmw_node_t* rmw_create_node ( rmw_context_t context,
const char *  name,
const char *  namespace_,
size_t  domain_id,
bool  localhost_only 
)

Create a node and return a handle to that node.

This function can fail, and therefore return NULL, if:

  • context, name, namespace_, or security_options is NULL
  • context, security_options is invalid
  • memory allocation fails during node creation
  • an unspecified error occurs

The context must be non-null and valid, i.e. it has been initialized by rmw_init() and has not been finalized by rmw_shutdown().

The name and namespace_ should be valid node name and namespace, and this should be asserted by the caller (e.g. rcl).

The domain ID should be used to physically separate nodes at the communication graph level by the middleware. For RTPS/DDS this maps naturally to their concept of domain id.

The security options should always be non-null and encapsulate the essential security configurations for the node and its entities.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No [1]
Lock-Free No [1]

[1] rmw implementation defined, check the implementation documentation

This should be defined by the rmw implementation.

Parameters
[in]contextinit context that this node should be associated with
[in]namethe node name
[in]namespace_the node namespace
[in]domain_idthe id of the domain that the node should join
[in]security_optionsthe security configurations for the node
[in]localhost_onlywhenever to use loopback only for communication or default network interfaces.
Returns
rmw node handle or NULL if there was an error

◆ rmw_destroy_node()

rmw_ret_t rmw_destroy_node ( rmw_node_t node)

Finalize a given node handle, reclaim the resources, and deallocate the node handle.

The method may assume - but should verify - that all publishers, subscribers, services, and clients created from this node have already been destroyed. If the rmw implementation chooses to verify instead of assume, it should return RMW_RET_ERROR and set a human readable error message if any entity created from this node has not yet been destroyed.

Parameters
[in]nodethe node handle to be destroyed
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if node is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ RCUTILS_DEPRECATED_WITH_MSG()

RCUTILS_DEPRECATED_WITH_MSG ( "rmw_node_assert_liveliness implementation was removed." " If manual liveliness assertion is  needed,
use MANUAL_BY_TOPIC."   
) const

◆ rmw_node_get_graph_guard_condition()

const rmw_guard_condition_t* rmw_node_get_graph_guard_condition ( const rmw_node_t node)

Return a guard condition which is triggered when the ROS graph changes.

The handle returned is a pointer to an internally held rmw guard condition. This function can fail, and therefore return NULL, if:

  • node is NULL
  • node is invalid

The returned handle is made invalid if the node is destroyed or if rmw_shutdown() is called.

The guard condition will be triggered anytime a change to the ROS graph occurs. A ROS graph change includes things like (but not limited to) a new publisher advertises, a new subscription is created, a new service becomes available, a subscription is canceled, etc.


Attribute Adherence
Allocates Memory No
Thread-Safe Yes
Uses Atomics No
Lock-Free Yes
Parameters
[in]nodepointer to the rmw node
Returns
rmw guard condition handle if successful, otherwise NULL

◆ rmw_init_publisher_allocation()

rmw_ret_t rmw_init_publisher_allocation ( const rosidl_message_type_support_t *  type_support,
const rosidl_runtime_c__Sequence__bound *  message_bounds,
rmw_publisher_allocation_t allocation 
)

Initialize a publisher allocation to be used with later publications.

This creates an allocation object that can be used in conjunction with the rmw_publish method to perform more carefully control memory allocations.

This will allow the middleware to preallocate the correct amount of memory for a given message type and message bounds. As allocation is performed in this method, it will not be necessary to allocate in the rmw_publish method.

Parameters
[in]type_supportType support of the message to be preallocated.
[in]message_boundsBounds structure of the message to be preallocated.
[out]allocationAllocation structure to be passed to rmw_publish.
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if an argument is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_fini_publisher_allocation()

rmw_ret_t rmw_fini_publisher_allocation ( rmw_publisher_allocation_t allocation)

Destroy a publisher allocation object.

This deallocates any memory allocated by rmw_init_publisher_allocation.

Parameters
[in]allocationAllocation object to be destroyed.
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if argument is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_get_default_publisher_options()

rmw_publisher_options_t rmw_get_default_publisher_options ( void  )

Return a rmw_publisher_options_t initialized with default values.

◆ rmw_create_publisher()

rmw_publisher_t* rmw_create_publisher ( const rmw_node_t node,
const rosidl_message_type_support_t *  type_support,
const char *  topic_name,
const rmw_qos_profile_t qos_policies,
const rmw_publisher_options_t publisher_options 
)

Create and return an rmw publisher.

\TODO(wjwwood): add detailed documentation, adding a not about one of the arguments for now.

The argument publisher_options must not be nullptr.

Parameters
[in]publisher_optionsoptions for configuring the publisher

◆ rmw_destroy_publisher()

rmw_ret_t rmw_destroy_publisher ( rmw_node_t node,
rmw_publisher_t publisher 
)

◆ rmw_borrow_loaned_message()

rmw_ret_t rmw_borrow_loaned_message ( const rmw_publisher_t publisher,
const rosidl_message_type_support_t *  type_support,
void **  ros_message 
)

Borrow a loaned message.

The memory allocated for the ros message belongs to the middleware and must not be deallocated. A call to

See also
rmw_publish_loned_message as well as
rmw_return_loaned_message_from_publisher` will return ownership of the loaned message back to the middleware.

In order to react to failures, the ros message is passed by pointer as an output parameter. Therefore, the pointer to the ros message has to be null and not previously allocated or else that memory is lost.

Parameters
[in]publisherPublisher to which the allocated message is associated.
[in]type_supportTypesupport to which the internal ros message is allocated.
[out]ros_messageThe pointer to be filled with a valid ros message by the middleware.
Returns
RMW_RET_OK if the ros message was correctly initialized, or
RMW_RET_INVALID_ARGUMENT if an argument other than the ros message is null, or
RMW_RET_BAD_ALLOC if the ros message could not be correctly created, or
RMW_RET_UNSUPPORTED if the rmw_implementation does not support loaned_message, or
RMW_RET_ERROR if an unexpected error occured.

◆ rmw_return_loaned_message_from_publisher()

rmw_ret_t rmw_return_loaned_message_from_publisher ( const rmw_publisher_t publisher,
void *  loaned_message 
)

Return a loaned message previously borrow from a publisher.

The ownership of the passed in ros message will be transferred back to the middleware. The middleware might deallocate and destroy the message so that the pointer is no longer guaranteed to be valid after this call.

Parameters
[in]publisherPublisher to which the loaned message is associated.
[in]loaned_messageLoaned message to be returned.
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if an argument is null, or
RMW_RET_UNSUPPORTED if the rmw_implementation does not support loaned_message, or
RMW_RET_ERROR if an unexpected error occurs and no message can be initialized.

◆ rmw_publish()

rmw_ret_t rmw_publish ( const rmw_publisher_t publisher,
const void *  ros_message,
rmw_publisher_allocation_t allocation 
)

Publish a given ros_message.

Publish a given ROS message via a publisher.

Parameters
[in]publisherPublisher to be used to send message.
[in]ros_messageMessage to be sent.
[in]allocationSpecify preallocated memory to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if publisher or ros_message is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_publish_loaned_message()

rmw_ret_t rmw_publish_loaned_message ( const rmw_publisher_t publisher,
void *  ros_message,
rmw_publisher_allocation_t allocation 
)

Publish a loaned ros_message.

Publish a loaned ROS message via a publisher and return ownership of the loaned message back to the middleware.

In contrast to

See also
rmw_publish the ownership of the ros message is being transferred to the middleware which might deallocate the memory for it. Similar to
rmw_return_loaned_message_from_publisher the passed in ros message might not be valid after this call and thus should only be called with messages previously loaned with a call to
rmw_borrow_loaned_message.
Parameters
[in]publisherPublisher to be used to send message.
[in]ros_messageMessage to be sent.
[in]allocationSpecify preallocated memory to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if publisher or ros_message is null, or
RMW_RET_UNSUPPORTED if the rmw_implementation does not support loaned_message, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_publisher_count_matched_subscriptions()

rmw_ret_t rmw_publisher_count_matched_subscriptions ( const rmw_publisher_t publisher,
size_t *  subscription_count 
)

Retrieve the number of matched subscriptions to a publisher.

Query the underlying middleware to determine how many subscriptions are matched to a given publisher.

Parameters
[in]publisherthe publisher object to inspect
[out]subscription_countthe number of subscriptions matched
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if either argument is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_publisher_get_actual_qos()

rmw_ret_t rmw_publisher_get_actual_qos ( const rmw_publisher_t publisher,
rmw_qos_profile_t qos 
)

Retrieve the actual qos settings of the publisher.

Query the underlying middleware to determine the qos settings of the publisher. The actual configuration applied when using RMW_*_SYSTEM_DEFAULT can only be resolved after the creation of the publisher, and it depends on the underlying rmw implementation. If the underlying setting in use can't be represented in ROS terms, it will be set to RMW_*_UNKNOWN. The value of avoid_ros_namespace_conventions field is not resolved with this function. The rcl function rcl_publisher_get_actual_qos resolves it.

Parameters
[in]publisherthe publisher object to inspect
[out]qosthe actual qos settings
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if either argument is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_publish_serialized_message()

rmw_ret_t rmw_publish_serialized_message ( const rmw_publisher_t publisher,
const rmw_serialized_message_t serialized_message,
rmw_publisher_allocation_t allocation 
)

Publish an already serialized message.

The publisher must already be registered with the correct message type support so that it can send serialized data corresponding to that type. This function sends the serialized byte stream directly over the wire without having to serialize the message first. A ROS message can be serialized manually using the rmw_serialize() function.

Parameters
[in]publisherThe publisher object registered to send the message.
[in]serialized_messageThe serialized message holding the byte stream.
[in]allocationSpecify preallocated memory to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_get_serialized_message_size()

rmw_ret_t rmw_get_serialized_message_size ( const rosidl_message_type_support_t *  type_support,
const rosidl_runtime_c__Sequence__bound *  message_bounds,
size_t *  size 
)

Compute the size of a serialized message.

Given a message definition and bounds, compute the serialized size.

Parameters
[in]type_supportThe type support of the message to compute.
[in]boundsArtifical bounds to use on unbounded fields.
[out]sizeThe computed size of the serialized message.
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if either argument is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_publisher_assert_liveliness()

rmw_ret_t rmw_publisher_assert_liveliness ( const rmw_publisher_t publisher)

Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC)

If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC, the creator of this publisher may manually call assert_liveliness at some point in time to signal to the rest of the system that this Node is still alive.


Attribute Adherence
Allocates Memory No
Thread-Safe Yes
Uses Atomics No
Lock-Free Yes
Parameters
[in]publisherhandle to the publisher that needs liveliness to be asserted
Returns
RMW_RET_OK if the liveliness assertion was completed successfully, or
RMW_RET_ERROR if an unspecified error occurs, or
RMW_RET_UNSUPPORTED if the rmw implementation does not support asserting liveliness.

◆ rmw_serialize()

rmw_ret_t rmw_serialize ( const void *  ros_message,
const rosidl_message_type_support_t *  type_support,
rmw_serialized_message_t serialized_message 
)

Serialize a ROS message into a rmw_serialized_message_t.

The ROS message is serialized into a byte stream contained within the rmw_serialized_message_t structure. The serialization format depends on the underlying middleware.

Parameters
[in]ros_messagethe typed ROS message
[in]type_supportthe typesupport for the ROS message
[out]serialized_messagethe destination for the serialize ROS message
Returns
RMW_RET_OK if successful, or
RMW_RET_BAD_ALLOC if memory allocation failed, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_deserialize()

rmw_ret_t rmw_deserialize ( const rmw_serialized_message_t serialized_message,
const rosidl_message_type_support_t *  type_support,
void *  ros_message 
)

Deserialize a ROS message.

The given rmw_serialized_message_t's internal byte stream buffer is deserialized into the given ROS message. The ROS message must already be allocated and initialized, and must match the given typesupport structure. The serialization format expected in the rmw_serialized_message_t depends on the underlying middleware.

Parameters
[in]serialized_messagethe serialized message holding the byte stream
[in]type_supportthe typesupport for the typed ros message
[out]ros_messagedestination for the deserialized ROS message
Returns
RMW_RET_OK if successful, or
RMW_RET_BAD_ALLOC if memory allocation failed, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_init_subscription_allocation()

rmw_ret_t rmw_init_subscription_allocation ( const rosidl_message_type_support_t *  type_support,
const rosidl_runtime_c__Sequence__bound *  message_bounds,
rmw_subscription_allocation_t allocation 
)

Initialize a subscription allocation to be used with later takes.

This creates an allocation object that can be used in conjunction with the rmw_take method to perform more carefully control memory allocations.

This will allow the middleware to preallocate the correct amount of memory for a given message type and message bounds. As allocation is performed in this method, it will not be necessary to allocate in the rmw_take method.

Parameters
[in]type_supportType support of the message to be preallocated.
[in]message_boundsBounds structure of the message to be preallocated.
[out]allocationAllocation structure to be passed to rmw_take.
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if an argument is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_fini_subscription_allocation()

rmw_ret_t rmw_fini_subscription_allocation ( rmw_subscription_allocation_t allocation)

Destroy a publisher allocation object.

This deallocates memory allocated by rmw_init_subscription_allocation.

Parameters
[in]allocationAllocation object to be destroyed.
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if argument is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_create_subscription()

rmw_subscription_t* rmw_create_subscription ( const rmw_node_t node,
const rosidl_message_type_support_t *  type_support,
const char *  topic_name,
const rmw_qos_profile_t qos_policies,
const rmw_subscription_options_t subscription_options 
)

Create and return an rmw subscription.

\TODO(wjwwood): add detailed documentation, adding a not about one of the arguments for now.

The argument subscription_options must not be nullptr.

Parameters
[in]subscription_optionsoptions for configuring the subscription

◆ rmw_destroy_subscription()

rmw_ret_t rmw_destroy_subscription ( rmw_node_t node,
rmw_subscription_t subscription 
)

◆ rmw_subscription_count_matched_publishers()

rmw_ret_t rmw_subscription_count_matched_publishers ( const rmw_subscription_t subscription,
size_t *  publisher_count 
)

Retrieve the number of matched publishers to a subscription.

Query the underlying middleware to determine how many publishers are matched to a given subscription.

Parameters
[in]subscriptionthe subscription object to inspect
[out]publisher_countthe number of publishers matched
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if either argument is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_subscription_get_actual_qos()

rmw_ret_t rmw_subscription_get_actual_qos ( const rmw_subscription_t subscription,
rmw_qos_profile_t qos 
)

Retrieve the actual qos settings of the subscription.

Query the underlying middleware to determine the qos settings of the subscription. The actual configuration applied when using RMW_*_SYSTEM_DEFAULT can only be resolved after the creation of the subscription, and it depends on the underlying rmw implementation. If the underlying setting in use can't be represented in ROS terms, it will be set to RMW_*_UNKNOWN. The value of avoid_ros_namespace_conventions field is not resolved with this function. The rcl function rcl_subscription_get_actual_qos resolves it.

Parameters
[in]subscriptionthe subscription object to inspect
[out]qosthe actual qos settings
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if either argument is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_take()

rmw_ret_t rmw_take ( const rmw_subscription_t subscription,
void *  ros_message,
bool *  taken,
rmw_subscription_allocation_t allocation 
)

Take an incoming message from a subscription.

Take an incoming ROS message from a given subscription.

Parameters
[in]subscriptionThe subscription object to take from.
[out]ros_messageThe ROS message data on success.
[out]takenBoolean flag indicating if a message was taken or not.
[in]allocationPreallocated buffer to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_take_with_info()

rmw_ret_t rmw_take_with_info ( const rmw_subscription_t subscription,
void *  ros_message,
bool *  taken,
rmw_message_info_t message_info,
rmw_subscription_allocation_t allocation 
)

Take an incoming message from a subscription with additional metadata.

Take an incoming ROS message from a given subscription.

Parameters
[in]subscriptionThe subscription object to take from.
[out]ros_messageThe ROS message data on success.
[out]takenBoolean flag indicating if a message was taken or not.
[out]message_infoAdditional message metadata.
[in]allocationPreallocated buffer to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_take_sequence()

rmw_ret_t rmw_take_sequence ( const rmw_subscription_t subscription,
size_t  count,
rmw_message_sequence_t message_sequence,
rmw_message_info_sequence_t message_info_sequence,
size_t *  taken,
rmw_subscription_allocation_t allocation 
)

Take multiple incoming messages from a subscription with additional metadata.

Take a sequence of ROS messgages from a given subscription.

While count messages may be requested, fewer messages may be available on the subscription. In this case, only the currently available messages will be returned. The taken flag indicates the number of messages actually taken. The method will return RMW_RET_OK even in the case that fewer (or zero) messages were retrieved. from the subscription, and will RMW_RET_ERROR in the case of unexpected errors. In the case that count is zero, the function will return RMW_RET_INVALID_ARGUMENT.

message_sequence and message_info_sequence should be initialized and have sufficient capacity. It is not critical that the sequence sizes match, and they may be reused from previous calls. Both must be valid (not NULL) for the method to run successfully.

Parameters
[in]subscriptionThe subscription object to take from.
[in]countNumber of messages to attempt to take.
[out]message_sequenceThe sequence of ROS message data on success.
[out]message_info_sequenceThe sequence of additional message metadata on success.
[out]takenNumber of messages actually taken from subscription.
[in]allocationPreallocated buffer to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if an argument is invalid, or
RMW_RET_BAD_ALLOC if memory allocation failed, or
RMW_RET_INCORRECT_RMW_IMPLEMENTATION if the rmw implementation does not match, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_take_serialized_message()

rmw_ret_t rmw_take_serialized_message ( const rmw_subscription_t subscription,
rmw_serialized_message_t serialized_message,
bool *  taken,
rmw_subscription_allocation_t allocation 
)

Take a message without deserializing it.

The message is taken in its serialized form. In contrast to rmw_take, the message is not deserialized in its ROS type but rather returned as a byte stream. The subscriber has to be registered for a specific type. But instead of receiving the message as its corresponding message type, it is taken as a byte stream. If needed, this byte stream can then be deserialized in a ROS message with a call to rmw_deserialize.

Parameters
[in]subscriptionSubscription object to take from.
[out]serialized_messageThe destination in which to store the serialized message.
[out]takenBoolean flag indicating if a message was taken or not.
[in]allocationPreallocated buffer to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_BAD_ALLOC if memory allocation failed, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_take_serialized_message_with_info()

rmw_ret_t rmw_take_serialized_message_with_info ( const rmw_subscription_t subscription,
rmw_serialized_message_t serialized_message,
bool *  taken,
rmw_message_info_t message_info,
rmw_subscription_allocation_t allocation 
)

Take a message without deserializing it and with its additional message information.

The same as rmw_take_serialized_message(), except it also includes the rmw_message_info_t.

Parameters
[in]subscriptionSubscription object to take from.
[out]serialized_messageThe destination in which to store the serialized message.
[out]takenBoolean flag indicating if a message was taken or not.
[out]message_infoA structure containing meta information about the taken message.
[in]allocationPreallocated buffer to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_BAD_ALLOC if memory allocation failed, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_take_loaned_message()

rmw_ret_t rmw_take_loaned_message ( const rmw_subscription_t subscription,
void **  loaned_message,
bool *  taken,
rmw_subscription_allocation_t allocation 
)

Take a loaned message.

If capable, the middleware can loan messages containing incoming messages. The message is owned by the middleware and thus has to be returned with a call to

See also
rmw_return_loaned_message_from_subscription.
Parameters
[in]subscriptionSubscription object to take from.
[in,out]loaned_messageThe destination in which to store the loaned message.
[out]takenBoolean flag indicating if a message was taken or not.
[in]allocationPreallocated buffer to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_BAD_ALLOC if memory allocation failed, or
RMW_RET_UNSUPPORTED if the rmw_implementation does not support loaned_message, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_take_loaned_message_with_info()

rmw_ret_t rmw_take_loaned_message_with_info ( const rmw_subscription_t subscription,
void **  loaned_message,
bool *  taken,
rmw_message_info_t message_info,
rmw_subscription_allocation_t allocation 
)

Take a loaned message and with its additional message information.

If capable, the middleware can loan messages containing incoming messages. The message is owned by the middleware and thus has to be returned with a call to

See also
rmw_release_loaned_message.
Parameters
[in]subscriptionSubscription object to take from.
[in,out]loaned_messageThe destination in which to store the loaned message.
[out]takenBoolean flag indicating if a message was taken or not.
[out]message_infoA structure containing meta information about the taken message.
[in]allocationPreallocated buffer to use (may be NULL).
Returns
RMW_RET_OK if successful, or
RMW_RET_BAD_ALLOC if memory allocation failed, or
RMW_RET_UNSUPPORTED if the rmw_implementation does not support loaned_message, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_return_loaned_message_from_subscription()

rmw_ret_t rmw_return_loaned_message_from_subscription ( const rmw_subscription_t subscription,
void *  loaned_message 
)

Return a loaned message previously taken from a subscription.

After the taking a loaned message from the middleware, the middleware has to keep the memory for the loaned message alive and valid as long as the user is working with that loan. In order to indicate that the loaned message is no longer needed, the call to

See also
rmw_return_loaned_message_from_subscription tells the middleware that memory can be deallocated/destroyed.
Parameters
[in]subscriptionThe subscription instance which loaned the message.
[in]loaned_messageThe message to be released.

◆ rmw_create_client()

rmw_client_t* rmw_create_client ( const rmw_node_t node,
const rosidl_service_type_support_t *  type_support,
const char *  service_name,
const rmw_qos_profile_t qos_policies 
)

Create an rmw client to communicate with the specified service.

Parameters
[in]nodeHandle to node with which to register this client
[in]type_supportThe type_support of this rosidl service
[in]service_nameThe name of the ROS 2 service to connect with
[in]qos_policiesThe QoS profile policies to utilize for this connection
Returns
The initialized client if successful, nullptr if not

◆ rmw_destroy_client()

rmw_ret_t rmw_destroy_client ( rmw_node_t node,
rmw_client_t client 
)

Destroy and unregister a service client.

Parameters
[in]nodeThe associated node whose client will be destroyed
[in]clientThe service client to destroy
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_send_request()

rmw_ret_t rmw_send_request ( const rmw_client_t client,
const void *  ros_request,
int64_t *  sequence_id 
)

Send a service request to the rmw server.

Parameters
[in]clientThe connected client over which to send this request
[in]ros_requestthe request message to send to the server
[out]sequence_idA unique identification value to identify this request
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_take_response()

rmw_ret_t rmw_take_response ( const rmw_client_t client,
rmw_service_info_t request_header,
void *  ros_response,
bool *  taken 
)

Attempt to get the response from a service request.

Parameters
[in]clientThe connected client to check on this request
[out]request_headerHeader response information
[out]ros_responseThe response of this service request,
[out]takenTrue if the response was taken, false otherwise
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_create_service()

rmw_service_t* rmw_create_service ( const rmw_node_t node,
const rosidl_service_type_support_t *  type_support,
const char *  service_name,
const rmw_qos_profile_t qos_policies 
)

Create an rmw service server that responds to requests.

Parameters
[in]nodeThe node that responds the service requests
[in]type_supportThe type support description of this service
[in]service_nameThe name of this service advertised across the ROS graph
[in]qos_policiesThe QoS profile policies to utilize for connections
Returns
The created service object if successful, otherwise a nullptr

◆ rmw_destroy_service()

rmw_ret_t rmw_destroy_service ( rmw_node_t node,
rmw_service_t service 
)

Destroy and unregister the service from this node.

Parameters
[in]nodeThe node that owns the service that is being destroyed
[in]servicePointer to the service type created in rmw_create_service
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_take_request()

rmw_ret_t rmw_take_request ( const rmw_service_t service,
rmw_service_info_t request_header,
void *  ros_request,
bool *  taken 
)

Attempt to take a request from this service's request buffer.

Parameters
[in]serviceservice object that responds to these requests
[out]request_headerRequest information header with writer guid and sequence number
[out]ros_requestThe deserialized ros_request, and is unmodified if there are no requests
[out]takentrue if the request was taken, otherwise false
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_send_response()

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

Send response to a client's request.

Parameters
[in]serviceThe service that responding to this request
[in]request_headerThe request header obtained when this request was taken
[in]ros_responseThe response message to send to the client
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_create_guard_condition()

rmw_guard_condition_t* rmw_create_guard_condition ( rmw_context_t context)

Create a guard condition and return a handle to that guard condition.

This function can fail, and therefore return NULL, if:

  • context is NULL
  • context is invalid
  • memory allocation fails during guard condition creation
  • an unspecified error occurs

The context must be non-null and valid, i.e. it has been initialized by rmw_init() and has not been finalized by rmw_shutdown().


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No [1]
Lock-Free No [1]

[1] rmw implementation defined, check the implementation documentation

This should be defined by the rmw implementation.

Parameters
[in]contextinit context that this node should be associated with
Returns
rmw guard condition handle or NULL if there was an error

◆ rmw_destroy_guard_condition()

rmw_ret_t rmw_destroy_guard_condition ( rmw_guard_condition_t guard_condition)

Finalize a given guard condition handle, reclaim the resources, and deallocate the handle.

Parameters
[in]guard_conditionthe guard condition handle to be destroyed
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if guard_condition is null, or
RMW_RET_ERROR if an unexpected error occurs.

◆ rmw_trigger_guard_condition()

rmw_ret_t rmw_trigger_guard_condition ( const rmw_guard_condition_t guard_condition)

◆ rmw_create_wait_set()

rmw_wait_set_t* rmw_create_wait_set ( rmw_context_t context,
size_t  max_conditions 
)

Create a wait set to store conditions that the middleware will block on.

This function can fail, and therefore return NULL, if:

  • context is NULL
  • context is invalid
  • memory allocation fails during wait set creation
  • an unspecified error occurs

If max_conditions is 0, the wait set can store an unbounded number of conditions to wait on. If max_conditions is greater than 0, the number of conditions that can be attached to the wait set is bounded at max_conditions.

Parameters
[in]contextinit context that this node should be associated with
[in]max_conditionsThe maximum number of conditions that can be attached to the wait set.
Returns
A pointer to the created wait set, NULL if an error occurred.

◆ rmw_destroy_wait_set()

rmw_ret_t rmw_destroy_wait_set ( rmw_wait_set_t wait_set)

Destroy and free memory of this wait_set.

Parameters
[in]wait_setThe wait_set object to destroy
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_wait()

rmw_ret_t rmw_wait ( rmw_subscriptions_t subscriptions,
rmw_guard_conditions_t guard_conditions,
rmw_services_t services,
rmw_clients_t clients,
rmw_events_t events,
rmw_wait_set_t wait_set,
const rmw_time_t wait_timeout 
)

Waits on sets of different waitable entities and returns when one is ready.

Add conditions to the wait set and wait until a response comes in, or until the timeout is reached. The arrays contain type-erased representations of waitable entities. This function casts the pointers to middleware-specific conditions and adds them to the wait set.

The count variables in the arrays represents the number of valid pointers in the array. NULL pointers are in the array considered invalid. If they are encountered, an error is returned.

The array structs are allocated and deallocated outside of this function. They do not have any information about how much memory is allocated for the arrays.

After the wait wakes up, the entries in each array that correspond to conditions that were not triggered are set to NULL.

Parameters
[in]subscriptionsArray of subscriptions to wait on
[in]guard_conditionsArray of guard conditions to wait on
[in]servicesArray of services to wait on
[in]clientsArray of clients to wait on
[in]wait_setStorage for the wait set
[in]wait_timeoutIf NULL, block until a condition is ready. If zero, check only for immediately available conditions and don't block. Else, this represents the maximum time to wait for a response from the wait set.
Returns
RMW_RET_OK if success, or
RMW_RET_ERROR if error, or
RMW_RET_TIMEOUT if wait timed out.

◆ rmw_get_node_names()

rmw_ret_t rmw_get_node_names ( const rmw_node_t node,
rcutils_string_array_t node_names,
rcutils_string_array_t node_namespaces 
)

Return a list of node name and namespaces discovered via a node.

This function will return a list of node names and a list of node namespaces that are discovered via the middleware. The two lists represent pairs of namespace and name for each discovered node. The lists will be the same length and the same position will refer to the same node across lists.

The node parameter must not be NULL, and must point to a valid node.

The node_names parameter must not be NULL, and must point to a valid string array.

The node_namespaces parameter must not be NULL, and must point to a valid string array.

This function does manipulate heap memory. This function is not thread-safe. This function is lock-free.

Parameters
[in]nodethe handle to the node being used to query the ROS graph
[out]node_namesa list of discovered node names
[out]node_namespacesa list of discovered node namespaces
Returns
RMW_RET_OK if node the query was made successfully, or
RMW_RET_ERROR if an unspecified error occurs.

◆ rmw_get_node_names_with_enclaves()

rmw_ret_t rmw_get_node_names_with_enclaves ( const rmw_node_t node,
rcutils_string_array_t node_names,
rcutils_string_array_t node_namespaces,
rcutils_string_array_t enclaves 
)

Return a list of node name and namespaces discovered via a node with its enclave.

Similar to rmw_get_node_names, but it also provides the enclave name.

Parameters
[in]nodethe handle to the node being used to query the ROS graph
[out]node_namesa list of discovered node names
[out]node_namespacesa list of discovered node namespaces
[out]enclaveslist of discovered nodes' enclave names
Returns
RMW_RET_OK if node the query was made successfully, or
RMW_RET_ERROR if an unspecified error occurs.

◆ rmw_count_publishers()

rmw_ret_t rmw_count_publishers ( const rmw_node_t node,
const char *  topic_name,
size_t *  count 
)

Count the number of publishers matching a topic name.

Parameters
[in]nodermw node connected to the ROS graph
[in]topic_nameThe name of the topic to match under possible prefixes
[out]countThe number of publishers matching the topic name
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_count_subscribers()

rmw_ret_t rmw_count_subscribers ( const rmw_node_t node,
const char *  topic_name,
size_t *  count 
)

Count the number of subscribers matching a topic name.

Parameters
[in]nodermw node connected to the ROS graph
[in]topic_nameThe name of the topic to match under possible prefixes
[out]countThe number of subscribers matching the topic name
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_get_gid_for_publisher()

rmw_ret_t rmw_get_gid_for_publisher ( const rmw_publisher_t publisher,
rmw_gid_t gid 
)

Get the unique identifier of the publisher.

Parameters
[in]publisherThe publisher to get the gid of
[out]gidThe resulting gid
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_compare_gids_equal()

rmw_ret_t rmw_compare_gids_equal ( const rmw_gid_t gid1,
const rmw_gid_t gid2,
bool *  result 
)

Check if two gid objects are the same.

Parameters
[in]gid1One gid1 to compare
[in]gid2The other gid to compare
[out]booltrue if the gid objects match, false otherwise
Returns
RMW_RET_OK if successful, otherwise an appropriate error code

◆ rmw_service_server_is_available()

rmw_ret_t rmw_service_server_is_available ( const rmw_node_t node,
const rmw_client_t client,
bool *  is_available 
)

Check if a service server is available for the given service client.

This function will return true for is_available if there is a service server available for the given client.

The node parameter must not be NULL, and must point to a valid node.

The client parameter must not be NULL, and must point to a valid client.

The given client and node must match, i.e. the client must have been created using the given node.

The is_available parameter must not be NULL, and must point to a bool variable. The result of the check will be stored in the is_available parameter.

This function does manipulate heap memory. This function is not thread-safe. This function is lock-free.

Parameters
[in]nodethe handle to the node being used to query the ROS graph
[in]clientthe handle to the service client being queried
[out]is_availableset to true if there is a service server available, else false
Returns
RMW_RET_OK if node the check was made successfully, or
RMW_RET_ERROR if an unspecified error occurs.

◆ rmw_set_log_severity()

rmw_ret_t rmw_set_log_severity ( rmw_log_severity_t  severity)

Set the current log severity.

Parameters
[in]severityThe log severity to set
Returns
RMW_RET_OK if successful, otherwise an appropriate error code