def runtrial(): shared_all.move_straight(distance_mm=70, speed_mm_s=50) shared_all.move_straight(distance_mm=70, speed_mm_s=-90) shared_all.turn_to_angle(gyro=gyro, target_angle=45) # turn to face south shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.RED, speed_mm_s=100) shared_all.turn_to_angle(gyro=gyro, target_angle=-45) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=800, speed_mm_s=300, target_angle=-45) shared_all.turn_arc(distance=50, angle=-60, speed_mm_s=100) # turn in an arc shared_all.turn_to_angle(gyro=gyro, target_angle=150) # turn to face south shared_all.move_crane_to_floor(crane_motor) shared_all.drive_raising_crane(duration_ms=1000, robot_distance_mm=400, robot_turn_angle=0, motor=crane_motor, crane_angle=60) shared_all.move_crane_to_top(crane_motor) shared_all.move_to_obstacle(obstacle_sensor=ultrasound, stop_on_obstacle_at=80, speed_mm_s=-100)
def align(adjust_for_mission=0): SLIDE_ALIGN_DIRECTION=138 shared_all.turn(-90, speed_deg_s=140) shared_all.move_straight(distance_mm=50, speed_mm_s=100) shared_all.move_to_color_reverse(color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK, speed_mm_s=60, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=80) shared_all.move_straight(distance_mm=70, speed_mm_s=-100) shared_all.turn(90, speed_deg_s=140) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK, speed_mm_s=60, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=60) shared_all.move_straight_target_direction(gyro = gyro, distance_mm= 40, speed_mm_s= 130, target_angle= 180+ adjust_for_mission) shared_all.turn(SLIDE_ALIGN_DIRECTION - 180, speed_deg_s=100) shared_all.move_straight_target_direction(gyro = gyro, distance_mm= 60, speed_mm_s= -110, target_angle= SLIDE_ALIGN_DIRECTION+ adjust_for_mission) shared_all.move_rack_to_floor()
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 runold(adjust_for_mission=0): shared_all.start_moving_crane_to_angle(motor=crane_motor, target_angle=25) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.GREEN, alternative_color=Color.GREEN, max_distance_mm=60) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.RED, alternative_color=Color.YELLOW, max_distance_mm=170) shared_all.turn_arc(distance=30, angle=15, speed_mm_s=60) #lift weight and back up crane_motor.stop() shared_all.move_crane_down(motor=crane_motor, degrees=10) crane_motor.run_time(600, 900) # shared_all.move_crane_to_floor(crane_motor) # shared_all.move_crane_up( motor = crane_motor, degrees = 40) shared_all.start_moving_crane_to_angle(motor=crane_motor, target_angle=25) shared_all.move_straight(distance_mm=70, speed_mm_s=-120) # turn west and back up shared_all.turn(-140, speed_deg_s=200) shared_all.start_moving_crane_to_top(motor=crane_motor) shared_all.move_straight(distance_mm=70, speed_mm_s=-150) shared_all.turn_arc(distance=50, angle=60, speed_mm_s=190)
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 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 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 align(): shared_all.move_crane_to_floor( motor=crane_motor) shared_all.move_crane_up( motor=crane_motor, degrees=60) shared_all.move_to_color(color_sensor = color_sensor_right, stop_on_color = Color.GREEN, alternative_color = Color.GREEN, speed_mm_s=40, max_distance_mm=60) shared_all.move_straight(distance_mm=17, speed_mm_s=40)
def innov_to_basket(adjust_for_mission=0): # shared_all.move_straight(distance_mm=10, speed_mm_s=-90) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=180, speed_mm_s=130, target_angle=-55 + adjust_for_mission) 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=80) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=50, speed_mm_s=130, target_angle=-55 + adjust_for_mission) 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=80)
def aligncubes(): shared_all.move_straight(distance_mm=290, speed_mm_s=150) shared_all.move_to_color(color_sensor=color_sensor_right, stop_on_color=Color.GREEN, max_distance_mm=600) shared_all.move_straight(distance_mm=10, speed_mm_s=-100)
def alignfacing(): shared_all.move_straight_target_direction(gyro=gyro, distance_mm=480, speed_mm_s=170, target_angle=-45) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.GREEN, max_distance_mm=40) shared_all.move_straight(distance_mm=40, speed_mm_s=40)
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 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 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 base_to_innov(): shared_all.move_straight_target_direction(gyro=gyro, distance_mm=210, speed_mm_s=190, target_angle=-90) shared_all.move_to_color(color_sensor=color_sensor_center, stop_on_color=Color.GREEN, alternative_color=Color.GREEN, max_distance_mm=30) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=10, speed_mm_s=110, target_angle=-90)
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 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 row_to_weight_pushdown(adjust_for_mission=0): shared_all.turn(angle=-40) shared_all.turn_arc(distance=50, angle=-60, speed_mm_s=80) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=70, speed_mm_s=160, target_angle=-90 + adjust_for_mission) 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=120)
def align(): shared_all.calibrate_gyro(-85) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=200, speed_mm_s=190, target_angle=-85) # shared_all.move_crane_to_floor( motor=crane_motor) # shared_all.move_crane_up( motor=crane_motor, degrees=60) shared_all.move_to_color(color_sensor=color_sensor_right, stop_on_color=Color.GREEN, alternative_color=Color.GREEN, speed_mm_s=40, max_distance_mm=60) shared_all.move_straight(distance_mm=50, speed_mm_s=40)
def phone_to_slide(adjust_for_mission=0): shared_all.turn_arc(distance=60, angle=-10, speed_mm_s=-90) shared_all.move_straight(distance_mm=40, speed_mm_s=-100) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=250, speed_mm_s=200, target_angle=180 + adjust_for_mission) shared_all.move_to_color( color_sensor=color_sensor_center, stop_on_color=Color.BLACK, alternative_color=Color.BLACK, speed_mm_s=25, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=140)
def tread_to_weight(): # shared_all.move_straight_target_direction(gyro=gyro, distance_mm=600, speed_mm_s=180, # target_angle= -90) shared_all.move_rack_to_top() # shared_all.move_crane_to_floor(motor=crane_motor, release_angle=25) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=460, speed_mm_s=210, target_angle=-90) shared_all.move_to_color( color_sensor=color_sensor_center, stop_on_color=Color.WHITE, alternative_color=Color.BLACK, speed_mm_s=30, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=50)
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 treadmill_to_weight(adjust_for_mission=0): shared_all.move_straight(distance_mm=100, speed_mm_s=160) shared_all.turn(angle=90, speed_deg_s=170) shared_all.move_reverse(max_distance=100, speed_mm_s=140) shared_all.push_back_reset_gyro(distance_mm=50, reset_gyro=True, new_gyro_angle=-90) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=460, speed_mm_s=150, target_angle=-90) shared_all.move_to_color( color_sensor=color_sensor_center, stop_on_color=Color.WHITE, alternative_color=Color.BLACK, speed_mm_s=30, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=50)
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 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)