00001
00002
00003 import time
00004
00005 import roslib
00006 roslib.load_manifest('cob_script_server')
00007 import rospy
00008 from std_msgs.msg import *
00009
00010 import simple_script_server
00011
00012 class GetDrink:
00013 def __init__(self):
00014 rospy.init_node('test_script')
00015 self.sss = simple_script_server.simple_script_server()
00016 rospy.Subscriber("/phidgetAO", Int16, self.phidget_callback)
00017 self.phidget_data = 0
00018
00019 def Initialize(self):
00020 self.sss.Init("tray")
00021 self.sss.Init("torso")
00022 self.sss.Init("arm")
00023 self.sss.Init("sdh")
00024
00025
00026 def phidget_callback(self,msg):
00027 self.phidget_data = msg.data
00028
00029 def run(self):
00030
00031 print "start"
00032
00033 usr_in = self.sss.wait_for_input()
00034
00035
00036 self.sss.SpeakStr("I will get the bottle for you.","FEST_EN")
00037 self.sss.Move("base","kitchen")
00038
00039 arm_pre_g = self.sss.Move("arm","pregrasp",False)
00040 self.sss.SetLight("red")
00041 tray_up = self.sss.Move("tray","up",False)
00042 self.sss.Move("sdh","cylopen")
00043 arm_pre_g.wait()
00044 tray_up.wait()
00045
00046
00047
00048 self.sss.Move("arm","grasp")
00049 self.sss.Move("sdh","cylclosed")
00050
00051
00052
00053 self.sss.Move("arm","grasp-to-tablet")
00054 self.sss.Move("arm","tablet")
00055 self.sss.Move("sdh","cylopen")
00056
00057
00058
00059 arm_folded = self.sss.Move("arm","tablet-to-folded",False)
00060 self.sss.sleep(3)
00061 self.sss.Move("sdh","home")
00062 arm_folded.wait()
00063
00064
00065
00066
00067 nod = self.sss.Move("torso","nod",False)
00068 self.sss.SetLight("green")
00069 nod.wait()
00070
00071
00072
00073
00074
00075 user_input = self.sss.wait_for_input()
00076
00077 self.sss.Move("tray","down",False)
00078 self.sss.SpeakStr("Enjoy!","FEST_EN")
00079
00080 self.sss.sleep(10)
00081 self.sss.Move("base","home")
00082
00083 print "finished"
00084
00085 if __name__ == "__main__":
00086 SCRIPT = GetDrink()
00087
00088 SCRIPT.run()