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

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

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

naegling77 gravatar image

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

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
0

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

miura gravatar image

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

For reference. http://docs.ros.org/en/indigo/api/ros... https://gist.github.com/bechu/6222399 http://docs.ros.org/en/melodic/api/ro...

edit flag offensive delete link more

Question Tools

Stats

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

Seen: 1,154 times

Last updated: Feb 26 '22