2025-09-10 13:38:07 +00:00
|
|
|
# ---JOHANNES---
|
2025-10-06 18:10:02 +00:00
|
|
|
# THIS CODE IS NOT USED ANYMORE AND SHOULD NOT BE USED!!!!!!
|
2025-09-10 13:38:07 +00:00
|
|
|
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())
|