Ask Your Question

Subscribing to a message type regardless of the topic name

asked 2017-04-28 14:52:46 -0500

updated 2017-04-28 14:58:54 -0500

Is there a way to subscribe to all messages of a given type without knowing their topic names? It would be perfect, if the callback function could additionally see the related topic name.

My application: I would like to write a node, which is supposed to do some administrative work and therefor collects all sensor_msgs/CameraInfo messages from every camera on my robot. But I don't know how many cameras my robot has.

This question comes close to what I need, but I'd still have to maintain a list of all my cameras separately. Any ideas?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-28 15:19:42 -0500

gvdhoorn gravatar image

You could probably use the Master API to get a list of all publishers for a particular message type (getTopicTypes(..)). Then iterate over that and subscribe to the topics that you're interested in.

edit flag offensive delete link more


Thanks for the hint. That looks good.

Andre Volk gravatar image Andre Volk  ( 2017-05-01 09:52:36 -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

1 follower


Asked: 2017-04-28 14:52:46 -0500

Seen: 230 times

Last updated: Apr 28 '17