Go to the documentation of this file.00001
00002
00003 import roslib
00004 roslib.load_manifest('srs_assisted_detection')
00005
00006
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
00026
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
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
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
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