Ask Your Question

Get all topics that publish a given message?

asked 2020-12-11 14:43:01 -0500

Martian gravatar image

How to get the names of all topics that publish a given message? E.g. when I add an image viewer in RVIZ, it already lists for you all topics that publish a sensor_msgs/Image message, so you choose which one you want to subscribe to! How can I achieve something like this in C++? Say I have a message called A, I want to get the names of all topics that publish A. Appreciate any help or suggestions:-)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-12-11 23:27:05 -0500

Apologies if this is the wrong part of the rviz code that does what you're asking, but I think what you're looking for is ros::master::getTopics()which is used here in rviz to get the list of topics and add them to the display for drop downs (~85% sure this is the right thing, but it was a quick glance, either way this will do what you're asking).

Here's the API docs for that file and it clearly shows the basic "get info" style calls to get all the topics and nodes on the network graph.

edit flag offensive delete link more


These links are more than enough for my question to be answered! Thanks a lot for the references:-)

Martian gravatar image Martian  ( 2020-12-12 05:56:05 -0500 )edit

Your Answer

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

Add Answer

Question Tools



Asked: 2020-12-11 14:43:01 -0500

Seen: 24 times

Last updated: Dec 11 '20