beat_trigger.py
Go to the documentation of this file.
00001 import roslib
00002 roslib.load_manifest('trigger_msgs')
00003 import sys
00004 import rospy
00005 import dynamic_reconfigure.client
00006 import time
00007 import trigger_msgs.msg
00008 import geometry_msgs.msg as gm
00009 #import threading as tr
00010 
00011 #class ProjectorWakeUp(threading.Thread):
00012 #
00013 #    def __init__(self):
00014 #        threading.Thread.__init__(self)
00015 #        self.projector = dynamic_reconfigure.client.Client('camera_synchronizer_node')
00016 #
00017 #    def run(self):
00018 #        self.projector.update_configuration(projector_on)
00019 #        time.sleep(.2)
00020 #        self.projector.update_configuration(projector_off)
00021 #        time.sleep(.05)
00022 #        self.projector.update_configuration(projector_on)
00023 #        time.sleep(.05)
00024 #        self.projector.update_configuration(projector_off)
00025 #        time.sleep(2)
00026 #        self.projector.update_configuration(projector_on)
00027 
00028 rospy.init_node("trigger", anonymous=True)
00029 head_up = rospy.Publisher("head_up", trigger_msgs.msg.Trigger, latch = True)
00030 head_down = rospy.Publisher("head_down", trigger_msgs.msg.Trigger, latch = True)
00031 head_down_up = rospy.Publisher("head_down_up", trigger_msgs.msg.Trigger, latch = True)
00032 arm_on = rospy.Publisher("light_on", trigger_msgs.msg.Trigger, latch = True)
00033 arm_off = rospy.Publisher("light_off", trigger_msgs.msg.Trigger, latch = True)
00034 
00035 left_initial_pose = rospy.Publisher("left_start", trigger_msgs.msg.Trigger, latch = True)
00036 left_initial_pose0 = rospy.Publisher("left_start2", trigger_msgs.msg.Trigger, latch = True)
00037 right_initial_pose0 = rospy.Publisher("right_initial_pose0", trigger_msgs.msg.Trigger, latch = True)
00038 #right_initial_pose00 = rospy.Publisher("right_initial_pose00", trigger_msgs.msg.Trigger, latch = True)
00039 froo_froo = rospy.Publisher("froo_froo", trigger_msgs.msg.Trigger, latch = True)
00040 head_look_around = rospy.Publisher("head_look_around2", trigger_msgs.msg.Trigger, latch = True)
00041 
00042 both_arms_forward2 = rospy.Publisher("both_arms_forward2", trigger_msgs.msg.Trigger, latch = True)
00043 both_arms_fold2 = rospy.Publisher("both_arms_fold2", trigger_msgs.msg.Trigger, latch = True)
00044 both_arms_fold_end_pose = rospy.Publisher("both_arms_fold_end_pose", trigger_msgs.msg.Trigger, latch = True)
00045 head_turn = rospy.Publisher("head_turn", trigger_msgs.msg.Trigger, latch = True)
00046 
00047 arm_spin = rospy.Publisher("arm_spin", trigger_msgs.msg.Trigger, latch = True)
00048 raise_the_roof = rospy.Publisher("raise_the_roof", trigger_msgs.msg.Trigger, latch = True)
00049 head_up_full = rospy.Publisher("head_up_full", trigger_msgs.msg.Trigger, latch = True)
00050 head_down_full = rospy.Publisher("head_down_full", trigger_msgs.msg.Trigger, latch = True)
00051 move_base = rospy.Publisher('simple_move_base', gm.Pose2D)
00052 
00053 #hand_up = rospy.Publisher("hand_up", trigger_msgs.msg.Trigger, latch = True)
00054 #hand_down = rospy.Publisher("hand_down", trigger_msgs.msg.Trigger, latch = True)
00055 #left_initial_pose00 = rospy.Publisher("left_initial_pose00", trigger_msgs.msg.Trigger, latch = True)
00056 # right_initial_pose00 = rospy.Publisher("right_initial_pose00", trigger_msgs.msg.Trigger, latch = True)
00057 #right_initial_pose = rospy.Publisher("right_initial_pose", trigger_msgs.msg.Trigger, latch = True)
00058 
00059 projector_on = {'camera_reset': False,
00060                 'forearm_l_rate': 30.0,
00061                 'forearm_l_trig_mode': 1,
00062                 'forearm_r_rate': 30.0,
00063                 'forearm_r_trig_mode': 1,
00064                 'narrow_stereo_trig_mode': 2,
00065                 'projector_mode': 3,
00066                 'projector_pulse_length': 0.002,
00067                 'projector_pulse_shift': 0.0,
00068                 'projector_rate': 58.823529411764703,
00069                 'projector_tweak': 0.0,
00070                 'prosilica_projector_inhibit': False,
00071                 'stereo_rate': 29.411764705882351,
00072                 'wide_stereo_trig_mode': 2}
00073 
00074 
00075 projector_off = {'camera_reset': False,
00076                     'forearm_l_rate': 30.0,
00077                     'forearm_l_trig_mode': 1,
00078                     'forearm_r_rate': 30.0,
00079                     'forearm_r_trig_mode': 1,
00080                     'narrow_stereo_trig_mode': 2,
00081                     'projector_mode': 1,
00082                     'projector_pulse_length': 0.002,
00083                     'projector_pulse_shift': 0.0,
00084                     'projector_rate': 58.823529411764703,
00085                     'projector_tweak': 0.0,
00086                     'prosilica_projector_inhibit': False,
00087                     'stereo_rate': 29.411764705882351,
00088                     'wide_stereo_trig_mode': 2}
00089 projector = dynamic_reconfigure.client.Client('camera_synchronizer_node')
00090 
00091 
00092 r = rospy.Rate(120/60.)
00093 #time.sleep(.2)
00094 #r.sleep()
00095 #projector_animation = ProjectorWakeUp()
00096 i = -23
00097 while not rospy.is_shutdown():
00098 
00099     print '------------', i, '-------------'
00100     if i == -23:
00101         print 'left_initial_pose0'
00102         left_initial_pose0.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 1.5)), rospy.get_param("~event", ""))
00103 
00104     if i == -12:
00105         print 'left_initial_pose'
00106         left_initial_pose.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 2.0)), rospy.get_param("~event", ""))
00107 
00108     if i == -6:
00109         print 'arm_on'
00110         arm_on.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.3)), rospy.get_param("~event", ""))
00111 
00112     if i == -5:
00113         print 'head_look_around'
00114         head_look_around.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.2)), rospy.get_param("~event", ""))
00115 
00116     if i >= 9 and i <= 49:
00117         arm_i = (i - 9)
00118         if arm_i % 8 == 0:
00119             print 'lights off'
00120             arm_off.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", .8)), rospy.get_param("~event", ""))
00121 
00122         if arm_i % 8 == 4:
00123             print 'lights on'
00124             arm_on.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", .8)), rospy.get_param("~event", ""))
00125 
00126     if i >= 15 and i <= 34:
00127         head_i = i - 15
00128         if head_i % 4 == 0:
00129             #Down
00130             print 'down'
00131             head_down_up.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.1)), rospy.get_param("~event", ""))
00132             #head_up.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.0)), rospy.get_param("~event", ""))
00133 
00134         if head_i % 4 == 2:
00135             #Up
00136             print 'up'
00137             #head_down.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.8)), rospy.get_param("~event", ""))
00138             #head_up.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.0)), rospy.get_param("~event", ""))
00139             #hand_up.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.0)), rospy.get_param("~event", ""))
00140 
00141     if i >= 40 and i <= 43:
00142         head_i = i - 41
00143         if head_i % 4 == 0:
00144             head_down_up.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.1)), rospy.get_param("~event", ""))
00145             print 'down'
00146 
00147         if head_i % 4 == 2:
00148             print 'up'
00149             #head_up.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.8)), rospy.get_param("~event", ""))
00150 
00151     ################################################################################
00152     ### FREESTYLE
00153     ################################################################################
00154     if i == 23:
00155         print 'right_initial_pose0'
00156         right_initial_pose0.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.3)), rospy.get_param("~event", ""))
00157 
00158     #if i == 24:
00159     #    print 'right_initial_pose0'
00160     #    right_initial_pose00.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 3.5)), rospy.get_param("~event", ""))
00161 
00162     if i == 26:
00163     #if i == 29:
00164         print 'arm_spin'
00165         arm_spin.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 3.0)), rospy.get_param("~event", ""))
00166 
00167     #if i >= 29 and i < 37:
00168     #    if ((i-29) % 9) == 0:
00169     #        print 'Free style!'
00170     #        froo_froo.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 2.0)), rospy.get_param("~event", ""))
00171 
00172     if i == 42:
00173     #if i == 45:
00174         #ANOTHER FREESTYLE
00175         print 'raise_the_roof'
00176         raise_the_roof.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 3.0)), rospy.get_param("~event", ""))
00177 
00178     ###############################################################################
00179     ## Dancy
00180     ###############################################################################
00181     if i == 53:
00182         print 'head_down'
00183         print 'both_arms_forward2'
00184         both_arms_forward2.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 2)), rospy.get_param("~event", ""))
00185 
00186     if i == 56:
00187         p2d = gm.Pose2D()
00188         p2d.x = -.4
00189         p2d.y = .15
00190         move_base.publish(p2d)
00191         head_down_full.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.5)), rospy.get_param("~event", ""))
00192 
00193     if i == 61:
00194         print 'head_up'
00195         print 'both_arms_fold2'
00196         head_up_full.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.4)), rospy.get_param("~event", ""))
00197         both_arms_fold2.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.8)), rospy.get_param("~event", ""))
00198 
00199     if i == 65:
00200         p2d = gm.Pose2D()
00201         p2d.y = 100.
00202         p2d.theta = -390
00203         move_base.publish(p2d)
00204 
00205     if i == 77:
00206         print 'both_arms_fold_end_pose'
00207         print 'head_turn'
00208         head_turn.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 7.0)), rospy.get_param("~event", ""))
00209         both_arms_fold_end_pose.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.8)), rospy.get_param("~event", ""))
00210 
00211     i = i+1
00212     r.sleep()
00213     if i == 80:
00214         break
00215 
00216 projector.update_configuration(projector_off)
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235     #if i == -12:
00236     #    left_initial_pose00.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 5)), rospy.get_param("~event", ""))
00237     #    right_initial_pose00.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 5)), rospy.get_param("~event", ""))
00238 
00239     #if i == 43:
00240     #    right_initial_pose.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 3.)), rospy.get_param("~event", ""))


hai_sandbox
Author(s): Hai Nguyen
autogenerated on Wed Nov 27 2013 11:46:56