def alt_bow_arrow(): PyPR2.openGripper(2) PyPR2.moveHeadTo(0.0,0.15) PyPR2.moveArmWithJointPos(**left_shooting) PyPR2.openGripper(2) time.sleep(2) PyPR2.moveHeadTo(0.0,0.0) PyPR2.moveArmWithJointPos(**alt_right_intermediate) PyPR2.moveHeadTo(0.0,0.3) time.sleep(3) PyPR2.moveArmWithJointPos(**alt_right_shooting) time.sleep(3) PyPR2.closeGripper(2) time.sleep(2) PyPR2.moveHeadTo(0.0,0.18) PyPR2.moveArmWithJointPos(**best_pullback_right) time.sleep(5) PyPR2.moveHeadTo(0.0,0.1) PyPR2.openGripper(2) #PyPR2.moveHeadTo(0.0,0.0) PyPR2.moveArmWithJointPos(**alt_right_release) PyPR2.moveHeadTo(0.0,0.1)
def refill(): PyPR2.moveArmWithJointPos(**left_intermediate) PyPR2.moveHeadTo(0.1,0.3) time.sleep(3) PyPR2.moveArmWithJointPos(**right_refill) PyPR2.moveHeadTo(-0.7,0.3) time.sleep(3) PyPR2.moveHeadTo(-0.2,0.3) PyPR2.moveArmWithJointPos(**left_refill) time.sleep(4) PyPR2.moveArmWithJointPos(**right_pick) PyPR2.moveHeadTo(-0.2,0.19) time.sleep(2) PyPR2.closeGripper(2) time.sleep(3) PyPR2.moveArmWithJointPos(**right_pick_further) time.sleep(2) PyPR2.moveArmWithJointPos(**left_pick_further) time.sleep(4) PyPR2.moveArmWithJointPos(**r2) PyPR2.moveArmWithJointPos(**l2)
def refill(): PyPR2.moveArmWithJointPos(**left_intermediate) PyPR2.moveHeadTo(0.1, 0.3) time.sleep(3) PyPR2.moveArmWithJointPos(**right_refill) PyPR2.moveHeadTo(-0.7, 0.3) time.sleep(3) PyPR2.moveHeadTo(-0.2, 0.3) PyPR2.moveArmWithJointPos(**left_refill) time.sleep(4) PyPR2.moveArmWithJointPos(**right_pick) PyPR2.moveHeadTo(-0.2, 0.19) time.sleep(2) PyPR2.closeGripper(2) time.sleep(3) PyPR2.moveArmWithJointPos(**right_pick_further) time.sleep(2) PyPR2.moveArmWithJointPos(**left_pick_further) time.sleep(4) PyPR2.moveArmWithJointPos(**r2) PyPR2.moveArmWithJointPos(**l2)
def alt_bow_arrow(): PyPR2.openGripper(2) PyPR2.moveHeadTo(0.0, 0.15) PyPR2.moveArmWithJointPos(**left_shooting) PyPR2.openGripper(2) time.sleep(2) PyPR2.moveHeadTo(0.0, 0.0) PyPR2.moveArmWithJointPos(**alt_right_intermediate) PyPR2.moveHeadTo(0.0, 0.3) time.sleep(3) PyPR2.moveArmWithJointPos(**alt_right_shooting) time.sleep(3) PyPR2.closeGripper(2) time.sleep(2) PyPR2.moveHeadTo(0.0, 0.18) PyPR2.moveArmWithJointPos(**best_pullback_right) time.sleep(5) PyPR2.moveHeadTo(0.0, 0.1) PyPR2.openGripper(2) #PyPR2.moveHeadTo(0.0,0.0) PyPR2.moveArmWithJointPos(**alt_right_release) PyPR2.moveHeadTo(0.0, 0.1)
def close(): time.sleep(10) PyPR2.openGripper(3) time.sleep(10) PyPR2.closeGripper(3)
def timerActions( id ): global msgTryTimer,busy_moving,track_d,last_action_counter,d,start_time,x,y,elapsed_time,focus_obj,a if msgTryTimer == id : #PyPR2.removeTimer( msgTryTimer ) #msgTryTimer += 1 #while True: #time.sleep(1) if abs(a-focus_obj['est_pos'][0]) < 0.04: a = focus_obj['est_pos'][0] PyPR2.moveBodyTo(0.1,0.0,0.0,1) else: a = focus_obj['est_pos'][0] d = math.sqrt(math.pow(x,2)+math.pow(y,2)) adjust_to_shooting() ''' with open(csvfile, "w") as output: writer = csv.writer(output, lineterminator='\n') writer.writerows(track_d) ''' #PyPR2.moveTorsoBy(0.03,5) #if abs(previous_pos - focus_obj['est_pos'][0])< 0.1: # PyPR2.moveHeadTo(0.2,1.0) #adjust_to_shooting() #if busymoving>0: busymoving-=1 if d>=3.5: if last_action_counter <4 and last_action_counter!=0: #obj.larm_reference = True #obj.arm_down() PyPR2.moveArmWithJointPos(**right_high_five) PyPR.moveArmWithJointPos(**shooting_back_down) last_action_counter=4 #busymoving=3 elif last_action_counter == 4: PyPR2.moveTorsoBy(0.1,2) PyPR2.say("Move Back") #busymoving=5 else: PyPR2.moveArmWithJointPos(**left_shooting) last_action_counter=4 #busymoving=5 elif d<=3.5 and d>3: if last_action_counter <3 and last_action_counter!=0: PyPR2.moveArmWithJointPos(**shooting_down) #obj.larm_reference = False #obj.arm_right() #PyPR2.moveBodyTo(0.01,0.0,0.0,1) last_action_counter=3 elif last_action_counter ==3: PyPR2.moveBodyTo(0.07,0.0,0.0,0.51) #busymoving=10 elif last_action_counter ==0: PyPR2.moveArmWithJointPos(**left_shooting) PyPR2.moveArWithJointPos(**alt_right_shooting) #busymoving=10 PyPR2.say("Move Back") else: PyPR2.moveArmWithJointPos(**alt_right_shooting) PyPR2.moveArmWithJointPos(**left_shooting) last_action_counter=3 elif d<=3 and d >2: if last_action_counter <2 and last_action_counter!=0: #obj.larm_reference = False #obj.arm_right() PyPR2.moveArmWithJointPos(**left_relax1) last_action_counter=2 #elif last_action_counter==0: else: PyPR2.moveArmWithJointPos(**alt_right_shooting) PyPR2.moveArmWithJointPos(**left_shooting) PyPR2.closeGripper(2) #PyPR2.closeGripper(2) last_action_counter =2 #previous_pos = focus_obj['est_pos'][0] #movement_tracker.append(str(CONDITION_TAG)+":"+str(focus_obj['est_pos'])) elif d <2 and d>1 : if last_action_counter ==1: PyPR2.say("Move") last_action_counter=1 #busymoving=10 elif last_action_counter >=2: PyPR2.moveArmWithJointPos(**left_shooting) PyPR2.moveArmWithJointPos(**alt_right_shooting) else : PyPR2.moveArmWithJointPos(**alt_right_shooting) PyPr2.moveArmWithJointPos(**left_shooting)
def timerActions(id): global msgTryTimer, busy_moving, track_d, last_action_counter, d, start_time, x, y, elapsed_time, focus_obj, a if msgTryTimer == id: #PyPR2.removeTimer( msgTryTimer ) #msgTryTimer += 1 #while True: #time.sleep(1) if abs(a - focus_obj['est_pos'][0]) < 0.04: a = focus_obj['est_pos'][0] PyPR2.moveBodyTo(0.1, 0.0, 0.0, 1) else: a = focus_obj['est_pos'][0] d = math.sqrt(math.pow(x, 2) + math.pow(y, 2)) adjust_to_shooting() ''' with open(csvfile, "w") as output: writer = csv.writer(output, lineterminator='\n') writer.writerows(track_d) ''' #PyPR2.moveTorsoBy(0.03,5) #if abs(previous_pos - focus_obj['est_pos'][0])< 0.1: # PyPR2.moveHeadTo(0.2,1.0) #adjust_to_shooting() #if busymoving>0: busymoving-=1 if d >= 3.5: if last_action_counter < 4 and last_action_counter != 0: #obj.larm_reference = True #obj.arm_down() PyPR2.moveArmWithJointPos(**right_high_five) PyPR.moveArmWithJointPos(**shooting_back_down) last_action_counter = 4 #busymoving=3 elif last_action_counter == 4: PyPR2.moveTorsoBy(0.1, 2) PyPR2.say("Move Back") #busymoving=5 else: PyPR2.moveArmWithJointPos(**left_shooting) last_action_counter = 4 #busymoving=5 elif d <= 3.5 and d > 3: if last_action_counter < 3 and last_action_counter != 0: PyPR2.moveArmWithJointPos(**shooting_down) #obj.larm_reference = False #obj.arm_right() #PyPR2.moveBodyTo(0.01,0.0,0.0,1) last_action_counter = 3 elif last_action_counter == 3: PyPR2.moveBodyTo(0.07, 0.0, 0.0, 0.51) #busymoving=10 elif last_action_counter == 0: PyPR2.moveArmWithJointPos(**left_shooting) PyPR2.moveArWithJointPos(**alt_right_shooting) #busymoving=10 PyPR2.say("Move Back") else: PyPR2.moveArmWithJointPos(**alt_right_shooting) PyPR2.moveArmWithJointPos(**left_shooting) last_action_counter = 3 elif d <= 3 and d > 2: if last_action_counter < 2 and last_action_counter != 0: #obj.larm_reference = False #obj.arm_right() PyPR2.moveArmWithJointPos(**left_relax1) last_action_counter = 2 #elif last_action_counter==0: else: PyPR2.moveArmWithJointPos(**alt_right_shooting) PyPR2.moveArmWithJointPos(**left_shooting) PyPR2.closeGripper(2) #PyPR2.closeGripper(2) last_action_counter = 2 #previous_pos = focus_obj['est_pos'][0] #movement_tracker.append(str(CONDITION_TAG)+":"+str(focus_obj['est_pos'])) elif d < 2 and d > 1: if last_action_counter == 1: PyPR2.say("Move") last_action_counter = 1 #busymoving=10 elif last_action_counter >= 2: PyPR2.moveArmWithJointPos(**left_shooting) PyPR2.moveArmWithJointPos(**alt_right_shooting) else: PyPR2.moveArmWithJointPos(**alt_right_shooting) PyPr2.moveArmWithJointPos(**left_shooting)