Add missions/New_MapReveal/New_MapReveal_Mineshaft.py
Rishi's updated code
This commit is contained in:
38
missions/New_MapReveal/New_MapReveal_Mineshaft.py
Normal file
38
missions/New_MapReveal/New_MapReveal_Mineshaft.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor
|
||||||
|
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
|
||||||
|
from pybricks.tools import run_task, multitask
|
||||||
|
from pybricks.tools import wait, StopWatch
|
||||||
|
from pybricks.robotics import DriveBase
|
||||||
|
from pybricks.hubs import PrimeHub
|
||||||
|
|
||||||
|
# Initialize hub and devices
|
||||||
|
hub = PrimeHub()
|
||||||
|
left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
|
||||||
|
right_motor = Motor(Port.B)
|
||||||
|
left_arm = Motor(Port.C)
|
||||||
|
right_arm = Motor(Port.D)
|
||||||
|
lazer_ranger = UltrasonicSensor(Port.E)
|
||||||
|
color_sensor = ColorSensor(Port.F)
|
||||||
|
|
||||||
|
# DriveBase configuration
|
||||||
|
WHEEL_DIAMETER = 68.8 # mm (adjust for your wheels)
|
||||||
|
AXLE_TRACK = 180 # mm (distance between wheels)
|
||||||
|
drive_base = DriveBase(left_motor, right_motor, WHEEL_DIAMETER, AXLE_TRACK)
|
||||||
|
drive_base.settings(600, 500, 300, 200)
|
||||||
|
drive_base.use_gyro(True)
|
||||||
|
|
||||||
|
WALL_DISTANCE = 200 # mm
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
await drive_base.straight(700)
|
||||||
|
await drive_base.turn(-20)
|
||||||
|
await drive_base.straight(110)
|
||||||
|
await drive_base.straight(-220)
|
||||||
|
await drive_base.turn(63)
|
||||||
|
await drive_base.straight(130)
|
||||||
|
await right_arm.run_angle(1000, -1200)
|
||||||
|
await drive_base.straight(84)
|
||||||
|
await right_arm.run_angle(300, 1200)
|
||||||
|
await drive_base.straight(-875)
|
||||||
|
|
||||||
|
run_task(main())
|
||||||
Reference in New Issue
Block a user