Added object oriented version of codes

This commit is contained in:
2026-10-31 13:27:07 -05:00
parent 63f7c48a64
commit cea616f13e
19 changed files with 1619 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
#####################################
# Solution for BioGlow Mission 13
#####################################
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(): # Interchangeable Mission - Parthiv
# --- ARM HOMING (optional) -------------------------------------------
# Uncomment the next line to push both arms gently against their hard stops
# and call that spot 0, so every arm move starts from the same place each run.
# Before using it: set home_backward for each arm in robot.py (run arm_calibrate.py).
# await robot.home_arms()
# --- 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.
await robot.settle_gyro()
await robot.left_arm.move_by(-80, speed=47) # left arm -80°, 47% arm speed
await robot.arc(-35, degrees=90) # arc: circle on the robot's LEFT (35 cm radius), FORWARD 90° (nose turns left)
await robot.turn(50) # 50° right
await robot.move(23.8) # 23.8 cm forward
await robot.turn(-33) # 33° left
await robot.move(8.5) # 8.5 cm forward
await robot.move(-3.3) # 3.3 cm backward
await robot.multitask(
robot.left_arm.move_by(80, speed=47), # left arm 80°, 47% arm speed
robot.right_arm.move_by(-100, speed=47) # right arm -100°, 47% arm speed
)
await robot.move(-6) # 6 cm backward
await robot.right_arm.move_by(100, speed=47) # right arm 100°, 47% arm speed
await robot.turn(30) # 30° right
await robot.move(-77.5) # 77.5 cm backward
robot.stop() # FIXED: was `await drive_base.stop` (crashed)
if __name__ == "__main__": # This run this mission stand-alone when not called from bioglow_main.py
robot.run_task(solve_missions())