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

Subscribe multiple topics using fuzzy string matching?

asked 2020-11-27 16:04:05 -0500

runtao gravatar image

updated 2020-11-27 17:09:26 -0500

Hi, let's say I want to subscribe multiple topics in one node. All the topics are named with same prefix, such as "/prefix_topic_a","/prefix_topic_b","/prefix_topic_c"...

Since the amount is not fixed, a hard-coding of subscription topic cannot be used. Is there anyway to find all topics with a certain prefix and automatically create subscribers for each topic? maybe using fuzzy string matching? Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-11-28 01:39:52 -0500

miura gravatar image

It was interesting to me to check it out: https://answers.ros.org/question/2068... You can get a list of topics from the C++ code, as shown in If you can get the topics, you'll be able to make partial matches or create a subscriber from them.

edit flag offensive delete link more

Comments

@miura, thanks, but it uses the master node in ROS1, which ROS2 dosen't have. How could the functionality be used in ROS2?

runtao gravatar image runtao  ( 2020-11-28 04:35:47 -0500 )edit

For ROS2, it seems that get_topic_names_and_types can be used.

You can also use get_topic_names_and_types in ROS2. http://docs.ros2.org/bouncy/api/rclcp...

miura gravatar image miura  ( 2020-11-28 04:40:39 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-11-27 16:04:05 -0500

Seen: 322 times

Last updated: Nov 28 '20