Robotics StackExchange | Archived questions

How to pass a string argument to a service call

I have a service that accepts a single string argument called "data". The .srv definition is simply:

string data
---

If I try to call my service with:

rosservice call /mynode/myservice "some text"

I get the error:

ERROR: service [/mynode/myservice] responded with an error: service cannot process request: handler returned invalid value: Invalid number of arguments, args should be [] args are(,)

The wiki's advice on specifying command-line strings doesn't seem to be correct.

What am I doing wrong?

Asked by Cerin on 2016-10-17 16:42:29 UTC

Comments

It seems like the caller is ok, and the error is on the server side.

Asked by ahendrix on 2016-10-17 17:43:48 UTC

Answers

Honestly, so far I can't find any problem with the way that you are calling your service. Assuming that there is not a problem with your service configuration (which based on the error message it is recognized by ROS), then I only can start guessing what could be the problem.

Did you try to call it in this way:

rosservice call /mynode/myservice "data: some text"

in any case, you should try to call it without the space in between the two words, just to check if it is the reason of the error ;-)

 rosservice call /mynode/myservice "some_text"

Asked by pablocesar on 2016-10-20 04:45:39 UTC

Comments

I was returning the wrong response type in my callback. I was returning the auto-generated MyServiceResponse object for my service's srv file. Even though my service has no return types, this apparently means something's still returned. The fix was to to return EmptyResponse()...

Asked by Cerin on 2016-10-20 08:43:28 UTC

Comments

Thank you so much for posting your solution to this error - this was exactly what was happening to me.

Asked by madserEile on 2020-04-12 10:13:21 UTC