steve.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib
00004 roslib.load_manifest('pr2_simple_interface')
00005 roslib.load_manifest('sound_play')
00006 #import rospy
00007 
00008 #rospy.init_node('steve_demo')
00009 from pr2_simple_interface import *
00010 from sound_play.msg import SoundRequest
00011 from sound_play.libsoundplay import SoundClient
00012 start()
00013 #############################################################
00014 # HowTo:
00015 # 
00016 # Look around:
00017 # head.look_at( 1.0, [left+/right-], [ up>1, down <1 ])
00018 #
00019 # Open grippers:
00020 # gripper.rel( [LEFT | RIGHT | BOTH] )
00021 #
00022 # Close grippers
00023 # gripper.close( [LEFT | RIGHT | BOTH] )
00024 #
00025 # Wait for slap on gripper
00026 # gripper.wait_for_slap( [LEFT | RIGHT | BOTH] )
00027 #
00028 # Move torso up/down
00029 # torso.set( [height] )
00030 #
00031 # Move arms
00032 # arm.move_to([-1.42, 0.640, 0.647, -1.925, 30.931, -0.521, -16.642], RIGHT)
00033 #             [ position ], [ LEFT | RIGHT | BOTH] )
00034 # arm.move_to([shoulder_pan,shoulder_life
00035 #
00036 # Speech:
00037 # sound.say("Something")
00038 
00039 
00040 gripper = Gripper()
00041 arm = RobotArm()
00042 head = Head()
00043 torso = Torso()
00044 sound = SoundClient()
00045 
00046 rospy.sleep(1)
00047 
00048 # move torso up
00049 torso.set(0.1)
00050 
00051 #robot speaks
00052 sound.say("Hi! I'm PR2.")
00053 
00054 # nod head
00055 head.look_at(1.0, 0.0, 0.5) # look down
00056 head.wait_for()             # wait for head to stop moving
00057 head.look_at(1.0, 0.0, 1.5) # look up
00058 head.wait_for()
00059 head.look_at(1.0, 0.0, 0.5)
00060 head.wait_for()
00061 head.look_at(1.0, 0.0, 1.5)
00062 head.wait_for()
00063 head.look_at(1.0, 0.0, 1.0)
00064 head.wait_for()
00065 torso.set(0.0)
00066 
00067 # look straight ahead
00068 head.look_at(1.0, 0.0, 1.0)
00069 head.wait_for()
00070 
00071 #arms
00072 arm.move_to([-80, 40, 30, -110, 200, -30, -900], RIGHT)
00073 arm.move_to([80, 40, -30, -110, -200, 30, 900], LEFT)
00074 arm.wait_for(BOTH)
00075 
00076 gripper.rel(BOTH)
00077 gripper.wait_for(BOTH)
00078 
00079 rospy.sleep(2)
00080 
00081 arm.move_to([-20, -15, -20, -50, 60, -5, 700], RIGHT)
00082 arm.move_to([20, -15, 20, -50, -60, 5, -700], LEFT)
00083 
00084 sound.say("Double high fives.")
00085 
00086 gripper.wait_for_slap(BOTH)
00087 
00088 head.look_at(1.0, 0.0, 1.5)
00089 head.wait_for()
00090 head.look_at(1.0, 0.0, 1.0)
00091 head.wait_for()
00092 
00093 sound.say("Slap one hand.")
00094 
00095 if (gripper.determine_slap() == LEFT):
00096     head.look_at(1.0, 1.0, 0.5)
00097     head.wait_for()
00098 else:
00099     head.look_at(1.0, -1.0, 0.0)
00100     head.wait_for()
00101 #arms
00102 arm.move_to([70, 50, 40, -120, 100, -20, 20], LEFT)
00103 arm.move_to([-70, 50, -40, -120, -100, -20, -20], RIGHT)
00104 arm.wait_for(BOTH)
00105 
00106 gripper.close(BOTH)
00107 gripper.wait_for(BOTH)
00108 
00109 # Make the robot look for a face.
00110 # First, turn the robot's head to look forward (the robot can't see a face if it's staring at the ceiling!)
00111 # Second, tell people that the robot is waiting to see a face.
00112 # Third, wait to see a face. When the robot sees a face, it'll turn its head to look at the face.
00113 head.look_at(1.0, 0.0, 1.0)
00114 head.wait_for()
00115 sound.say("I'm looking for a face.")
00116 rospy.sleep(2)
00117 head.look_at_face()
00118 head.wait_for()
00119 
00120 # Tell everyone that you're program is done.
00121 sound.say("Goodbye.")


pr2_simple_interface
Author(s): Austin Hendrix
autogenerated on Wed Aug 26 2015 15:37:23