Ask Your Question
0

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
1

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 https://github.com/ros-visualization/... 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 http://docs.ros.org/en/melodic/api/ro... 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

Comments

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

2 followers

Stats

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

Seen: 24 times

Last updated: Dec 11 '20