Function rcl_count_subscribers
Defined in File graph.h
Function Documentation
-
rcl_ret_t rcl_count_subscribers(const rcl_node_t *node, const char *topic_name, size_t *count)
Return the number of subscriptions on a given topic.
The
node
parameter must point to a valid node.The
topic_name
parameter must not beNULL
, and must not be an empty string. It should also follow the topic name rules.See: https://design.ros2.org/articles/topic_and_service_names.html
The
count
parameter must point to a valid bool. Thecount
parameter is the output for this function and will be set.In the event that error handling needs to allocate memory, this function will try to use the node’s allocator.
The topic name is not automatically remapped by this function. If there is a subscriber created with topic name
foo
and remap rulefoo:=bar
then calling this withtopic_name
set tobar
will return a count of 1, and withtopic_name
set tofoo
will return a count of 0. /sa rcl_remap_topic_name()Attribute
Adherence
Allocates Memory
No
Thread-Safe
No
Uses Atomics
No
Lock-Free
Maybe [1]
- Parameters:
node – [in] the handle to the node being used to query the ROS graph
topic_name – [in] the name of the topic in question
count – [out] number of subscriptions on the given topic
- 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_ERROR if an unspecified error occurs.