ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

What is the proper approach to create a dynamic *number* of subscribers/services?

asked 2016-07-06 14:31:05 -0500

curranw gravatar image

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:

  1. Create a subscriber for each robot?
  2. 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:

  1. Use the parameter server with the number of robots. Works for both subscribers and services. Use the same callback for each robot.
  2. 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?
  3. Some better method using service calls?
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-07-07 07:30:49 -0500

kramer gravatar image

See if my answer to a similar question is helpful as an alternative. Upon re-reading my answer, I realize I wasn't as clear as I could have been; apologies in advance.

Perhaps you're aware of this already, but a note/warning: be careful with service calls. They block, and may cause a performance hit, especially if you have a proliferating number them (as you seem to be suggesting).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-07-06 14:31:05 -0500

Seen: 648 times

Last updated: Jul 07 '16