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
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
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
00054
00055
00056
00057
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
00094
00095
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
00130 print 'down'
00131 head_down_up.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.1)), rospy.get_param("~event", ""))
00132
00133
00134 if head_i % 4 == 2:
00135
00136 print 'up'
00137
00138
00139
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
00150
00151
00152
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
00159
00160
00161
00162 if i == 26:
00163
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
00168
00169
00170
00171
00172 if i == 42:
00173
00174
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
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
00236
00237
00238
00239
00240