def turn_arc_90(): shared_all.log_string('Arc turns 90 deg 12 cm') shared_all.turn_arc(distance=120, angle=90, speed_mm_s=130) wait(2000) shared_all.turn_arc(distance=120, angle=-90, speed_mm_s=130) wait(2000)
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 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))
#!/usr/bin/env pybricks-micropython import sys import os sys.path.append('../shared') sys.path.append('../samples') import shared_all import bus_service_1 import treadmill import row import weight, phone, slide shared_all.calibrate_gyro(180) shared_all.log_string('bus_service_1.base_to_treadmill()') # bus_service_1.base_to_treadmill() # shared_all.log_string('treadmill.align()') treadmill.align() shared_all.log_string('treadmill.run()') treadmill.run() # shared_all.log_string('bus_service_1.treadmill_to_row()') # bus_service_1.treadmill_to_row() # shared_all.log_string('row.align()') # row.align() # shared_all.log_string('row.run()') # row.run() # shared_all.log_string('bus_service_1.row_to_weight()') bus_service_1.treadmill_to_weight() shared_all.log_string('weight.align()')
def deepsweep(): shared_all.calibrate_gyro(180) shared_all.log_string('bus_service_1.base_to_treadmill()') bus_service_1.base_to_treadmill() shared_all.log_string('treadmill.align()') treadmill.align() shared_all.log_string('treadmill.run()') treadmill.run() # shared_all.log_string('bus_service_1.treadmill_to_row()') # bus_service_1.treadmill_to_row() # shared_all.log_string('row.align()') # row.align() # shared_all.log_string('row.run()') # row.run() shared_all.log_string('bus_service_1.treadmill_to_weight()') bus_service_1.treadmill_to_weight() shared_all.log_string('weight.align()') weight.align() shared_all.log_string('weight.run()') weight.run() shared_all.log_string('bus_service_1.weight_to_phone()') bus_service_1.weight_to_phone() shared_all.log_string('phone.align()') phone.align() shared_all.log_string('phone.run()') phone.run() ArnavBus.boccia_slide_to_home()
def bocciarun(): shared_all.calibrate_gyro(-45) boccia.align() boccia.run() def lastbow(): shared_all.calibrate_gyro(0) bus_service_1.base_to_stepcounter() stepcounter.run() while True: buttons = shared_all.any_button_pressed() shared_all.log_string('Button pressed ' + str(buttons)) if Button.UP in buttons: ## BUT 1 bocciarun() if Button.RIGHT in buttons: ## BUT 2 benchrun() if Button.DOWN in buttons: ## BUT 3 innov_basket() if Button.LEFT in buttons: ## button 4 sliderun() if Button.CENTER in buttons: ## button center buttons = shared_all.any_button_pressed(waiting_color=Color.YELLOW) if Button.UP in buttons: ## BUT 1 deepsweep() if Button.RIGHT in buttons: ## BUT 2
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()))
from robot_setup import ultrasound from robot_setup import SOUND_VOLUME from robot_setup import WHEEL_DIAMETER_MM from robot_setup import AXLE_TRACK_MM from robot_setup import SENSOR_TO_AXLE from robot_setup import WHEEL_CIRCUM_MM from robot_setup import DEGREES_PER_MM from robot_setup import WHITE_MIN_INTENSITY from robot_setup import BLACK_MAX_INTENSITY import shared_all ##### Do not change above this line ########################################## shared_all.log_string('Buttons LEFT_DOWN ' + str(Button.LEFT_DOWN)) shared_all.log_string('Buttons DOWN ' + str(Button.DOWN)) shared_all.log_string('Buttons RIGHT_DOWN ' + str(Button.RIGHT_DOWN)) shared_all.log_string('Buttons LEFT ' + str(Button.LEFT)) shared_all.log_string('Buttons CENTER ' + str(Button.CENTER)) shared_all.log_string('Buttons RIGHT ' + str(Button.RIGHT)) shared_all.log_string('Buttons LEFT_UP ' + str(Button.LEFT_UP)) shared_all.log_string('Buttons UP ' + str(Button.UP)) shared_all.log_string('Buttons BEACON ' + str(Button.BEACON)) shared_all.log_string('Buttons RIGHT_UP ' + str(Button.RIGHT_UP)) while True: buttons = shared_all.any_button_pressed() shared_all.log_string('Button pressed ' + str(buttons)) if Button.LEFT in buttons:
from robot_setup import WHEEL_CIRCUM_MM from robot_setup import DEGREES_PER_MM import shared_all ##### Do not change above this line ########################################## import bus_service_1 import bus_service_2 import stepcounter import treadmill import row import phone import flip import weight import slide import bench import basket shared_all.calibrate_gyro(-90) shared_all.log_string('bus_service_1.weight_to_phone()') bus_service_1.weight_to_phone() shared_all.log_string('phone.align()') phone.align() shared_all.log_string('phone.run()') phone.run() bus_service_1.phone_to_bigt() flip.bigt_align() flip.flip_bigt()
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()))
shared_all.calibrate_gyro(0) time1 = utime.ticks_ms() for x in range(10): gyro.angle() time2 = utime.ticks_ms() for x in range(10): a = time1 + 1 time3 = utime.ticks_ms() for x in range(10): a = color_sensor_center.color() time4 = utime.ticks_ms() for x in range(10): a = color_sensor_center.reflection() time5 = utime.ticks_ms() for x in range(10): shared_all.log_string('Log it s ' + str(time5) + ' ' + str(time4)) time6 = utime.ticks_ms() shared_all.log_string('Time for 10 angle reads ' + str(utime.ticks_diff(time2, time1))) shared_all.log_string('Time for 10 adds ' + str(utime.ticks_diff(time3, time2))) shared_all.log_string('Time for 10 color reads ' + str(utime.ticks_diff(time4, time3))) shared_all.log_string('Time for 10 intensity reads ' + str(utime.ticks_diff(time5, time4))) shared_all.log_string('Time for 10 logs ' + str(utime.ticks_diff(time6, time5)))