47 lines
2.8 KiB
Python
47 lines
2.8 KiB
Python
|
|
#####################################
|
||
|
|
# Solution for BioGlow Mission 8
|
||
|
|
#####################################
|
||
|
|
|
||
|
|
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(): # Research Platform - Johannes
|
||
|
|
|
||
|
|
# --- 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()
|
||
|
|
|
||
|
|
robot.reset()
|
||
|
|
await robot.arc(128, cm=34) # arc: circle on the robot's RIGHT (128 cm radius), FORWARD 34 cm along it (nose turns right)
|
||
|
|
await robot.arc(-140, cm=35.5) # arc: circle on the robot's LEFT (140 cm radius), FORWARD 35.5 cm along it (nose turns left)
|
||
|
|
await robot.move(14.5, speed=18, acceleration=400) # 14.5 cm forward, 18% speed, 400 mm/s² accel
|
||
|
|
await robot.lift_up(900, speed=93)
|
||
|
|
await robot.lift_down(300, speed=100)
|
||
|
|
await robot.move(-15, speed=18, acceleration=400) # 15 cm backward, 18% speed, 400 mm/s² accel
|
||
|
|
await robot.turn(20, speed=100, acceleration=500) # 20° right, 100% turn speed, 500 °/s² turn accel
|
||
|
|
await robot.move(6.3, speed=100) # 6.3 cm forward, 100% speed
|
||
|
|
await robot.arc(-100, cm=-110, speed=100) # arc: circle on the robot's LEFT (100 cm radius), BACKWARD 110 cm along it (back end swings left, nose turns right) | 100% speed
|
||
|
|
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())
|