Rosanswers logo

I'm trying to create a service that returns an array of a custom msg. However, when I call this using roservice call /myservice [input params...] I get the following error:

ERROR: service [/myservice] responded with an error: service cannot process request: handler returned wrong number of values: Invalid number of arguments, args should be ['parsed'] args are(operation: travel_to
target: a1
time_step: 0, operation:open ... )

Based on this I assumed that the type I was returning was wrong, so outputted the type just before the return statement in Python, however they seem to be what I expect them to be based on the documentation here

type: type 'list'
element type: class 'asp_model.msg._SubGoal.SubGoal'

.srv file

string goal
string entityA
string entityB
Subgoal[] parsed
.msg file
string operation
string target
int16 time_step

Some additional info: I also tried simply returning a list of integers [1, 2, 3], which with the response type set to Int16[] which resulted in the same error. I'm running on ROS Hydro, Ubuntu 12.04, no other errors show up when running catkin_make or running the server

Any ideas on how to go about fixing this? I'm not sure if I'm completely misunderstanding the error message!

Edit1: Python on server, I've removed code indicated by the '...' as its some lengthy regex and string parsing stuff:

    def parse_answer(self, raw):
        parsed = []  # Use this to save list of SubGoals
        for step in anslist:
            if step:
                parsed.append(SubGoal(operation=operation[0], target=target[0], time_step=int(time_step)))

        return parsed

Originally posted by genericsoup on ROS Answers with karma: 45 on 2015-02-08

Post score: 0

Original comments

Comment by ahendrix on 2015-02-09:
Please post the python code for your server. I suspect you're returning the wrong type.

Comment by genericsoup on 2015-02-09:
Edited question to include relevant code - unsure if you get a notification when I edit, hence the comment. Thanks :)


1 Answer 1


Rosanswers logo

@ahendrix is right. You returned the wrong type.

Have a detailed look at the python service tutorial.

You have to return an instance of <YourServiceType>Response instead of a list of SubGoal. In this Response you can store the SubGoals.

Originally posted by BennyRe with karma: 2949 on 2015-02-09

This answer was ACCEPTED on the original site

Post score: 2


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.