def evasion() : # Swing Turn 's angle right_turn_speed = 50 right_turn_time = 0.4 # Point Turn 's angle left_turn_speed = 30 left_turn_time = 0.4 # The speed that the executor wants speed = 43 go_time = 1.5 try: go_turn_stop.right_SwingTurn(right_turn_speed, right_turn_time) time.sleep(1) go_turn_stop.go_forward(speed,go_time) go_turn_stop.right_PointTurn(left_turn_speed, left_turn_time) time.sleep(1) WB = recog_line.get_01() while recog_line.numberOfCases(WB) != 'inLine' : go_turn_stop.just_go_forward(speed) else : time.sleep(1) break except : pass
import recog_line import setup dis = 17 #20 speed = 20 time = 0.5 try: while True: # ultra sensor replies the distance back distance = recog_obs.get_Distance() print('distance= ', distance) # when the distance is above the dis, moving object forwards while (distance > dis): W_and_B = recog_line.get_01() if recog_line.numberOfCases(W_and_B) == 'inLine' : go_turn_stop.go_forward(speed, time) elif recog_line.numberOfCases(W_and_B) == 'leftSide' : go_turn_stop.right_PointTurn(speed, time) else : go_turn_stop.left_PointTurn(speed, time) else : evasion_obs.evasion() except KeyboardInterrupt: go_turn_stop.pwm_low()