Robotics StackExchange | Archived questions

Is it possible to create a "generic subscription" in ROS2 Foxy

Hello,

I'm using rclcpp with ROS2 Foxy and I need to create a generic ROS2 Foxy subscriber whose type is available only at runtime.

I can use get_topic_names_and_types to extract the topic type from the known topic name, but it is not possible to use it with templates to call the create_subscription function.

Is there a way to perform this operation in C++?

Asked by Myzhar on 2022-09-19 16:18:37 UTC

Comments

This may help #q359681

Asked by ravijoshi on 2022-09-20 01:03:13 UTC

OK, I found a generic subscription class in rosbag2: https://github.com/ros2/rosbag2/tree/foxy/rosbag2_transport/src/rosbag2_transport

Asked by Myzhar on 2022-09-20 04:35:12 UTC

Glad you made it work.

Asked by ravijoshi on 2022-09-20 04:55:58 UTC

Answers