How to implement service in a class in rospy with no args?
I'm trying to implement a service on Kinetic (no args, two return values) but I am getting the error:
service [/classify_container] responded with an error: error processing request: classify_container() takes exactly 1 argument (2 given)
Where am I going wrong?
Classification.srv
---
string class_name
float32 confidence
The Service
from pytorch_ros.srv import Classification
class PytorchNode(object):
def __init__(self):
classification_service = rospy.Service('classify',
Classification,
self.classify_handle)
def classify_handle(self):
# do some stuff
# to get the classification
# .....
# construct msg and return
classification_msg = Classification()
classification_msg.class_name = self.names[classification]
classification_msg.confidence = confidence
return classification_msg
The client
#!/usr/bin/env python
from __future__ import division
from __future__ import print_function
import rospy
from pytorch_ros.srv import Classification
rospy.wait_for_service('classify_container')
try:
srv_classify_container = rospy.ServiceProxy('classify_container', Classification)
classification = srv_classify_container()
print(classification.class_name)
print(classification.confidence)
except rospy.ServiceException as e:
print("Service call failed: %s" % e)