92 lines
3.7 KiB
Python
92 lines
3.7 KiB
Python
#####################################
|
|
# Solution for BioGlow Missions 7,12
|
|
#####################################
|
|
|
|
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(): # Humongous Fungus + Tree Cane
|
|
|
|
robot.stop()
|
|
robot.reset()
|
|
robot.drive_base.reset()
|
|
|
|
# --- 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(ms=10)
|
|
|
|
# Move towards Mycelium,lower left arm
|
|
await robot.multitask(
|
|
robot.move(70,speed=70,then=robot.Stop.BRAKE),
|
|
robot.left_arm.move_by(-45, speed=50)
|
|
)
|
|
|
|
# Lower right arm
|
|
await robot.right_arm.move_by(-60, speed=80)
|
|
await robot.wait(100)
|
|
|
|
# Extend mycelium
|
|
await robot.multitask(
|
|
robot.left_arm.move_by(90, speed=80),
|
|
robot.move(5,speed=30,then=robot.Stop.BRAKE)
|
|
)
|
|
await robot.wait(100)
|
|
|
|
# Move backward and raise tree support by turning right slightly
|
|
await robot.move(-5,speed=50,then=robot.Stop.HOLD)
|
|
await robot.turn(26,then=robot.Stop.HOLD)
|
|
|
|
# Turn and raise right arm or another way is to move forward
|
|
# and raise the arm before turning
|
|
await robot.turn(-25,then=robot.Stop.BRAKE)
|
|
await robot.wait(100)
|
|
await robot.right_arm.move_by(60, speed=80)
|
|
await robot.wait(100)
|
|
|
|
# Turn left and attempt to solve ants
|
|
await robot.turn(-90,then=robot.Stop.HOLD)
|
|
# go straight beyond the ants
|
|
await robot.move(35,then=robot.Stop.BRAKE)
|
|
|
|
#turn and align to ant then move forward
|
|
await robot.turn(130,then=robot.Stop.BRAKE)
|
|
await robot.move(20,speed=25,then=robot.Stop.HOLD)
|
|
|
|
#move back and turn towards home, attemp the windows to the past
|
|
await robot.move(-4,speed=60,then=robot.Stop.BRAKE)
|
|
await robot.turn(80,then=robot.Stop.HOLD)
|
|
|
|
#Return to home area and stop the robot
|
|
await robot.move(20,then = robot.Stop.NONE)
|
|
await robot.arc(60, degrees=60,then = robot.Stop.NONE)
|
|
robot.stop()
|
|
|
|
def test_something():
|
|
await robot.multitask(
|
|
#robot.move(10,speed=30,then=robot.Stop.BRAKE),
|
|
robot.left_arm.move_by(-45, speed=80),
|
|
robot.right_arm.move_by(-60, speed=80)
|
|
)
|
|
def test_ants_approach():
|
|
await robot.turn(135,then=robot.Stop.HOLD)
|
|
await robot.move(15,speed=30,then=robot.Sto)
|
|
await robot.move(-10,speed=60,then=robot.Stop.BRAKE)
|
|
await robot.turn(60,then=robot.Stop.HOLD)
|
|
await robot.move(90)
|
|
|
|
if __name__ == "__main__": # This run this mission stand-alone when not called from bioglow_main.py
|
|
robot.run_task(solve_missions())
|
|
#robot.run_task(test_something())
|
|
#robot.run_task(test_ants_approach()) |