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

asked 2022-09-19 16:18:37 -0600

Myzhar gravatar image

updated 2022-09-19 16:21:56 -0600

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++?

edit retag flag offensive close merge delete

Comments

1

This may help #q359681

ravijoshi gravatar image ravijoshi  ( 2022-09-20 01:03:13 -0600 )edit

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

Myzhar gravatar image Myzhar  ( 2022-09-20 04:35:12 -0600 )edit

Glad you made it work.

ravijoshi gravatar image ravijoshi  ( 2022-09-20 04:55:58 -0600 )edit