00001
00002
00003
00004 import time
00005
00006 import roslib
00007 roslib.load_manifest('cob_script_server')
00008 import rospy
00009
00010 from simple_script_server import script
00011
00012 import tf
00013 from geometry_msgs.msg import *
00014 from gazebo_plugins.msg import *
00015
00016 oneTime = 0;
00017
00018 class GraspScript(script):
00019
00020 def Initialize(self):
00021
00022 self.sss.init("tray")
00023 self.sss.init("torso")
00024 self.sss.init("arm")
00025 self.sss.set_operation_mode("arm", "position")
00026 self.sss.init("sdh")
00027 self.sss.init("base")
00028
00029 self.thumb_sub = rospy.Subscriber("/sdh_thumb_2_bumper/state",ContactsState,self.callback)
00030 self.thumb_sub = rospy.Subscriber("/sdh_controller/tactile_data",TactileSensor,self.callback_hw)
00031
00032
00033
00034 handle01 = self.sss.move("arm","folded",False)
00035 self.sss.move("torso","home",False)
00036 self.sss.move("sdh","home",False)
00037 self.sss.move("tray","down")
00038 handle01.wait()
00039 if not self.sss.parse:
00040 print "Please localize the robot with rviz"
00041 self.sss.wait_for_input()
00042
00043
00044 def Run(self):
00045 listener = tf.TransformListener(True, rospy.Duration(10.0))
00046
00047 handle01 = self.sss.move("base","table_cup_start")
00048
00049
00050 self.sss.move("arm","pregrasp")
00051 self.sss.move("arm","pregrasp_tablecup")
00052 self.sss.move("sdh","table_cup_open")
00053
00054 self.sss.move("base","table_cup_end")
00055
00056 def callback(self,data):
00057 global oneTime
00058 if oneTime==0:
00059 self.sss.move("sdh","cup")
00060
00061 handle01 = self.sss.move("arm","overtablet",False)
00062 self.sss.move("tray","up")
00063 handle01.wait()
00064 self.sss.move("sdh","cylopen")
00065 self.sss.move_cart_rel("arm",[[0.0, 0.0, -0.2], [0, 0, 0]])
00066 handle01 = self.sss.move("arm","tablet-to-folded",False)
00067 self.sss.move("sdh","cylclosed",False)
00068 handle01.wait()
00069 oneTime = 1;
00070
00071 if __name__ == "__main__":
00072 SCRIPT = GraspScript()
00073 SCRIPT.Start()