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

Subscribing to a message type regardless of the topic name

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

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

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
1

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

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

Comments

Thanks for the hint. That looks good.

Andre Volk gravatar image Andre Volk  ( 2017-05-01 09:52:36 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 408 times

Last updated: Apr 28 '17