What is the proper approach to create a dynamic *number* of subscribers/services?
I have n number of robots, and I want to gather each of their positions. Each robot is under a different namespace so I have the topics:
/robot1/pose
/robot2/pose
/robotn/pose
If the namespace follows the same convention, is it better to:
- Create a subscriber for each robot?
- Create a service-client for each robot?
And given a subscriber or service, what is the proper way to dynamically find the services/topics to subscribe to?
Thoughts:
- Use the parameter server with the number of robots. Works for both subscribers and services. Use the same callback for each robot.
- Have each robot republish their pose onto a joint /pose_all topic and use one subscriber. Can differentiate between robots using PoseStamped. Simplest seeming solution (no parameters to remember to update...), but is it hacky?
- Some better method using service calls?