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

How to pass a string argument to a service call

asked 2016-10-17 16:42:29 -0600

Cerin gravatar image

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?

edit retag flag offensive close merge delete



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

ahendrix gravatar image ahendrix  ( 2016-10-17 17:43:48 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-10-20 08:43:28 -0600

Cerin gravatar image

updated 2016-10-20 08:46:00 -0600

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()...

edit flag offensive delete link more


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

madserEile gravatar image madserEile  ( 2020-04-12 10:13:21 -0600 )edit

answered 2016-10-20 04:45:39 -0600

pablocesar gravatar image

updated 2016-10-20 04:46:50 -0600

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"
edit flag offensive delete link more

Question Tools



Asked: 2016-10-17 16:42:29 -0600

Seen: 4,414 times

Last updated: Oct 20 '16