Rosanswers logo


How can i use a class method for rospy.Service()?

The .srv file is

int64 a
int64 b
bool response

The code in the server.py is

s = rospy.Service('setVelocity', SetVelocity, self.setVelocity)

The signature of the setVelocity method

def setVelocity (self, r, l)

In the client.py i've

s = rospy.ServiceProxy('setVelocity', SetVelocity)

and i get this error:

error processing request: setVelocity() takes exactly 3 arguments (2 given)

Sorry for my bad english

Originally posted by Dreadma on ROS Answers with karma: 3 on 2015-03-04

Post score: 0


1 Answer 1


Rosanswers logo

The service callback should only take one argument other than self, which will be of type [YourService]Request.

Originally posted by Dan Lazewatsky with karma: 9115 on 2015-03-04

This answer was ACCEPTED on the original site

Post score: 1


Your Answer

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