def align_nearboccia(adjust_for_mission=0): shared_all.move_straight_target_direction(gyro=gyro, distance_mm=40, speed_mm_s=120, target_angle=-90 + adjust_for_mission) shared_all.move_to_color( color_sensor=color_sensor_right, stop_on_color=Color.WHITE, alternative_color=Color.BLACK, speed_mm_s=30, min_intensity=robot_setup.WHITE_MIN_INTENSITY[color_sensor_right]) shared_all.move_straight(distance_mm=7, speed_mm_s=-90) shared_all.turn_to_direction(gyro=gyro, target_angle=-137 + adjust_for_mission, speed_deg_s=80) if not shared_all.move_to_color_reverse(color_sensor=color_sensor_right, stop_on_color=Color.GREEN, alternative_color=Color.GREEN, speed_mm_s=30, max_distance_mm=50): shared_all.move_to_color(color_sensor=color_sensor_right, stop_on_color=Color.GREEN, alternative_color=Color.GREEN, speed_mm_s=30, max_distance_mm=55) shared_all.move_straight(distance_mm=10, speed_mm_s=-100)
def alignatangle(adjust_for_mission=0): shared_all.move_straight_target_direction(gyro = gyro, distance_mm= 170, speed_mm_s= 130, target_angle= -130+ adjust_for_mission) shared_all.turn(angle=110, speed_deg_s=190) shared_all.turn_to_direction( gyro=gyro, target_angle=10+ adjust_for_mission)
def alignold(adjust_for_mission=0): shared_all.move_straight_target_direction(gyro=gyro, distance_mm=90, speed_mm_s=100, target_angle=-90 + adjust_for_mission) # shared_all.turn(-90) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=85, speed_mm_s=-120, target_angle=180 + adjust_for_mission) shared_all.move_to_color_reverse(color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=75, speed_mm_s=110, target_angle=180 + adjust_for_mission) shared_all.turn_to_direction(gyro=gyro, target_angle=-135 + adjust_for_mission, speed_mm_s=80)
def alignheadon(adjust_for_mission=0): shared_all.turn(180, 210) shared_all.turn_to_direction(gyro=gyro, target_angle=180 + adjust_for_mission) shared_all.move_to_color_reverse(color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK)
def align_right_turns(adjust_for_mission=0): shared_all.move_to_color( color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=70) shared_all.move_straight(distance_mm=100, speed_mm_s=140) shared_all.move_crane_to_top(crane_motor) shared_all.turn_to_direction(gyro=gyro, target_angle=180 + adjust_for_mission) shared_all.move_straight(distance_mm=390, speed_mm_s=-200) shared_all.push_back_reset_gyro(distance_mm=60, reset_gyro=True, new_gyro_angle=180) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=15, speed_mm_s=110, target_angle=180 + adjust_for_mission) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=30, speed_mm_s=-110, target_angle=-90 + adjust_for_mission)
def base_to_basket(adjust_for_mission=0): shared_all.turn_arc(distance=620, angle=-90, speed_mm_s=230) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK) shared_all.turn_to_direction(gyro=gyro, target_angle=-90, speed_mm_s=120)
def run(): shared_all.move_straight_target_direction(gyro = gyro, distance_mm=190, speed_mm_s=-18, target_angle=DIRECTION) # shared_all.move_straight(distance_mm=90, speed_mm_s=-140) shared_all.turn_to_direction( gyro = gyro, target_angle = DIRECTION)
def align(adjust_for_mission=0): shared_all.turn_to_direction(gyro=gyro, target_angle=-133 + adjust_for_mission, speed_deg_s=80) shared_all.move_to_color(color_sensor=color_sensor_right, stop_on_color=Color.GREEN, alternative_color=Color.GREEN, speed_mm_s=30, max_distance_mm=30)
def push_small_tire(adjust_for_mission=0): shared_all.move_rack_to_floor() shared_all.drive_raising_crane(duration_ms=1900, robot_distance_mm=30, robot_turn_angle=-35, motor=rack_motor, crane_angle=-5) shared_all.move_crane_to_top(rack_motor) shared_all.turn_to_direction(gyro=gyro, target_angle=-70) shared_all.turn_arc(distance=90, angle=-20, speed_mm_s=140)
def alignreverse(adjust_for_mission=0): shared_all.turn(angle=-30) shared_all.move_to_color( color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=180) shared_all.turn_to_direction(gyro=gyro, target_angle=180 + adjust_for_mission)
def align(adjust_for_mission=0): shared_all.turn_to_direction( gyro=gyro, target_angle=180+ adjust_for_mission) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.WHITE, alternative_color=Color.WHITE, speed_mm_s=25, min_intensity=robot_setup.WHITE_MIN_INTENSITY[color_sensor_center]) shared_all.move_straight(distance_mm= 60, speed_mm_s= -70) shared_all.move_crane_to_floor(crane_motor) shared_all.turn_arc(distance=160, angle=80, speed_mm_s =50)
def runold(adjust_for_mission=0): shared_all.turn_to_direction( gyro=gyro, target_angle=-37+ adjust_for_mission) shared_all.move_rack_to_floor() shake() shared_all.drive_raising_crane(duration_ms=1900, robot_distance_mm=-80, robot_turn_angle=-20, motor=rack_motor, crane_angle=-5) shared_all.drive_raising_crane(duration_ms=1900, robot_distance_mm=25, robot_turn_angle=-50, motor=rack_motor, crane_angle=-5) shared_all.turn(8) shared_all.drive_raising_crane(duration_ms=1900, robot_distance_mm=-10, robot_turn_angle=0, motor=rack_motor, crane_angle=110)
def run(adjust_for_mission=0): shared_all.turn(5) # shared_all.move_straight(distance_mm=190, speed_mm_s=-210) right_motor.run_angle(-90, 50, Stop.BRAKE, True) left_motor.run_angle(-270, 3 * 360, Stop.BRAKE, True) shared_all.move_straight(distance_mm=120, speed_mm_s=180) shared_all.move_straight(distance_mm=20, speed_mm_s=90) shared_all.turn_to_direction(gyro=gyro, target_angle=180 + adjust_for_mission)
def aligntonorth(adjust_for_mission=0): shared_all.turn_arc(distance=150, angle=-45, speed_mm_s=170) shared_all.turn_arc(distance=150, angle=45, speed_mm_s=170) shared_all.move_straight_target_direction(gyro = gyro, distance_mm= 20, speed_mm_s= 110, target_angle= -90+ adjust_for_mission) shared_all.turn_to_direction( gyro=gyro, target_angle=0+ adjust_for_mission) shared_all.move_to_color_reverse(color_sensor=color_sensor_center, stop_on_color=Color.GREEN, alternative_color=Color.GREEN) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.BLUE, alternative_color=Color.BLUE) shared_all.move_straight(distance_mm=10, speed_mm_s=-80)
def basket_to_bench(): shared_all.turn_arc(distance=90, angle=-55, speed_mm_s=-70) shared_all.move_crane_to_top(motor=rack_motor) shared_all.turn_to_direction(gyro=gyro, target_angle=180 + adjust_for_mission) shared_all.move_to_color_reverse(color_sensor=color_sensor_center, stop_on_color=Color.WHITE, alternative_color=Color.WHITE) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=120, speed_mm_s=140, target_angle=180 + adjust_for_mission) shared_all.move_crane_to_top(motor=crane_motor) shared_all.turn(-60)
def go_long(): shared_all.move_straight(max_distance=1600, speed_mm_s=250) shared_all.move_to_color(color_sensor=color_sensor_left, stop_on_color=Color.BLACK, speed_mm_s = 70) shared_all.move_straight(max_distance=60) shared_all.turn_to_direction(gyro, target_angle=-90) shared_all.move_to_color(color_sensor=color_sensor_left, stop_on_color=Color.RED, speed_mm_s = 70) shared_all.turn_to_direction(gyro, target_angle=160) shared_all.move_straight(max_distance=1600, speed_mm_s=250)
def run(): ##lift shared_all.move_crane_down(crane_motor, 10) shared_all.drive_raising_crane(duration_ms=600, robot_distance_mm=0, robot_turn_angle=0, motor=crane_motor, crane_angle=110) shared_all.move_crane_down(crane_motor, 80) #knock shared_all.move_straight(distance_mm=18, speed_mm_s=-90) shared_all.move_crane_to_floor(crane_motor) shared_all.drive_raising_crane(duration_ms=400, robot_distance_mm=10, robot_turn_angle=-30, motor=crane_motor, crane_angle=-20) #backup shared_all.start_moving_crane_to_angle(crane_motor, 70) shared_all.turn_to_direction(gyro=gyro, target_angle=-85) shared_all.move_straight(distance_mm=60, speed_mm_s=-120)
def align_color_and_rightturns(adjust_for_mission=0): shared_all.move_straight(distance_mm=170, speed_mm_s=120) shared_all.move_straight_target_direction(gyro = gyro, distance_mm= 80, speed_mm_s= -140, target_angle= -90+ adjust_for_mission) shared_all.move_to_color_reverse(color_sensor=color_sensor_center, stop_on_color=Color.WHITE, alternative_color=Color.WHITE, min_intensity=robot_setup.WHITE_MIN_INTENSITY[color_sensor_center], max_distance_mm=110) shared_all.move_straight_target_direction(gyro = gyro, distance_mm= 220, speed_mm_s= 140, target_angle= -90+ adjust_for_mission) shared_all.turn_to_direction( gyro=gyro, target_angle=0+ adjust_for_mission)
def alignold(adjust_for_mission=0): shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK) shared_all.move_straight(distance_mm=10, speed_mm_s=70) shared_all.turn(-90) shared_all.move_straight(distance_mm=170, speed_mm_s=-170) shared_all.push_back_reset_gyro(distance_mm=60, reset_gyro=False, new_gyro_angle=0) shared_all.move_straight(distance_mm=160, speed_mm_s=150) shared_all.turn_to_direction(gyro=gyro, target_angle=180 + adjust_for_mission) shared_all.move_to_color_reverse(color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK)
def run(adjust_for_mission=0): # shared_all.move_straight(distance_mm=190, speed_mm_s=-210) # left_motor.run_angle( -210, 3*360, Stop.BRAKE, True) shared_all.turn(5) # shared_all.move_straight(distance_mm=190, speed_mm_s=-210) right_motor.run_angle(-90, 50, Stop.BRAKE, True) left_motor.run_angle(-270, 3 * 360, Stop.BRAKE, True) shared_all.move_straight(distance_mm=230, speed_mm_s=180) # shared_all.move_straight(distance_mm=20, speed_mm_s=90) shared_all.turn_to_direction(gyro=gyro, target_angle=180 + adjust_for_mission) shared_all.turn(90) shared_all.push_back_reset_gyro(distance_mm=150, reset_gyro=True, new_gyro_angle=-90)
def gyro_color_test_angled(): shared_all.log_string('Pre-run gyro speed ' + str(shared_all.gyro.speed()) + ' angle:' + str(shared_all.gyro.angle())) shared_all.move_crane_to_floor(crane_motor) shared_all.move_crane_up(crane_motor, degrees=135) shared_all.move_straight(max_distance=800, speed_mm_s=200) shared_all.log_string('post Run speed ' + str(gyro.speed()) + ' angle:' + str(gyro.angle())) shared_all.turn_to_direction(gyro, target_angle=45) shared_all.log_string('post +45 turn gyro speed ' + str(gyro.speed()) + ' angle:' + str(gyro.angle())) shared_all.move_to_color(color_sensor=color_sensor_left, stop_on_color=Color.BLACK, speed_mm_s = 70) shared_all.turn_to_direction(gyro, target_angle=90) shared_all.log_string('post +90 turn gyro speed ' + str(gyro.speed()) + ' angle:' + str(gyro.angle())) shared_all.move_straight(max_distance=100) shared_all.move_crane_to_floor(crane_motor) shared_all.move_crane_up(crane_motor, degrees=45) shared_all.move_crane_to_floor(crane_motor) shared_all.move_reverse(max_distance=100) shared_all.move_crane_up(crane_motor, degrees=135) shared_all.turn_to_direction(gyro, target_angle=210) shared_all.log_string('post +210 turn gyro speed ' + str(gyro.speed()) + ' angle:' + str(gyro.angle())) shared_all.move_straight(max_distance=1300) shared_all.log_string('post Run speed ' + str(gyro.speed()) + ' angle:' + str(gyro.angle()))
def treadmill_to_row_nearrow(adjust_for_mission=0): shared_all.turn_arc(distance=110, angle=55, speed_mm_s=100) # turn in an arc shared_all.turn(angle=-55, speed_deg_s=120) shared_all.turn_to_direction(gyro=gyro, target_angle=180 + adjust_for_mission) # shared_all.turn_to_direction( gyro=gyro, target_angle=-90+ adjust_for_mission) shared_all.move_straight(180, -180) shared_all.push_back_reset_gyro(distance_mm=60, reset_gyro=True, new_gyro_angle=180) shared_all.move_straight(distance_mm=70, speed_mm_s=100) shared_all.move_to_color( color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=40)
def align(adjust_for_mission=0): # shared_all.move_straight(max_distance=700, speed_mm_s=100) # wait(1000) # shared_all.move_crane_to_top(crane_motor) # wait(10) shared_all.turn(angle=-30) shared_all.move_to_color( color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=90) # shared_all.move_straight(distance_mm=10, speed_mm_s=30) shared_all.turn_to_direction(gyro=gyro, target_angle=180 + adjust_for_mission) shared_all.move_to_color_reverse( color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=180)
def stepcounter_to_treadmill_forward(adjust_for_mission=0): # shared_all.turn( angle=-45) shared_all.turn_arc(distance=200, angle=-65, speed_mm_s=150) # turn in an arc shared_all.turn_arc(distance=200, angle=65, speed_mm_s=150) # turn in an arc shared_all.move_straight_target_direction(gyro=gyro, distance_mm=170, speed_mm_s=150, target_angle=0) # back up and move at an angle to spine black line shared_all.turn(angle=40, speed_deg_s=90) shared_all.move_reverse(max_distance=50, speed_mm_s=110) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK, max_intensity=15) shared_all.move_reverse(max_distance=10, speed_mm_s=80) shared_all.turn(angle=-40, speed_deg_s=90) shared_all.turn_to_direction(gyro=gyro, target_angle=0)
def bigtire_to_slide(adjust_for_mission=0): shared_all.move_straight(distance_mm=40, speed_mm_s=-100) shared_all.turn_arc(distance=30, angle=30, speed_mm_s=-130) shared_all.turn_to_direction(gyro=gyro, target_angle=90 + adjust_for_mission)
def align(adjust_for_mission=0): shared_all.turn_to_direction( gyro=gyro, target_angle=10+ adjust_for_mission)
def alignold(adjust_for_mission=0): shared_all.move_straight(distance_mm=180, speed_mm_s=150) shared_all.turn_to_direction( gyro=gyro, target_angle=0+ adjust_for_mission) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK) shared_all.move_straight(distance_mm=20, speed_mm_s=120)