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 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 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 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 putcube(): shared_all.drive_raising_crane(duration_ms=1000, robot_distance_mm=30, robot_turn_angle=0, motor=crane_motor, crane_angle=-80) shared_all.move_straight(distance_mm=60, speed_mm_s=-90)
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 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 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 treadmill_to_row_withalign(adjust_for_mission=0): shared_all.move_to_color_reverse( 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) shared_all.move_straight(distance_mm=120, speed_mm_s=100) shared_all.turn(angle=90, speed_deg_s=140) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=100, speed_mm_s=-160, target_angle=-90) shared_all.push_back_reset_gyro(distance_mm=40, reset_gyro=True, new_gyro_angle=-90) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=270, speed_mm_s=180, target_angle=-90) shared_all.turn(angle=90, speed_deg_s=120) shared_all.move_reverse(max_distance=40, 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 run_arp(): shared_all.move_crane_to_top(crane_motor) shared_all.move_crane_to_floor(crane_motor) shared_all.turn(-10) shared_all.move_straight( distance_mm=300, speed_mm_s=-190, )
def treadmill_to_row_simple(adjust_for_mission=0): shared_all.move_to_color_reverse( color_sensor=color_sensor_center, stop_on_color=Color.WHITE, alternative_color=Color.BLACK, max_intensity=robot_setup.BLACK_MAX_INTENSITY[color_sensor_center], max_distance_mm=50) shared_all.move_straight(distance_mm=40, speed_mm_s=70)
def turn_points_90(): shared_all.move_straight(distance_mm=90, speed_mm_s=140) shared_all.turn(110, 190) wait(2000) shared_all.turn(-110, 190) wait(2000) shared_all.turn(90) wait(3000) shared_all.turn(-90)
def align(): shared_all.move_reverse( max_distance=30 , speed_mm_s= 100) shared_all.turn(angle=-45, speed_deg_s=100) shared_all.move_straight(distance_mm=60, speed_mm_s=100) # Calibrate the gyro point in the direction at the start # shared_all.calibrate_gyro(0) # align()
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 align(): # shared_all.move_straight(distance_mm=50, speed_mm_s=200) # shared_all.turn(angle=90, speed_deg_s=200) # shared_all.move_reverse(max_distance=65, speed_mm_s=75) # shared_all.move_straight(distance_mm=450, speed_mm_s=175) # shared_all.turn(angle=15, speed_deg_s=200) # shared_all.turn_arc(distance=15,angle=15,speed_mm_s=50) # shared_all.move_straight(distance_mm=138, speed_mm_s=200) shared_all.start_moving_crane_to_angle(crane_motor, 45) shared_all.move_rack_to_top() shared_all.move_straight(distance_mm=110, speed_mm_s=120) shared_all.turn(35)
def level2crane(): shared_all.move_rack_to_floor() shared_all.log_string('Moved racktotop') shared_all.move_crane_up(motor=rack_motor, degrees=40) shared_all.turn(angle=20) shared_all.drive_raising_crane(duration_ms=500, robot_distance_mm=20, robot_turn_angle=0, motor=rack_motor, crane_angle=190) shared_all.move_straight(distance_mm=40, speed_mm_s=-90) shared_all.move_crane_down(motor=rack_motor, degrees=90) shared_all.log_string('MOtor is ' + str(crane_motor))
def runold (): shared_all.move_rack_to_floor () shared_all.move_straight(distance_mm=60, speed_mm_s=120) while shared_all.did_motor_stall(motor =rack_motor , max_degrees =50 , speed = 320): # log_string('stalled - step back') shared_all.move_reverse(max_distance=6, speed_mm_s=20) shared_all.move_crane_to_angle(motor=rack_motor, target_angle=90) shared_all.drive_raising_crane (duration_ms=900, robot_distance_mm=80, robot_turn_angle=0, motor=rack_motor, crane_angle=-20) shared_all.move_crane_to_angle(motor=rack_motor, target_angle=120) shared_all.move_reverse(max_distance=20, speed_mm_s=100)
def run(): shared_all.move_rack_to_floor() # shared_all.move_crane_up( motor = rack_motor, degrees = 30) shared_all.move_straight(distance_mm=55, speed_mm_s=100) while shared_all.did_motor_stall(motor =rack_motor , max_degrees =30 , speed = 80): shared_all.log_string('Stalled') shared_all.move_straight(distance_mm=4, speed_mm_s=-20) shared_all.drive_raising_crane(duration_ms=400, robot_distance_mm=30, robot_turn_angle=0, motor=rack_motor, crane_angle=75) shared_all.turn_arc(distance = 60 ,angle = -7 , speed_mm_s=100)
def level1(): shared_all.move_crane_to_top(motor=crane_motor) shared_all.move_rack_to_floor() shared_all.turn(angle=-10, speed_deg_s=90) shared_all.move_straight(distance_mm=90, speed_mm_s=90) shared_all.turn(angle=20, speed_deg_s=90) # rack_motor.stop(Stop.BRAKE) # cntr=0 # while cntr < 4 and shared_all.did_motor_stall(motor =rack_motor , max_degrees =80 , speed = 320): # shared_all.log_string('Mtr stalled') # shared_all.move_crane_down(rack_motor, 5) # shared_all.log_string('mved crane down') # shared_all.move_rack_to_floor() # shared_all.move_straight(distance_mm=6, speed_mm_s=20) # cntr +=1 # shared_all.move_rack_to_floor() # shared_all.move_crane_down(rack_motor, 5) # rack_motor.run_time(720, 900) shared_all.drive_raising_crane(duration_ms=1300, robot_distance_mm=-40, robot_turn_angle=0, motor=rack_motor, crane_angle=80) shared_all.drive_raising_crane(duration_ms=1300, robot_distance_mm=0, robot_turn_angle=0, motor=rack_motor, crane_angle=50) shared_all.drive_raising_crane(duration_ms=900, robot_distance_mm=20, robot_turn_angle=0, motor=rack_motor, crane_angle=15) # back up while lowering slightly shared_all.drive_raising_crane(duration_ms=800, robot_distance_mm=-70, robot_turn_angle=0, motor=rack_motor, crane_angle=-20) shared_all.move_rack_to_floor() shared_all.move_straight(distance_mm=60, speed_mm_s=-90) shared_all.move_rack_to_top()
def stepcounter_to_treadmill_reverse(adjust_for_mission=0): shared_all.move_straight(distance_mm=160, speed_mm_s=150) shared_all.turn(angle=-10) shared_all.turn_arc(distance=330, angle=-50, speed_mm_s=-150) shared_all.move_straight_target_direction(gyro=gyro, distance_mm=400, speed_mm_s=-170, target_angle=180) 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=180)
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 runpushdown(): shared_all.move_rack_to_top() shared_all.move_straight(distance_mm=110, speed_mm_s=120) shared_all.turn(35) shared_all.move_crane_down(rack_motor, 210) shared_all.turn(-35) shared_all.move_straight(distance_mm=50, speed_mm_s=-120) shared_all.start_moving_crane_to_top(rack_motor) 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=70) shared_all.move_rack_to_top()
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 all_cranes(): shared_all.log_string('crane ang start ' + str(crane_motor.angle())) shared_all.move_crane_to_floor(crane_motor) shared_all.log_string('crane ang flr ' + str(crane_motor.angle())) shared_all.start_moving_crane_to_top(motor=crane_motor) shared_all.move_straight(distance_mm=70, speed_mm_s=-50) shared_all.log_string('crane ang top ' + str(crane_motor.angle())) shared_all.start_moving_crane_to_angle(motor=crane_motor, target_angle=50) shared_all.move_straight(distance_mm=70, speed_mm_s=150) shared_all.log_string('crane ang at 50 ' + str(crane_motor.angle())) shared_all.log_string('arm ang strt ' + str(rack_motor.angle())) shared_all.move_rack_to_top() shared_all.log_string('arm ang top ' + str(rack_motor.angle())) shared_all.move_rack_to_floor() shared_all.log_string('arm ang flr ' + str(rack_motor.angle())) shared_all.move_crane_up(rack_motor, 90) shared_all.log_string('arm ang flr+90 ' + str(rack_motor.angle())) shared_all.move_crane_down(rack_motor, 90) shared_all.log_string('arm ang -90 ' + str(rack_motor.angle())) shared_all.move_rack_to_top() shared_all.log_string('arm ang top ' + str(rack_motor.angle())) shared_all.log_string('crane motor ' + str(crane_motor)) shared_all.log_string('rack motor ' + str(rack_motor)) shared_all.log_string('left motor ' + str(left_motor)) shared_all.log_string('right motor ' + str(right_motor)) shared_all.move_crane_to_floor(crane_motor) crane_motor.reset_angle(0) shared_all.log_string('crane ang flr ' + str(crane_motor.angle())) shared_all.move_crane_to_top(motor=crane_motor) shared_all.log_string('crane ang top ' + str(crane_motor.angle())) shared_all.move_rack_to_floor() rack_motor.reset_angle(0) shared_all.log_string('rack ang flr ' + str(rack_motor.angle())) shared_all.move_rack_to_top() shared_all.log_string('rack ang top ' + str(rack_motor.angle())) shared_all.log_string('rack top ' + str(rack_motor.angle()) + 'crane top ' + str(crane_motor.angle()))
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 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 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 runfacing(): shared_all.move_crane_down(rack_motor, 70) shared_all.move_hook_to_floor() shared_all.move_straight(distance_mm=20, speed_mm_s=-50) shared_all.drive_raising_crane (duration_ms=800, robot_distance_mm=-30, robot_turn_angle=0, motor=rack_motor, crane_angle=20) shared_all.drive_raising_crane (duration_ms=1900, robot_distance_mm=-90, robot_turn_angle=0, motor=rack_motor, crane_angle=20) # shared_all.move_straight(distance_mm=40, speed_mm_s=130) shared_all.move_crane_up(rack_motor, 70) shared_all.move_straight(distance_mm=500, speed_mm_s=-200) shared_all.move_rack_to_top() # shared_all.calibrate_gyro(new_gyro_angle=-45) # alignfacing() # runfacing()
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)