Generic Ros Service Clients

asked 2015-10-07 13:02:04 -0600

theNerd247 gravatar image

I'm currently trying to use the topic_tools/mux node to multiplex multiple topics using the same selector (which is implemented as a ROS service). Now, I've recently discovered that ROS Services cannot be created with the same name, and if they are then the most recent Services gets created and the ones before are destroyed (without notification to the user by the way which is not good in the sense that it may not be intended by the user). So then, another solution would be to create the multiplexer each with a different service name. Then I would create another node that broadcasted to these services. Now, I would like to make this generic (as it would be very useful for later use) such that this node would:

  • take __N__ output service names, and an input service name (called __S__) via program arguments
  • For each __N__ services name create a ServiceClient and check to make sure all clients have the same request and respond ROS types. If they don't then exit with some failure type
  • Then advertise a service with name __S__. This service will simply take the called request and forward it to each of the __N__ clients. The response from these clients can be ignored (for now).

My current problem is that I can't find a way to determine the Service type based on the given qualified service name using the current roscpp API. I may be missing something however, it appears that the only way to create a ROS Service client is to know the Request and Respond types first; there is no generic wrapper around this so that applications - such as mine - can forward client requests to services without regard to the type. This seems to be possible as I would assume that there is some class that the roscpp API is using to bind a service's name with its service type - that and the topic_tools/mux node seems to be able to do this for topics (that is forwarding the messages from one topic to another without regard to the topic message types). And though services are different than topics they both seem to be based on message types.

edit retag flag offensive close merge delete