rmw  master
C API providing a middleware abstraction layer which is used to implement the rest of ROS.
get_topic_names_and_types.h File Reference
#include "rmw/macros.h"
#include "rmw/names_and_types.h"
#include "rmw/types.h"
#include "rmw/visibility_control.h"
Include dependency graph for get_topic_names_and_types.h:

Go to the source code of this file.


rmw_ret_t rmw_get_topic_names_and_types (const rmw_node_t *node, rcutils_allocator_t *allocator, bool no_demangle, rmw_names_and_types_t *topic_names_and_types)
 Return a list of topic names and their types. More...

Function Documentation

◆ rmw_get_topic_names_and_types()

rmw_ret_t rmw_get_topic_names_and_types ( const rmw_node_t node,
rcutils_allocator_t allocator,
bool  no_demangle,
rmw_names_and_types_t topic_names_and_types 

Return a list of topic names and their types.

This function returns a list of topic names in the ROS graph and their types.

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

The topic_names_and_types parameter must be allocated and zero initialized. The topic_names_and_types is the output for this function, and contains allocated memory. Therefore, it should be passed to rmw_names_and_types_fini() when it is no longer needed. Failing to do so will result in leaked memory.

There may be some demangling that occurs when listing the topics from the middleware implementation. This is the mechanism by which this function can discriminate between ROS topics, non-ROS topics, and topics which may be used to implement other concepts like ROS Services.

For example, if the underlying implementation is DDS or RTPS, ROS specific prefixes may be prepended to the user namespace, and the namespace may be stripped of leading and trailing slashes, see:


As well as:


If the no_demangle argument is true, then the topic names given by the middleware will be returned without any demangling or filtering. For example, the ROS topic /foo may be returned as rt/foo or the DDS topic (non-ROS topic) with a partition list `['foo', 'bar']and topicbaz may be returned asfoo/baz` (note that only the first partition is used but it is still concatenated to the topic).

[in]nodethe handle to the node being used to query the ROS graph
[in]allocatorallocator to be used when allocating space for strings
[in]no_demangleif true, list all topics without any demangling
[out]topic_names_and_typeslist of topic names and their types
RMW_RET_OK if the query was successful, or
RMW_RET_INVALID_ARGUMENT if the node is invalid, or
RMW_RET_INVALID_ARGUMENT if any arguments are invalid, or
RMW_RET_BAD_ALLOC if memory allocation fails, or
RMW_RET_ERROR if an unspecified error occurs.