Is it possible to subscribe to a topic configured at runtime in a C++ node?
For example, is there an API to do the following in roscpp (adapted the code snippet seen here)?
type_name = rostopic.get_topic_type(topic_name, blocking=False)[0]
if type_name:
type_class = roslib.message.get_message_class(type_name)
subscriber = rospy.Subscriber(topic_name, type_class, callback)
Originally posted by moooeeeep on ROS Answers with karma: 194 on 2018-08-24
Post score: 1
Original comments
Comment by gvdhoorn on 2018-08-24:
May I suggest a topic change? "subscribe dynamically at runtime" is typically understood to mean: "create subscribers (for a specific msg type) at runtime". You seem to be asking how to create subscribers without knowing the msg type. That would be something else.
Comment by moooeeeep on 2018-08-24:
@gvdhoorn I updated the title to hopefully better express the intent of the question. Feel free to improve if you can come up with an even better title!
Comment by gvdhoorn on 2018-08-24:
I think this is perfect. Thanks.