ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Getting list of publishers and subscribers for all ros topics in C++ code

asked 2022-02-24 20:32:31 -0500

naegling77 gravatar image

updated 2022-02-25 18:30:38 -0500

I want to get the list of all subscribers and publishers for a given topic in C++ code.

I know that in Python, you can do rostopic.get_topic_list() to get this information.

In C++, doing ros::master::getTopics(topics) would only provide information regarding the list of available topics and their datatypes. But it does not provide information on the nodes publishing and subscribing to it. Is there a C++ API for this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-02-26 00:52:33 -0500

miura gravatar image

You should be able to get it with ros::master::execute(). Use getPublishedTopics or getSystemState as the method.

For reference.

edit flag offensive delete link more

Question Tools


Asked: 2022-02-24 20:32:31 -0500

Seen: 956 times

Last updated: Feb 26 '22