Function rcl_get_subscriptions_info_by_topic

Function Documentation

rcl_ret_t rcl_get_subscriptions_info_by_topic(const rcl_node_t *node, rcutils_allocator_t *allocator, const char *topic_name, bool no_mangle, rcl_topic_endpoint_info_array_t *subscriptions_info)

Return a list of all subscriptions to a topic.

The node parameter must point to a valid node.

The topic_name parameter must not be NULL.

When the no_mangle parameter is true, the provided topic_name should be a valid topic name for the middleware (useful when combining ROS with native middleware (e.g. DDS) apps). When the no_mangle parameter is false, the provided topic_name should follow ROS topic name conventions. In either case, the topic name should always be fully qualified.

Each element in the subscriptions_info array will contain the node name, node namespace, topic type, gid and the qos profile of the subscription. It is the responsibility of the caller to ensure that subscriptions_info parameter points to a valid struct of type rcl_topic_endpoint_info_array_t. The count field inside the struct must be set to 0 and the info_array

field inside the struct must be set to null.

The

allocator will be used to allocate memory to the info_array member inside of subscriptions_info. Moreover, every const char * member inside of rmw_topic_endpoint_info_t will be assigned a copied value on allocated memory.

Attribute

Adherence

Allocates Memory

Yes

Thread-Safe

No

Uses Atomics

No

Lock-Free

Maybe [1]

[1] implementation may need to protect the data structure with a lock

See also

rmw_get_zero_initialized_topic_endpoint_info_array

See also

rmw_topic_endpoint_info_set_node_name and the likes. However, it is the responsibility of the caller to reclaim any allocated resources to subscriptions_info to avoid leaking memory.

See also

rmw_topic_endpoint_info_array_fini

Parameters:
  • node[in] the handle to the node being used to query the ROS graph

  • allocator[in] allocator to be used when allocating space for the array inside publishers_info

  • topic_name[in] the name of the topic in question

  • no_mangle[in] if true, topic_name needs to be a valid middleware topic name, otherwise it should be a valid ROS topic name

  • subscriptions_info[out] a struct representing a list of subscriptions information

Returns:

RCL_RET_OK if the query was successful, or

Returns:

RCL_RET_NODE_INVALID if the node is invalid, or

Returns:

RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or

Returns:

RCL_RET_BAD_ALLOC if memory allocation fails, or

Returns:

RCL_RET_ERROR if an unspecified error occurs.