ui_answer.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import roslib
00004 roslib.load_manifest('srs_assisted_detection')
00005 
00006 #from srs_grasping.srv import *
00007 from geometry_msgs.msg import *
00008 
00009 from sensor_msgs.msg import *
00010 from srs_assisted_detection.srv import *
00011 from geometry_msgs.msg import *
00012 
00013 
00014 import rospy
00015 detect=UiDetectorResponse()
00016 func=0
00017 pose=Pose()
00018 action=''
00019 def answerObjectSrv(req):    
00020 
00021     rospy.loginfo("Get Object information")
00022 
00023     global func
00024     func=1
00025     #save
00026     #send action only grasp at the moment   
00027     global pose
00028     pose.position.x=detect.object_list.detections[req.id].pose.pose.position.x
00029     pose.position.y=detect.object_list.detections[req.id].pose.pose.position.y
00030     pose.position.z=detect.object_list.detections[req.id].pose.pose.position.z
00031     pose.orientation.x=detect.object_list.detections[req.id].pose.pose.orientation.x
00032     pose.orientation.y=detect.object_list.detections[req.id].pose.pose.orientation.y
00033     pose.orientation.z=detect.object_list.detections[req.id].pose.pose.orientation.z
00034     pose.orientation.w=detect.object_list.detections[req.id].pose.pose.orientation.w
00035     global action
00036     
00037     #default for user
00038     action='grasp'
00039 
00040     s.shutdown()
00041     s2.shutdown()
00042     moveBB=UiAnswerResponse()
00043     moveBB.message.data='get data waiting for action'
00044     return moveBB
00045         
00046 def moveBBSrv(req):
00047     rospy.loginfo("Get BB information")
00048 
00049     #BBmove service base and then movement
00050     moveBB=BBMoveResponse()
00051     moveBB.message.data='moving to better position'
00052     global func
00053     func=2
00054     
00055     global pose
00056     pose.position.x=1
00057     pose.position.y=2
00058     pose.position.z=3
00059     
00060     s.shutdown()
00061     s2.shutdown()
00062     return moveBB
00063     
00064 def assisted_answer_server(detections):
00065     #rospy.init_node('asisted_answer_server')
00066     global detect
00067     detect=detections
00068     global s
00069     global s2
00070     s = rospy.Service('assisted_answer', UiAnswer, answerObjectSrv)
00071     s2 = rospy.Service('assisted_BBmove', BBMove, moveBBSrv)
00072 
00073     rospy.loginfo("Assisted answer ready.")
00074     s.spin()
00075     s2.spin()
00076     return [func,pose,action]
00077 
00078 
00079 if __name__ == "__main__":
00080     assisted_answer_server('test')
00081     


srs_assisted_detection
Author(s): Heiko Hoennige
autogenerated on Mon Oct 6 2014 08:31:59