Ask Your Question
0

How to pass a string argument to a service call

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

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

Comments

1

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

ahendrix gravatar imageahendrix ( 2016-10-17 17:43:48 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

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

pablocesar gravatar image

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

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
0

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

Cerin gravatar image

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 1,434 times

Last updated: Oct 20 '16