Creating a service that accepts no arguments
I am trying to create a service that accepts no arguments and returns a string. My attempt in srv file was
---
string return_value
The node that implements the service looks like this
from testService.srv import NoArguments
import rospy
def service_implementation():
return "answer"
if __name__=="__main__":
rospy.init_node('service_node')
s = rospy.Service('service_with_no_arguments', NoArguments, service_implementation)
rospy.spin()
However, when I try to call it, I get an error:
error processing request: service_implementation() takes no arguments (1 given)
What would be the right way to define a service that accepts no arguments?
EDIT: I noticed that one way to do it would be to add (some) argument to service_implementation so that it looks like
def service_implementation(request):
return "answer"