Function rcl_get_publishers_info_by_topic
Defined in File graph.h
Function Documentation
-
rcl_ret_t rcl_get_publishers_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 *publishers_info)
Return a list of all publishers to a topic.
The
node
parameter must point to a valid node.The
topic_name
parameter must not beNULL
.When the
no_mangle
parameter istrue
, the providedtopic_name
should be a valid topic name for the middleware (useful when combining ROS with native middleware (e.g. DDS) apps). When theno_mangle
parameter isfalse
, the providedtopic_name
should follow ROS topic name conventions. In either case, the topic name should always be fully qualified.Each element in the
publishers_info
array will contain the node name, node namespace, topic type, gid and the qos profile of the publisher. It is the responsibility of the caller to ensure thatpublishers_info
parameter points to a valid struct of type rcl_topic_endpoint_info_array_t. Thecount
field inside the struct must be set to 0 and theinfo_array
field inside the struct must be set to null.
The
allocator
will be used to allocate memory to theinfo_array
member inside ofpublishers_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]
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
publishers_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 namepublishers_info – [out] a struct representing a list of publisher 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.