Files
bioglow_solutions/regionals/bioglow_mission_2.py

80 lines
4.5 KiB
Python
Raw Normal View History

2026-10-31 13:27:07 -05:00
#####################################
# Solution for BioGlow Mission 2
#####################################
import robot # drive base, arms, sensors and moves all come from robot.py
# UNITS used in this file -----------------------------------------------------
# robot.move(cm) distance in cm (+ forward, - backward)
# robot.turn(degrees) degrees (+ right / clockwise, - left)
# robot.arc(radius_cm, ...) radius in cm (+ circle on the right, - on the left),
# then degrees= around the circle or cm= along it (+ forward, - backward)
# speed= % of top speed, 1-100 (normal: 80% drive, 72% turn)
# acceleration= how fast it speeds up and slows down:
# mm/s² for move/arc (normal 500), °/s² for turn (normal 200)
# (² means "per second": 200 mm/s² = 200 mm/s faster every second)
# arm.move_by(degrees, speed=) arm turn in degrees, speed in % of the arm's top speed
# ------------------------------------------------------------------------------
async def solve_missions(): # Exploding Seeds - Johannes
# --- LET THE GYRO SETTLE ----------------------------------------------
# Wait half a second (and until the hub is perfectly still) before moving,
# so turns are measured from a steady heading.
2026-11-15 22:04:04 +00:00
#await robot.settle_gyro()
2026-10-31 13:27:07 -05:00
robot.stop()
robot.reset()
2026-11-08 17:16:13 +00:00
# Solving Exploding seeds
2026-11-15 21:53:22 +00:00
await robot.move(1, speed=100, acceleration=400, then=robot.Stop.NONE) # 2 cm forward, 100% speed, 400 mm/s² accel
2026-10-31 13:27:07 -05:00
await robot.arc(15, cm=11.5, speed=100, turn_speed=48, acceleration=400, turn_acceleration=100, then=robot.Stop.NONE) # arc: circle on the robot's RIGHT (15 cm radius), FORWARD 11.5 cm along it (nose turns right) | 100% speed, 48% turn speed, 400 mm/s² accel, 100 °/s² turn accel
2026-11-08 17:16:13 +00:00
await robot.move(27, speed=100, acceleration=400, then=robot.Stop.HOLD)
2026-10-31 13:27:07 -05:00
await robot.left_arm.move_by(70, speed=70) # left arm 70°, 70% arm speed
await robot.move(-3, speed=100, acceleration=400) # 3 cm backward, 100% speed, 400 mm/s² accel
2026-11-08 17:16:13 +00:00
await robot.left_arm.move_by(15, speed=23) # left arm 20°, 23% arm speed
await robot.move(-30, speed=100, acceleration=400, then=robot.Stop.COAST) # 30 cm backward, 100% speed, 400 mm/s² accel
2026-10-31 13:27:07 -05:00
await robot.multitask(
2026-11-08 17:16:13 +00:00
#robot.right_arm.move_by(-110, speed=100), # Don't drop the right arm
robot.left_arm.move_by(-100, speed=100),
2026-10-31 13:27:07 -05:00
robot.turn(-40, speed=48, acceleration=100, then=robot.Stop.HOLD) # 40° left, 48% turn speed, 100 °/s² turn accel
)
2026-11-08 17:16:13 +00:00
# Towards the vine
2026-11-15 21:53:22 +00:00
await robot.arc(68, degrees=65, speed=80, turn_speed=48, acceleration=400, turn_acceleration=100, then=robot.Stop.HOLD) # arc: circle on the robot's RIGHT (61 cm radius), FORWARD 70° (nose turns right) | 100% speed, 48% turn speed, 400 mm/s² accel, 100 °/s² turn accel
2026-11-08 17:16:13 +00:00
# This where we drop the right arm
2026-10-31 13:27:07 -05:00
await robot.multitask(
2026-11-08 17:16:13 +00:00
robot.right_arm.move_by(-110, speed=100),
2026-11-15 21:53:22 +00:00
robot.turn(-70, speed=70, acceleration=100, then=robot.Stop.HOLD)
2026-10-31 13:27:07 -05:00
)
2026-11-08 17:16:13 +00:00
# Untangled the vine
2026-11-15 21:53:22 +00:00
await robot.move(11, speed=70, acceleration=200, then=robot.Stop.COAST)
2026-11-08 17:16:13 +00:00
await robot.right_arm.move_by(70, speed=100) # right arm 70°, 100% arm speed
2026-11-15 22:45:54 +00:00
await robot.move(-10, speed=60, acceleration=200, then=robot.Stop.COAST) # 13 cm backward, 18% speed, 200 mm/s² accel
2026-11-08 17:16:13 +00:00
# Solving Sunlight roof
2026-10-31 13:27:07 -05:00
await robot.multitask(
2026-11-08 17:16:13 +00:00
robot.turn(95, speed=48, acceleration=100, then=robot.Stop.HOLD), # 95° right, 48% turn speed, 100 °/s² turn accel
robot.right_arm.move_by(100, speed=100) # right arm -40°, 100% arm speed
2026-10-31 13:27:07 -05:00
)
2026-11-15 21:53:22 +00:00
await robot.move(19, speed=100, acceleration=400, then=robot.Stop.COAST), # 16 cm forward, 100% speed, 400 mm/s² accel
2026-11-08 17:16:13 +00:00
# Return to barracks
2026-11-15 21:53:22 +00:00
await robot.move(-20, speed=100, acceleration=400, then=robot.Stop.NONE)
await robot.arc(40, degrees=-90,then = robot.Stop.NONE)
2026-11-08 17:16:13 +00:00
await robot.move(-40, speed=100, acceleration=400, then=robot.Stop.BRAKE)
robot.stop()
2026-10-31 13:27:07 -05:00
2026-11-08 17:16:13 +00:00
# For testing a part of a solution
def run_test_something():
await robot.arc(30, degrees=-90,then = robot.Stop.NONE)
await robot.move(-40, speed=100, acceleration=400, then=robot.Stop.BRAKE)
return
2026-10-31 13:27:07 -05:00
if __name__ == "__main__": # This run this mission stand-alone when not called from bioglow_main.py
robot.run_task(solve_missions())
2026-11-08 17:16:13 +00:00
#robot.run_task(run_test_something()) -- Uncomment this for testing and comment the line above