Uploaded files from Bitbucket

This commit is contained in:
2025-09-10 13:38:07 +00:00
parent e36e3d03fc
commit 5c7e2e9eb2
3 changed files with 126 additions and 0 deletions

43
missions/mission_09.py Normal file
View File

@@ -0,0 +1,43 @@
# ---JOHANNES---
from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch
hub = PrimeHub()
# Initialize both motors. In this example, the motor on the
# left must turn counterclockwise to make the robot go forward.
left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.B)
arm_motor = Motor(Port.E, Direction.CLOCKWISE)
arm_motor.run_angle(299,90, Stop.HOLD)
# Initialize the drive base. In this example, the wheel diameter is 56mm.
# The distance between the two wheel-ground contact points is 112mm.
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=54, axle_track=140)
print('The default settings are: ' + str(drive_base.settings()))
drive_base.settings(100,1000,166,750)
# Optionally, uncomment the line below to use the gyro for improved accuracy.
drive_base.use_gyro(True)
async def solveM9():
print("Solving Mission 9")
await drive_base.turn(45)
await drive_base.straight(260)
await arm_motor.run_angle(500,-500, Stop.HOLD)
await drive_base.straight(-40)
await drive_base.turn(92)
await drive_base.straight(-120)
await drive_base.straight(220)
await arm_motor.run_angle(500,100, Stop.HOLD)
await drive_base.turn(-50)
await drive_base.straight(-600)
async def main():
await drive_base.straight(50)
print("Hello, Robot is starting to run.")
await solveM9()
run_task(main())