Function rmw_get_subscriptions_info_by_topic
Defined in File get_topic_endpoint_info.h
Function Documentation
-
rmw_ret_t rmw_get_subscriptions_info_by_topic(const rmw_node_t *node, rcutils_allocator_t *allocator, const char *topic_name, bool no_mangle, rmw_topic_endpoint_info_array_t *subscriptions_info)
Retrieve endpoint information for each known subscription of a given topic.
This function returns an array of endpoint information for each subscription of a given topic, as discovered so far by the given node. Endpoint information includes the subscription’s node name and namespace, the associated topic type, the subscription’s gid, and the subscription QoS profile. Names of non-existent topics are allowed, in which case an empty array will be returned.
Attribute
Adherence
Allocates Memory
Yes
Thread-Safe
Yes
Uses Atomics
Maybe [1]
Lock-Free
Maybe [1]
See also
rmw_get_publishers_info_by_topic() for more details.
- QoS that are correctly read
Not all QoS may be read correctly,
- Runtime behavior
To query the ROS graph is a synchronous operation. It is also non-blocking, but it is not guaranteed to be lock-free. Generally speaking, implementations may synchronize access to internal resources using locks but are not allowed to wait for events with no guaranteed time bound (barring the effects of starvation due to OS scheduling).
- Thread-safety
Nodes are thread-safe objects, and so are all operations on them except for finalization. Therefore, it is safe to query the ROS graph using the same node concurrently. However, when querying subscriptions’ information:
Access to the array of topic endpoint information is not synchronized. It is not safe to read or write
subscriptions_info
while rmw_get_subscriptions_info_by_topic() uses it.The default allocators are thread-safe objects, but any custom
allocator
may not be. Check your allocator documentation for further reference.
- Parameters:
node – [in] Node to query the ROS graph.
allocator – [in] Allocator to be used when populating the
subscriptions_info
array.topic_name – [in] Name of the topic for subscription lookup, often a fully qualified topic name but not necessarily (see rmw_create_subscription()).
no_mangle – [in] Whether to mangle the topic name before subscription lookup or not.
subscriptions_info – [out] Array of subscription information, populated on success, left unchanged on failure. If populated, it is up to the caller to finalize this array later on, using rmw_topic_endpoint_info_array_fini(). QoS Profiles in the info array will use RMW_DURATION_INFINITE for infinite durations, avoiding exposing any implementation-specific values.
- Pre:
Given
node
must be a valid node handle, as returned by rmw_create_node().- Pre:
Given
subscriptions_info
must be a zero-initialized array of endpoints’ information, as returned by rmw_get_zero_initialized_topic_endpoint_info_array().- Returns:
RMW_RET_OK
if the query was successful, or- Returns:
RMW_RET_INVALID_ARGUMENT
ifnode
is NULL, or- Returns:
RMW_RET_INVALID_ARGUMENT
ifallocator
is not valid, by rcutils_allocator_is_valid() definition, or- Returns:
RMW_RET_INVALID_ARGUMENT
iftopic_name
is NULL, or- Returns:
RMW_RET_INVALID_ARGUMENT
ifsubscriptions_info
is NULL, or- Returns:
RMW_RET_INVALID_ARGUMENT
ifsubscriptions_info
is not a zero-initialized array, or- Returns:
RMW_RET_INCORRECT_RMW_IMPLEMENTATION
if thenode
implementation identifier does not match this implementation, or- Returns:
RMW_RET_BAD_ALLOC
if memory allocation fails, or- Returns:
RMW_RET_ERROR
if an unspecified error occurs.