ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
1

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
0

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. 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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 181 times

Last updated: Feb 26