Service global name error
I'm having a lot of troubles doing the following in ROS: I would like to subscribe to a fakeARpublisher and resend a pose information through a service. In short, I did a script that it is subscribed to a topic and at the same time acts like a server for a service called LocalizePart. The code is given below:
#!/usr/bin/env python
# license removed for brevity
import rospy
from std_msgs.msg import String
from std_msgs.msg import Int16
from myworkcell.msg import message1
from myworkcell.srv import LocalizePart
from fake_ar_publisher.msg import ARMarker
import random
received_pose=ARMarker()
def callback(data):
#print "receiving data"
received_pose.pose=data.pose
# print "received_pose"
def handle_service2(req):
print "in the response"
#req.base_frame=received_pose
rospy.loginfo(rospy.get_caller_id() + "I heard %s", received_pose.pose)
print "Im here"
return LocalizePartResponse(received_pose.pose)
def vision_node_service_server_2():
rospy.init_node('myworkcell_node', anonymous=True)
#ROS_INFO("ScanNPlan node has been initialized");
#print "about to subscribe"
rospy.Subscriber('ar_pose_marker',ARMarker, callback)
print "hereeeee"
#print "subscribed"
#ROS_INFO("I'm subscribed to fake_ar_publisher");
#s=rospy.Service('localize_part',LocalizePart,handle_service2)
s=rospy.Service('Localize_Part',LocalizePart,handle_service2)
#print"I'm here already"
rospy.spin()
if __name__ == '__main__':
try:
vision_node_service_server_2()
except rospy.ROSInterruptException:
pass
But when I send a request to this service, it shows the following error:
Error processing request: global name 'LocalizePartResponse' is not defined
Any advise would be greatly appreciated. Thank you in advance