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

How to correctly return an array of ints from service?

asked 2021-04-24 06:36:49 -0500

mbostic gravatar image

I have the following code:

RouteRemainder.srv:

---
int64[] route_remainder

routes_manager,py:

...    
rospy.Service( "/route_remainder", RouteRemainder, self.route_remainder_callback)
...
def route_remainder_callback(self, msg):
    return [1, 2, 3]

When I call rosservice call /route_remainder, I get:

ERROR: service [/route_remainder] responded with an error: service cannot process request: handler returned wrong number of values: Invalid number of arguments, args should be ['route_remainder'] args are(1, 2, 3)

What could be the problem?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-04-24 06:44:02 -0500

mbostic gravatar image

I had to wrap the return value into a tuple:

return ([1,2,3],)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-04-24 06:34:51 -0500

Seen: 132 times

Last updated: Apr 24 '21