Update codes_for_scrimmage/hazmat/mainhazmatUPD.py

This commit is contained in:
2025-10-24 01:07:23 +00:00
parent 3765db3001
commit b41f833c5e

View File

@@ -21,7 +21,7 @@ drive_base = DriveBase(left_motor, right_motor, WHEEL_DIAMETER, AXLE_TRACK)
drive_base.settings(600, 500, 300, 200) drive_base.settings(600, 500, 300, 200)
drive_base.use_gyro(True) drive_base.use_gyro(True)
WALL_DISTANCE = 200 # mm WALL_DISTANCE = 300 # mm
async def drive_forward(): async def drive_forward():
"""Drive forward continuously using DriveBase.""" """Drive forward continuously using DriveBase."""
@@ -32,11 +32,11 @@ async def monitor_distance():
"""Monitor ultrasonic sensor and stop when wall is detected.""" """Monitor ultrasonic sensor and stop when wall is detected."""
while True: while True:
distance = lazer_ranger.distance() distance = lazer_ranger.distance()
print('Distancing...',distance)
if distance < WALL_DISTANCE: if distance < WALL_DISTANCE:
# Stop the drivebase # Stop the drivebase
await drive_base.turn(-180) await drive_base.stop
drive_base.brake()
print(f"Wall detected at {distance}mm!") print(f"Wall detected at {distance}mm!")
break break
@@ -117,7 +117,7 @@ async def Run4(): # From Send_Over_Final.py
await drive_base.straight(65) await drive_base.straight(65)
#Solve mission #Solve mission
drive_base.turn(-10) drive_base.turn(-10)
await left_arm.run_angle(10000,-4000) await left_arm.run_angle(10000, 4000)
#Get to Red Start #Get to Red Start
await drive_base.straight(-110) await drive_base.straight(-110)
await drive_base.turn(90) await drive_base.turn(90)