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 run(): shared_all.move_crane_down(motor=crane_motor, degrees=20) crane_motor.run_angle(720, 100) ## Below lines only for testing ## Comment out when done testing. Do not upload to Git hub without commenting. # shared_all.calibrate_gyro(0) # align() # run()
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 level1crane(): shared_all.move_crane_to_floor(motor=crane_motor) shared_all.move_crane_up(motor=crane_motor, degrees=35) shared_all.move_straight(distance_mm=60, speed_mm_s=90) shared_all.move_crane_down(motor=crane_motor, degrees=15) shared_all.move_straight(distance_mm=8, speed_mm_s=90) shared_all.drive_raising_crane(duration_ms=700, robot_distance_mm=-10, robot_turn_angle=0, motor=crane_motor, crane_angle=120) shared_all.move_crane_down(motor=crane_motor, degrees=30) shared_all.move_straight(distance_mm=30, speed_mm_s=-90)
def run(): 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=-20, robot_turn_angle=0, motor=rack_motor, crane_angle=20) shared_all.drive_raising_crane (duration_ms=1900, robot_distance_mm=-70, robot_turn_angle=0, motor=rack_motor, crane_angle=30) shared_all.move_straight(distance_mm=40, speed_mm_s=-130) shared_all.move_crane_up(rack_motor, 30) #backup shared_all.move_straight(distance_mm=600, speed_mm_s=-200)
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 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 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 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 do_crane_push(): shared_all.move_crane_to_floor(crane_motor) shared_all.move_crane_up(crane_motor, degrees=135) shared_all.move_straight(max_distance=60) shared_all.turn(angle=-50) # shared_all.move_straight(max_distance=100) shared_all.move_crane_to_floor(crane_motor) shared_all.turn(angle=50) crane_motor.run(40) shared_all.move_straight(max_distance=130, speed_mm_s=50) crane_motor.stop(Stop.BRAKE) shared_all.move_crane_down(crane_motor, degrees=30) shared_all.move_straight(max_distance=60) """for x in range(5): worker.move_crane_up(robot, crane_motor, degrees=20) move_robot.move_straight(robot=robot, max_distance=40)""" shared_all.move_reverse(max_distance=350) """worker.move_crane_up(robot, crane_motor, degrees=20)
def drop_cubes(): shared_all.move_crane_down(crane_motor, 40) shared_all.move_crane_to_top(crane_motor)
def run(): shared_all.move_crane_down(motor=rack_motor, degrees=220)
def align(): shared_all.move_crane_to_floor(crane_motor) shared_all.move_straight(distance_mm=100, speed_mm_s=-300) shared_all.move_crane_down(motor=crane_motor, degrees=45) wait(10)
def bench_to_loading(): shared_all.move_straight(distance_mm=200, speed_mm_s=-140) shared_all.move_crane_to_top(crane_motor) shared_all.move_crane_down(crane_motor, 20) shared_all.sound_alarm() shared_all.any_button_pressed()