Uploaded files from Bitbucket
This commit is contained in:
49
missions/M8_5.py
Normal file
49
missions/M8_5.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
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
|
||||||
|
from pybricks.tools import run_task, multitask
|
||||||
|
|
||||||
|
hub = PrimeHub()
|
||||||
|
|
||||||
|
left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
|
||||||
|
right_motor = Motor(Port.B)
|
||||||
|
|
||||||
|
left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE)
|
||||||
|
right_arm = Motor(Port.D)
|
||||||
|
|
||||||
|
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180)
|
||||||
|
|
||||||
|
drive_base.settings(600,500,300,200)
|
||||||
|
drive_base.use_gyro(True)
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
left_arm.run_angle(1000, 300)
|
||||||
|
right_arm.run_angle(1000,500)
|
||||||
|
await drive_base.straight(320)
|
||||||
|
|
||||||
|
await right_arm.run_angle(5000,-500, Stop.HOLD)
|
||||||
|
await right_arm.run_angle(5000,500, Stop.HOLD)
|
||||||
|
await right_arm.run_angle(5000,-500, Stop.HOLD)
|
||||||
|
await right_arm.run_angle(5000,500, Stop.HOLD)
|
||||||
|
await right_arm.run_angle(5000,-500, Stop.HOLD)
|
||||||
|
|
||||||
|
await drive_base.turn(-20)
|
||||||
|
await drive_base.straight(275)
|
||||||
|
await drive_base.turn(20)
|
||||||
|
await drive_base.straight(63)
|
||||||
|
|
||||||
|
await drive_base.turn(-30)
|
||||||
|
right_arm.run_angle(50,500)
|
||||||
|
await drive_base.turn(45)
|
||||||
|
await drive_base.straight(-135)
|
||||||
|
await drive_base.turn(-60)
|
||||||
|
await drive_base.straight(90)
|
||||||
|
await left_arm.run_angle(1000,-450)
|
||||||
|
await drive_base.straight(-145)
|
||||||
|
await left_arm.run_angle(1000,450)
|
||||||
|
await drive_base.straight(10)
|
||||||
|
await drive_base.turn(35)
|
||||||
|
await drive_base.straight(-500)
|
||||||
|
run_task(main())
|
||||||
34
missions/Send_Over.py
Normal file
34
missions/Send_Over.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
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
|
||||||
|
from pybricks.tools import run_task, multitask
|
||||||
|
|
||||||
|
hub = PrimeHub()
|
||||||
|
|
||||||
|
left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
|
||||||
|
right_motor = Motor(Port.B)
|
||||||
|
|
||||||
|
left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE)
|
||||||
|
right_arm = Motor(Port.D)
|
||||||
|
|
||||||
|
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=64.8, axle_track=180)
|
||||||
|
|
||||||
|
drive_base.settings(600,500,300,200)
|
||||||
|
drive_base.use_gyro(True)
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
|
||||||
|
await drive_base.straight(855)
|
||||||
|
await drive_base.turn(-90)
|
||||||
|
await drive_base.straight(50)
|
||||||
|
await left_arm.run_angle(10000,-15000)
|
||||||
|
await drive_base.straight(-50)
|
||||||
|
await drive_base.turn(90)
|
||||||
|
await drive_base.straight(2000)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
run_task(main())
|
||||||
43
missions/mission_09.py
Normal file
43
missions/mission_09.py
Normal 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())
|
||||||
Reference in New Issue
Block a user