Create N subscribers to N topics without knowing value of N
Hello,
Is there a way to create N subscribers to N topics that all have the same message structure, without knowing beforehand what the value of N is? N will be determined from a ROS parameter.
The topic names will be incrementing, such as /ROBOT_1/joint_states, /ROBOT_2/joint_states, ... , /ROBOT_N/joint_states. I have been able to modify the topicName to subscribe to successfully and confirmed this by logging the topicName from a for loop that goes up to N.
I am unsure of how to create N subscribers though inside the for loop that I am using. Also open to other methods that do not use a for loop if they exist. Any help would be appreciated.
Thanks!