Ask Your Question

rospy service multiple argument

asked 2014-06-26 07:19:09 -0600

Maya gravatar image

updated 2014-06-26 07:19:32 -0600





With check being defined as :

def check(self, rep, robot_id):

How can I do it in python ?

Thanks a lot

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2014-06-26 08:14:06 -0600

bajo gravatar image

updated 2014-07-02 06:10:31 -0600


i am not sure why you want two different services that perform the same function. Other than that i would do as you mentioned and include this data in the service definition (.srv file).


When you look at the definition of the rospy services you can clearly see that there are no callback arguments expected. You can always use your Service definition in the .srv you are using to add a field like an string or int for the robot ID to be passed to the service call. For example you could take the AddTwoInts.srv

int64 a
int64 b
int64 sum

and modify it to look like this

int64 a
int64 b
int64 robotid
int64 sum

In your service callback you can than access this value and change the response message accordingly. For this you should rename the file, add it to the CMakeLists.txt in the package the .srv file is in and make a catkin_make to generate the needed include files.

edit flag offensive delete link more



That's exactly what I end up doing. Why can"t we use argument in services ? :/

Maya gravatar imageMaya ( 2014-06-30 05:43:16 -0600 )edit

Your Answer


Add Answer

Question Tools

1 follower


Asked: 2014-06-26 07:19:09 -0600

Seen: 752 times

Last updated: Jul 02 '14