00001
00002
00003 import time
00004
00005 import roslib
00006 roslib.load_manifest('cob_script_server')
00007 import rospy
00008
00009 from simple_script_server import script
00010
00011 import tf
00012 from geometry_msgs.msg import *
00013
00014 class GraspScript(script):
00015
00016 def Initialize(self):
00017
00018
00019
00020
00021
00022
00023
00024
00025 handle01 = self.sss.move("arm","folded",False)
00026 self.sss.move("torso","home",False)
00027 self.sss.move("sdh","home",False)
00028 self.sss.move("tray","down")
00029 handle01.wait()
00030 if not self.sss.parse:
00031 print "Please localize the robot with rviz"
00032 self.sss.wait_for_input()
00033
00034
00035 def Run(self):
00036 listener = tf.TransformListener(True, rospy.Duration(10.0))
00037
00038
00039
00040 self.sss.move("base","rc_table_planning")
00041 self.sss.move_planned("arm","pregrasp")
00042 self.sss.move("sdh","cylopen")
00043
00044
00045 cup = PointStamped()
00046 cup.header.stamp = rospy.Time.now()
00047 cup.header.frame_id = "/map"
00048
00049
00050
00051 cup.point.x = 2.48
00052 cup.point.y = 1.22
00053 cup.point.z = 0.85
00054 self.sss.sleep(2)
00055
00056 if not self.sss.parse:
00057 cup = listener.transformPoint('/arm_7_link',cup)
00058
00059
00060
00061
00062 self.sss.move_planned("arm", "grasp")
00063
00064 self.sss.move("sdh","cylclosed")
00065
00066
00067
00068
00069 self.sss.move("tray","up")
00070
00071 self.sss.move_planned("arm","grasp-to-tablet")
00072 self.sss.move("sdh","cylopen")
00073
00074
00075 self.sss.move_planned("arm","tablet-to-folded")
00076 self.sss.sleep(4)
00077 self.sss.move("sdh","cylclosed",False)
00078
00079
00080
00081
00082 self.sss.move("base","rc_entrance")
00083
00084 self.sss.move("torso","nod")
00085
00086 if __name__ == "__main__":
00087 SCRIPT = GraspScript()
00088 SCRIPT.Start()