From 751e008854c1ea5b5df9015842ea7d0069de550c Mon Sep 17 00:00:00 2001 From: nifrali Date: Tue, 25 Nov 2025 13:17:33 -0600 Subject: [PATCH 01/26] Experimentals --- .../hazmat/HazmatCodeChanges.py | 0 .../hazmat/Heavy_lifting_final.py | 0 .../hazmat/M8_5.py | 0 .../hazmat/Send_Over_Final.py | 0 .../hazmat/hazmat_main.py | 0 .../hazmat/mainhazmatUPD.py | 0 .../hazmat/tip the scale.py | 0 .../regional-final/Final_combined.py | 0 .../sectionals/sectional_main_experimental.py | 350 ++++++++++++++++++ 9 files changed, 350 insertions(+) rename {codes_for_scrimmage => competition_codes}/hazmat/HazmatCodeChanges.py (100%) rename {codes_for_scrimmage => competition_codes}/hazmat/Heavy_lifting_final.py (100%) rename {codes_for_scrimmage => competition_codes}/hazmat/M8_5.py (100%) rename {codes_for_scrimmage => competition_codes}/hazmat/Send_Over_Final.py (100%) rename {codes_for_scrimmage => competition_codes}/hazmat/hazmat_main.py (100%) rename {codes_for_scrimmage => competition_codes}/hazmat/mainhazmatUPD.py (100%) rename {codes_for_scrimmage => competition_codes}/hazmat/tip the scale.py (100%) rename {codes_for_scrimmage => competition_codes}/regional-final/Final_combined.py (100%) create mode 100644 competition_codes/sectionals/sectional_main_experimental.py diff --git a/codes_for_scrimmage/hazmat/HazmatCodeChanges.py b/competition_codes/hazmat/HazmatCodeChanges.py similarity index 100% rename from codes_for_scrimmage/hazmat/HazmatCodeChanges.py rename to competition_codes/hazmat/HazmatCodeChanges.py diff --git a/codes_for_scrimmage/hazmat/Heavy_lifting_final.py b/competition_codes/hazmat/Heavy_lifting_final.py similarity index 100% rename from codes_for_scrimmage/hazmat/Heavy_lifting_final.py rename to competition_codes/hazmat/Heavy_lifting_final.py diff --git a/codes_for_scrimmage/hazmat/M8_5.py b/competition_codes/hazmat/M8_5.py similarity index 100% rename from codes_for_scrimmage/hazmat/M8_5.py rename to competition_codes/hazmat/M8_5.py diff --git a/codes_for_scrimmage/hazmat/Send_Over_Final.py b/competition_codes/hazmat/Send_Over_Final.py similarity index 100% rename from codes_for_scrimmage/hazmat/Send_Over_Final.py rename to competition_codes/hazmat/Send_Over_Final.py diff --git a/codes_for_scrimmage/hazmat/hazmat_main.py b/competition_codes/hazmat/hazmat_main.py similarity index 100% rename from codes_for_scrimmage/hazmat/hazmat_main.py rename to competition_codes/hazmat/hazmat_main.py diff --git a/codes_for_scrimmage/hazmat/mainhazmatUPD.py b/competition_codes/hazmat/mainhazmatUPD.py similarity index 100% rename from codes_for_scrimmage/hazmat/mainhazmatUPD.py rename to competition_codes/hazmat/mainhazmatUPD.py diff --git a/codes_for_scrimmage/hazmat/tip the scale.py b/competition_codes/hazmat/tip the scale.py similarity index 100% rename from codes_for_scrimmage/hazmat/tip the scale.py rename to competition_codes/hazmat/tip the scale.py diff --git a/codes_for_scrimmage/regional-final/Final_combined.py b/competition_codes/regional-final/Final_combined.py similarity index 100% rename from codes_for_scrimmage/regional-final/Final_combined.py rename to competition_codes/regional-final/Final_combined.py diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_experimental.py new file mode 100644 index 0000000..dabb297 --- /dev/null +++ b/competition_codes/sectionals/sectional_main_experimental.py @@ -0,0 +1,350 @@ +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,Direction.CLOCKWISE) # Specify default direction +left_arm = Motor(Port.C, Direction.CLOCKWISE) # Specify default direction +right_arm = Motor(Port.D, Direction.CLOCKWISE,[[12,36],[12,20,24]]) #Added gear train list for gear ration +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 = 300 # mm + +async def drive_forward(): + """Drive forward continuously using DriveBase.""" + drive_base.drive(400, 0) + +async def drive_backward(): + """Drive forward continuously using DriveBase.""" + drive_base.drive(400, 0) + +async def async_drive(speed, direction): + drive_base.d + + +async def monitor_distance(): + """Monitor ultrasonic sensor and stop when wall is detected.""" + while True: + distance = await lazer_ranger.distance() + print('Distancing...',distance) + + if distance < WALL_DISTANCE: + # Stop the drivebase + drive_base.stop() + print(f"Wall detected at {distance}mm!") + break + + # Small delay to prevent overwhelming the sensor + await wait(50) + +# Experimental - Removed forge and who live here part +async def Run1(): # From M8_5.py + right_arm.run_angle(500,30) + left_arm.run_angle(500,90) + await drive_base.straight(200) + + await drive_base.turn(-40) + await drive_base.straight(325) + await left_arm.run_angle(500,-90) + + await drive_base.straight(-100) + await drive_base.straight(50) + await left_arm.run_angle(500,180) + + await drive_base.straight(-90) + left_arm.run_angle(500,-180) + await drive_base.turn(-20) + await drive_base.turn(15) + + await drive_base.straight(-173) + await drive_base.turn(45) + await drive_base.straight(120) + left_arm.run_angle(1000,670) + + await right_arm.run_angle(4000,-30, Stop.HOLD) + await right_arm.run_angle(4000,30, Stop.HOLD) + await right_arm.run_angle(4000,-30, Stop.HOLD) + await right_arm.run_angle(4000,30, Stop.HOLD) + await right_arm.run_angle(4000,-30, Stop.HOLD) + right_arm.run_angle(4000,30, Stop.HOLD) + + # await drive_base.turn(-35) + # await drive_base.straight(297) + # await drive_base.turn(63) + # await drive_base.straight(170) + + # await drive_base.turn(-80) + # await drive_base.straight(87) + # await drive_base.turn(-15) + + await drive_base.straight(-90) + #await drive_base.turn(-100) + await drive_base.arc(200,None,-300) + drive_base.stop() + +async def Run2(): # experiment with ferris wheel for silo + await drive_base.straight(410) + #await drive_base.turn(-20) + #await drive_base.straight(536) + #await drive_base.turn(60, Stop.HOLD) + #await drive_base.straight(30) + for i in range(3): + await right_arm.run_angle(10000, -360) + await drive_base.straight(-400) + +# Experimental - This to solve forge, who lived here and heavy lifting combined +async def Run2_1(): + await right_arm.run_target(50,50) + #await right_arm.re + #await multitask( + await right_arm.run_angle(50,-30) + await drive_base.arc(350,113, None) + #) + await drive_base.turn(-60) + await drive_base.straight(-40) + + await right_arm.run_angle(500,-90) # arm down + await wait(100) + await drive_base.turn(20) # turn right a little bit + #await wait(100) + await right_arm.run_angle(500,90) #arm up + await drive_base.turn(-20) #reset position + + await drive_base.straight(50) + await drive_base.turn(-15) + await drive_base.straight(50) + await drive_base.turn(-25) + + await drive_base.straight(-50) + await drive_base.turn(-100) + await drive_base.arc(-500,None,600) + drive_base.brake() + + +async def Run3(): # tip the scale.py + right_arm.run_angle(500,30) + await drive_base.straight(800) + await drive_base.turn(90) + await drive_base.straight(86) + await right_arm.run_angle(800,-140) + await right_arm.run_angle(900,140) + + await drive_base.straight(-100) + await drive_base.turn(90) + await drive_base.straight(800) + drive_base.brake() + + +async def Run4(): # From Send_Over_Final.py + + await drive_base.straight(920) + await drive_base.turn(-90,Stop.HOLD) + await drive_base.straight(65) + #Solve + drive_base.turn(-10) + await left_arm.run_angle(10000,-3000) + await drive_base.straight(-110) + await drive_base.turn(90) + + await multitask( + drive_forward(), + monitor_distance() + ) + +async def Run_3_4(): #combined angler artifacts and tip the scale - experimental + await drive_base.straight(920) + await drive_base.turn(-90,Stop.HOLD) + await drive_base.straight(65) + #Solve + drive_base.turn(-10) + await left_arm.run_angle(10000,-3000) + await drive_base.straight(-110) + await drive_base.turn(90) + await drive_base.arc(-150,-95, None) + + await drive_base.straight(100) + await right_arm.run_angle(800,-150) + await right_arm.run_angle(900,150) + + await drive_base.straight(-80) + await drive_base.turn(-67) + await drive_base.straight(450,Stop.COAST_SMART) + await drive_base.arc(10,-25, None) + #await drive_base.turn(-23, Stop.COAST_SMART) + + await multitask( + drive_forward(), + monitor_distance() + ) + + +# Add Rishi's code here +async def Run5(): + await drive_base.straight(700) + await drive_base.turn(-20) + await drive_base.straight(110) + await drive_base.straight(-210) + await drive_base.turn(63) + await drive_base.straight(130) + await right_arm.run_angle(1000, -90) + await drive_base.straight(84) + await right_arm.run_angle(300, 90) + await drive_base.straight(-875) + +# Add - Adi's code here +async def Run6(): + await drive_base.straight(500) + await right_arm.run_angle(300,500) + await drive_base.straight(-75) + await right_arm.run_angle(300, -900) + await drive_base.straight(-350) + await wait(1000) + await drive_base.straight(800) + await drive_base.straight(-200) + await drive_base.turn(-15) + await drive_base.straight(350) + await drive_base.turn(-100) + await drive_base.straight(-80) + await left_arm.run_angle(500, -900) + await drive_base.straight(50) + await drive_base.straight(50) + await left_arm.run_angle(700, 250) + await drive_base.turn(30) + await drive_base.straight(-60) + await drive_base.turn(80) + await drive_base.straight(-900) + +async def arc_back(radius, angle): + #print(radius, angle) + drive_base.arc(radius, angle, None) + +async def lift_right_arm(): + await right_arm.run_angle(100, -90) + +# This is a refactor of Salvage operation mission without wait and realignment +async def Run6_1(): #experimental + + await drive_base.straight(500) + await right_arm.run_angle(100,90) + await drive_base.straight(-75) + + #ack back while raising arm + await multitask ( + lift_right_arm(), + arc_back(-215, -45) + ) + + #align to raise the ship + await drive_base.straight(-150) + await drive_base.turn(-45) + + #await drive_base.straight(-350) + #await wait(1000) + + #Solve ship + await drive_base.straight(800) + await drive_base.straight(-200) + await drive_base.turn(-15) + await drive_base.straight(350) + await drive_base.turn(-100) + await drive_base.straight(-80) + await left_arm.run_angle(500, -700) + await drive_base.straight(50) + await drive_base.straight(50) + await left_arm.run_angle(700, 250) + await drive_base.turn(15) + await drive_base.straight(-80) + await drive_base.turn(80) + await drive_base.straight(-900) + drive_base.stop() + +async def Run6_7(): # experiment with ferris wheel for Site Markings + await drive_base.straight(500) + + await right_arm.run_angle(100, -10) + await wait(50) + #await multitask ( + #lift_right_arm() + #await right_arm.run_angle(100, 10) + #await arc_back(-215, -140) + await drive_base.straight(-300) + await drive_base.arc(-150, -140, None) + + await drive_base.straight(-300) + await wait(50) + await right_arm.run_angle(50, 50) + #await drive_base.straight(-300) + drive_base.stop() + +# Function to classify color based on HSV +def detect_color(h, s, v, reflected): + if reflected > 4: + if h < 4 or h > 350: # red + return "Red" + elif 3 < h < 40 and s > 70: # orange + return "Orange" + elif 47 < h < 56: # yellow + return "Yellow" + elif 70 < h < 160: # green - do it vertically not horizontally for accuracy + return "Green" + elif 195 < h < 198: # light blue + return "Light_Blue" + elif 210 < h < 225: # blue - do it vertically not horizontally for accuracy + return "Blue" + elif 260 < h < 350: # purple + return "Purple" + + else: + return "Unknown" + return "Unknown" + + +async def main(): + while True: + h, s, v = await color_sensor.hsv() + print(color_sensor.color()) + print(h,s,v) + reflected = await color_sensor.reflection() + color = detect_color(h, s, v, reflected) + print(color) + + + if color == "Red": + print('Running Mission 3') + await Run3() #red + elif color == "Orange": + print('Running Mission 6') + await Run6_1() #orange + elif color == "Yellow": + print('Running Mission 4') + await Run_3_4() #yellow + elif color == "Green": + print('Running Mission 1') + await Run1() #green - vertically + elif color == "Blue": + print('Running Mission 5') + await Run5() #blue - vertically + elif color == "Purple": + print('Running Mission 2') + await Run6_7() #purple - vertically + elif color == "Light_Blue": + print("Running Mission 2_1") + await Run2_1() + else: + print(f"Unknown color detected (Hue: {h}, Sat: {s}, Val: {v})") + await wait(10) +# Run the main function +run_task(main()) \ No newline at end of file From 05be290f90ef00ebff4f87654fdbe1bd664efba6 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Tue, 25 Nov 2025 20:23:48 +0000 Subject: [PATCH 02/26] Update competition_codes/sectionals/sectional_main_experimental.py --- .../sectionals/sectional_main_experimental.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_experimental.py index dabb297..164ddc0 100644 --- a/competition_codes/sectionals/sectional_main_experimental.py +++ b/competition_codes/sectionals/sectional_main_experimental.py @@ -31,9 +31,6 @@ async def drive_backward(): """Drive forward continuously using DriveBase.""" drive_base.drive(400, 0) -async def async_drive(speed, direction): - drive_base.d - async def monitor_distance(): """Monitor ultrasonic sensor and stop when wall is detected.""" @@ -46,11 +43,14 @@ async def monitor_distance(): drive_base.stop() print(f"Wall detected at {distance}mm!") break + if distance is None: + continue + # Small delay to prevent overwhelming the sensor await wait(50) -# Experimental - Removed forge and who live here part +# Experimental - Removed forge and who lived here part async def Run1(): # From M8_5.py right_arm.run_angle(500,30) left_arm.run_angle(500,90) From 489ff94601d572516c87e318e3c09c1cafffce42 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Tue, 25 Nov 2025 20:27:57 +0000 Subject: [PATCH 03/26] Update competition_codes/sectionals/sectional_main_experimental.py --- competition_codes/sectionals/sectional_main_experimental.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_experimental.py index 164ddc0..3deb707 100644 --- a/competition_codes/sectionals/sectional_main_experimental.py +++ b/competition_codes/sectionals/sectional_main_experimental.py @@ -131,7 +131,7 @@ async def Run2_1(): await drive_base.straight(-50) await drive_base.turn(-100) await drive_base.arc(-500,None,600) - drive_base.brake() + drive_base.stop() async def Run3(): # tip the scale.py @@ -145,7 +145,7 @@ async def Run3(): # tip the scale.py await drive_base.straight(-100) await drive_base.turn(90) await drive_base.straight(800) - drive_base.brake() + drive_base.stop() async def Run4(): # From Send_Over_Final.py From f389ff7101577e2caa92c7d67dd95e8d44a51b61 Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Thu, 4 Dec 2025 01:46:03 +0000 Subject: [PATCH 04/26] Update competition_codes/sectionals/sectional_main_experimental.py --- competition_codes/sectionals/sectional_main_experimental.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_experimental.py index 3deb707..d6accad 100644 --- a/competition_codes/sectionals/sectional_main_experimental.py +++ b/competition_codes/sectionals/sectional_main_experimental.py @@ -173,7 +173,7 @@ async def Run_3_4(): #combined angler artifacts and tip the scale - experimental await left_arm.run_angle(10000,-3000) await drive_base.straight(-110) await drive_base.turn(90) - await drive_base.arc(-150,-95, None) + await drive_base.arc(-150,-100, None) await drive_base.straight(100) await right_arm.run_angle(800,-150) From e8c25a4e906daf5dbbf6ae291cd6d2f7430f458a Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Thu, 4 Dec 2025 03:01:19 +0000 Subject: [PATCH 05/26] Update competition_codes/sectionals/sectional_main_experimental.py --- .../sectionals/sectional_main_experimental.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_experimental.py index d6accad..715d7ba 100644 --- a/competition_codes/sectionals/sectional_main_experimental.py +++ b/competition_codes/sectionals/sectional_main_experimental.py @@ -21,7 +21,7 @@ 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 = 300 # mm +WALL_DISTANCE = 200 # mm async def drive_forward(): """Drive forward continuously using DriveBase.""" @@ -113,14 +113,15 @@ async def Run2_1(): await right_arm.run_angle(50,-30) await drive_base.arc(350,113, None) #) + await drive_base.straight(20) await drive_base.turn(-60) - await drive_base.straight(-40) + await drive_base.straight(-47) await right_arm.run_angle(500,-90) # arm down await wait(100) await drive_base.turn(20) # turn right a little bit #await wait(100) - await right_arm.run_angle(500,90) #arm up + await right_arm.run_angle(500,140) #arm up await drive_base.turn(-20) #reset position await drive_base.straight(50) @@ -175,14 +176,14 @@ async def Run_3_4(): #combined angler artifacts and tip the scale - experimental await drive_base.turn(90) await drive_base.arc(-150,-100, None) - await drive_base.straight(100) + await drive_base.straight(135) await right_arm.run_angle(800,-150) await right_arm.run_angle(900,150) - await drive_base.straight(-80) - await drive_base.turn(-67) - await drive_base.straight(450,Stop.COAST_SMART) - await drive_base.arc(10,-25, None) + await drive_base.straight(-100) + await drive_base.turn(-65) + await drive_base.straight(320,Stop.COAST_SMART) + await drive_base.arc(10,-47, None) #await drive_base.turn(-23, Stop.COAST_SMART) await multitask( @@ -324,7 +325,7 @@ async def main(): if color == "Red": print('Running Mission 3') - await Run3() #red + await Run2_1() #red elif color == "Orange": print('Running Mission 6') await Run6_1() #orange @@ -342,9 +343,9 @@ async def main(): await Run6_7() #purple - vertically elif color == "Light_Blue": print("Running Mission 2_1") - await Run2_1() + await Run3() else: print(f"Unknown color detected (Hue: {h}, Sat: {s}, Val: {v})") await wait(10) # Run the main function -run_task(main()) \ No newline at end of file +run_task(main()) From d235d602ce6ea39b58e3ea69a6865d62d1d3bb32 Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Thu, 4 Dec 2025 23:33:57 +0000 Subject: [PATCH 06/26] Update competition_codes/sectionals/sectional_main_experimental.py --- .../sectionals/sectional_main_experimental.py | 265 +++++++++--------- 1 file changed, 132 insertions(+), 133 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_experimental.py index 715d7ba..64952ff 100644 --- a/competition_codes/sectionals/sectional_main_experimental.py +++ b/competition_codes/sectionals/sectional_main_experimental.py @@ -50,8 +50,24 @@ async def monitor_distance(): # Small delay to prevent overwhelming the sensor await wait(50) -# Experimental - Removed forge and who lived here part -async def Run1(): # From M8_5.py +""" +Run#1 +- Removed forge and who lived here part +- What's on sale + Silo +- Green Key +""" +async def Run1(): + await solve_whats_on_sale() + await solve_silo() + + # return to base + await drive_base.straight(-90) + #await drive_base.turn(-100) + await drive_base.arc(200,None,-300) + drive_base.stop() + +async def solve_whats_on_sale(): + right_arm.run_angle(500,30) left_arm.run_angle(500,90) await drive_base.straight(200) @@ -69,6 +85,7 @@ async def Run1(): # From M8_5.py await drive_base.turn(-20) await drive_base.turn(15) +async def solve_silo(): await drive_base.straight(-173) await drive_base.turn(45) await drive_base.straight(120) @@ -81,91 +98,86 @@ async def Run1(): # From M8_5.py await right_arm.run_angle(4000,-30, Stop.HOLD) right_arm.run_angle(4000,30, Stop.HOLD) - # await drive_base.turn(-35) - # await drive_base.straight(297) - # await drive_base.turn(63) - # await drive_base.straight(170) - # await drive_base.turn(-80) - # await drive_base.straight(87) - # await drive_base.turn(-15) +""" +Run#2 +- This to solve forge, who lived here and heavy lifting combined +- Red Key +""" +async def Run2(): + await solve_forge() + await solve_heavy_lifting() + await solve_who_lived_here() - await drive_base.straight(-90) - #await drive_base.turn(-100) - await drive_base.arc(200,None,-300) + # return to base + await drive_base.arc(-500,None,600) drive_base.stop() - -async def Run2(): # experiment with ferris wheel for silo - await drive_base.straight(410) - #await drive_base.turn(-20) - #await drive_base.straight(536) - #await drive_base.turn(60, Stop.HOLD) - #await drive_base.straight(30) - for i in range(3): - await right_arm.run_angle(10000, -360) - await drive_base.straight(-400) -# Experimental - This to solve forge, who lived here and heavy lifting combined -async def Run2_1(): +async def solve_forge(): await right_arm.run_target(50,50) - #await right_arm.re - #await multitask( await right_arm.run_angle(50,-30) await drive_base.arc(350,113, None) - #) + await drive_base.straight(20) await drive_base.turn(-60) await drive_base.straight(-47) +async def solve_heavy_lifting(): await right_arm.run_angle(500,-90) # arm down await wait(100) await drive_base.turn(20) # turn right a little bit - #await wait(100) await right_arm.run_angle(500,140) #arm up await drive_base.turn(-20) #reset position +async def solve_who_lived_here(): await drive_base.straight(50) await drive_base.turn(-15) await drive_base.straight(50) await drive_base.turn(-25) - await drive_base.straight(-50) await drive_base.turn(-100) + +""" +Run#2.1 +- Alternate solution for Forge, Who lived here and Heavy Lifting combined +- Light Blue Key +- Different alignment +""" +async def Run2_1(): + await solve_forge_straight() + await solve_heavy_lifting() + await solve_who_lived_here() + + # return to base await drive_base.arc(-500,None,600) drive_base.stop() +async def solve_forge_straight(): + await right_arm.run_target(50,50) + await right_arm.run_angle(50,-30) + await drive_base.straight(700) + # await drive_base.turn(-30) + # await drive_base.straight(20) + await drive_base.turn(-40) + await drive_base.straight(-30) -async def Run3(): # tip the scale.py - right_arm.run_angle(500,30) - await drive_base.straight(800) - await drive_base.turn(90) - await drive_base.straight(86) - await right_arm.run_angle(800,-140) - await right_arm.run_angle(900,140) +""" +Run#3 +- Combined angler artifacts and tip the scale +- Yellow key +""" +async def Run3(): + await solve_angler_artifacts() + await solve_tip_the_scale() - await drive_base.straight(-100) - await drive_base.turn(90) - await drive_base.straight(800) - drive_base.stop() - - -async def Run4(): # From Send_Over_Final.py - - await drive_base.straight(920) - await drive_base.turn(-90,Stop.HOLD) - await drive_base.straight(65) - #Solve - drive_base.turn(-10) - await left_arm.run_angle(10000,-3000) - await drive_base.straight(-110) - await drive_base.turn(90) - + #cross over to red side await multitask( drive_forward(), monitor_distance() ) -async def Run_3_4(): #combined angler artifacts and tip the scale - experimental + +async def solve_angler_artifacts(): await drive_base.straight(920) await drive_base.turn(-90,Stop.HOLD) await drive_base.straight(65) @@ -173,9 +185,11 @@ async def Run_3_4(): #combined angler artifacts and tip the scale - experimental drive_base.turn(-10) await left_arm.run_angle(10000,-3000) await drive_base.straight(-110) + await drive_base.turn(90) await drive_base.arc(-150,-100, None) +async def solve_tip_the_scale(): await drive_base.straight(135) await right_arm.run_angle(800,-150) await right_arm.run_angle(900,150) @@ -186,27 +200,48 @@ async def Run_3_4(): #combined angler artifacts and tip the scale - experimental await drive_base.arc(10,-47, None) #await drive_base.turn(-23, Stop.COAST_SMART) - await multitask( - drive_forward(), - monitor_distance() - ) + +""" +Run #4 +- Solves the Mineshaft explorer + 2/3 Surface Brush + 1/3 Map Reveal +- Blue Key +""" +async def Run4(): + await solve_brush_reveal() + await solve_mineshaft_explorer() + + #return to base + await drive_base.straight(-875) -# Add Rishi's code here -async def Run5(): +async def solve_brush_reveal(): await drive_base.straight(700) await drive_base.turn(-20) await drive_base.straight(110) await drive_base.straight(-210) + +async def solve_mineshaft_explorer(): await drive_base.turn(63) await drive_base.straight(130) await right_arm.run_angle(1000, -90) await drive_base.straight(84) await right_arm.run_angle(300, 90) - await drive_base.straight(-875) -# Add - Adi's code here +""" +Run#5 +- Solves Salvage Operation + Statue Rebuild +- Orange Key +""" async def Run6(): + await solve_salvage_operation() + await solve_statue_rebuild() + + #return to base + await drive_base.straight(-60) + await drive_base.turn(80) + await drive_base.straight(-900) + +async def solve_salvage_operation(): await drive_base.straight(500) await right_arm.run_angle(300,500) await drive_base.straight(-75) @@ -217,6 +252,8 @@ async def Run6(): await drive_base.straight(-200) await drive_base.turn(-15) await drive_base.straight(350) + +async def solve_statue_rebuild(): await drive_base.turn(-100) await drive_base.straight(-80) await left_arm.run_angle(500, -900) @@ -224,71 +261,33 @@ async def Run6(): await drive_base.straight(50) await left_arm.run_angle(700, 250) await drive_base.turn(30) - await drive_base.straight(-60) - await drive_base.turn(80) - await drive_base.straight(-900) -async def arc_back(radius, angle): - #print(radius, angle) - drive_base.arc(radius, angle, None) - -async def lift_right_arm(): - await right_arm.run_angle(100, -90) - -# This is a refactor of Salvage operation mission without wait and realignment -async def Run6_1(): #experimental - - await drive_base.straight(500) - await right_arm.run_angle(100,90) - await drive_base.straight(-75) - - #ack back while raising arm - await multitask ( - lift_right_arm(), - arc_back(-215, -45) - ) - - #align to raise the ship - await drive_base.straight(-150) - await drive_base.turn(-45) - - #await drive_base.straight(-350) - #await wait(1000) - - #Solve ship - await drive_base.straight(800) - await drive_base.straight(-200) - await drive_base.turn(-15) - await drive_base.straight(350) - await drive_base.turn(-100) - await drive_base.straight(-80) - await left_arm.run_angle(500, -700) - await drive_base.straight(50) - await drive_base.straight(50) - await left_arm.run_angle(700, 250) - await drive_base.turn(15) - await drive_base.straight(-80) - await drive_base.turn(80) - await drive_base.straight(-900) +""" +Run#6 +- Solve 2/3 Site Markings +- Run only if have time +- Purple Key +""" +async def Run6_7(): # experiment with ferris wheel for Site Markings + solve_site_mark_1() + solve_site_mark_2() + #return to base + await drive_base.straight(-300) drive_base.stop() -async def Run6_7(): # experiment with ferris wheel for Site Markings +async def solve_site_mark_1(): await drive_base.straight(500) - await right_arm.run_angle(100, -10) await wait(50) - #await multitask ( - #lift_right_arm() - #await right_arm.run_angle(100, 10) - #await arc_back(-215, -140) await drive_base.straight(-300) await drive_base.arc(-150, -140, None) - + +async def solve_site_mark_2(): await drive_base.straight(-300) await wait(50) await right_arm.run_angle(50, 50) - #await drive_base.straight(-300) - drive_base.stop() + + # Function to classify color based on HSV def detect_color(h, s, v, reflected): @@ -323,27 +322,27 @@ async def main(): print(color) - if color == "Red": - print('Running Mission 3') - await Run2_1() #red - elif color == "Orange": - print('Running Mission 6') - await Run6_1() #orange - elif color == "Yellow": - print('Running Mission 4') - await Run_3_4() #yellow - elif color == "Green": + if color == "Green": print('Running Mission 1') - await Run1() #green - vertically - elif color == "Blue": - print('Running Mission 5') - await Run5() #blue - vertically - elif color == "Purple": + await Run1() + elif color == "Red": print('Running Mission 2') - await Run6_7() #purple - vertically + await Run2() + elif color == "Yellow": + print('Running Mission 3') + await Run3() + elif color == "Blue": + print('Running Mission 4') + await Run4() + elif color == "Orange": + print('Running Mission 5') + await Run5() + elif color == "Purple": + print('Running Mission 6') + await Run6_7() elif color == "Light_Blue": print("Running Mission 2_1") - await Run3() + await Run2_1() else: print(f"Unknown color detected (Hue: {h}, Sat: {s}, Val: {v})") await wait(10) From 8bee9efe6be06154099a2c75faab8bcface6b79e Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Thu, 4 Dec 2025 23:41:29 +0000 Subject: [PATCH 07/26] Add utils/tests/Diagnostics.py Returns all information about the robot --- utils/tests/Diagnostics.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 utils/tests/Diagnostics.py diff --git a/utils/tests/Diagnostics.py b/utils/tests/Diagnostics.py new file mode 100644 index 0000000..07d7766 --- /dev/null +++ b/utils/tests/Diagnostics.py @@ -0,0 +1,33 @@ +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,Direction.CLOCKWISE) # Specify default direction +left_arm = Motor(Port.C, Direction.CLOCKWISE) # Specify default direction +right_arm = Motor(Port.D, Direction.CLOCKWISE,[[12,36],[12,20,24]]) #Added gear train list for gear ration +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 + +if hub.battery.voltage() > 7800: + print(f"Battery voltage is sufficient: {hub.battery.voltage()}") +elif hub.battery.voltage < 7800 : + print(f"Charging needed: {hub.battery.voltage()}") + +print(hub.battery.current()) +print(hub.imu.heading()) +print(hub.system.info()) \ No newline at end of file From d507a9c2040d4a3cf98059f0293f12c00c25d18a Mon Sep 17 00:00:00 2001 From: Rishikesh Lolapu <31lolapr@elmbrookstudents.org> Date: Thu, 4 Dec 2025 23:46:26 +0000 Subject: [PATCH 08/26] Update competition_codes/sectionals/sectional_main_experimental.py --- .../sectionals/sectional_main_experimental.py | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_experimental.py index 64952ff..a078cad 100644 --- a/competition_codes/sectionals/sectional_main_experimental.py +++ b/competition_codes/sectionals/sectional_main_experimental.py @@ -207,13 +207,17 @@ Run #4 - Blue Key """ async def Run4(): - await solve_brush_reveal() - await solve_mineshaft_explorer() - - #return to base + await drive_base.straight(700) + await drive_base.turn(-20) + await drive_base.straight(110) + await drive_base.straight(-210) + await drive_base.turn(60) + await drive_base.straight(130) + await right_arm.run_angle(1000, -200) + await drive_base.straight(90) + await right_arm.run_angle(300, 200) await drive_base.straight(-875) - async def solve_brush_reveal(): await drive_base.straight(700) await drive_base.turn(-20) @@ -233,10 +237,20 @@ Run#5 - Orange Key """ async def Run6(): - await solve_salvage_operation() - await solve_statue_rebuild() - - #return to base + await drive_base.straight(550) + await right_arm.run_angle(300,100) + await drive_base.straight(-75) + await right_arm.run_angle(300, -100) + await drive_base.straight(300) + await drive_base.straight(-200) + await drive_base.turn(-15) + await drive_base.straight(350) + await drive_base.turn(-103) + await drive_base.straight(-80) + await left_arm.run_angle(500, -900) + await drive_base.straight(101) + await left_arm.run_angle(700, 285) + await drive_base.turn(30) await drive_base.straight(-60) await drive_base.turn(80) await drive_base.straight(-900) From e8607d02ae89450a0f88d837376961d38628b88b Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Fri, 5 Dec 2025 16:28:00 +0000 Subject: [PATCH 09/26] Update utils/tests/ColorSensor.py --- utils/tests/{colorsensortest.py => ColorSensor.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename utils/tests/{colorsensortest.py => ColorSensor.py} (100%) diff --git a/utils/tests/colorsensortest.py b/utils/tests/ColorSensor.py similarity index 100% rename from utils/tests/colorsensortest.py rename to utils/tests/ColorSensor.py From 6fee096cf8082d8606ad228566b3075787d3a7b0 Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Sat, 6 Dec 2025 14:26:20 +0000 Subject: [PATCH 10/26] Update competition_codes/sectionals/sectional_main_experimental.py --- competition_codes/sectionals/sectional_main_experimental.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_experimental.py index a078cad..21a9c0e 100644 --- a/competition_codes/sectionals/sectional_main_experimental.py +++ b/competition_codes/sectionals/sectional_main_experimental.py @@ -115,7 +115,7 @@ async def Run2(): async def solve_forge(): await right_arm.run_target(50,50) - await right_arm.run_angle(50,-30) + # await right_arm.run_angle(50,-30) await drive_base.arc(350,113, None) await drive_base.straight(20) From 8b2ab7b9c248c90c690bc682d2f6cfac8078562c Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:19:39 +0000 Subject: [PATCH 11/26] Upload files to "BatteryDiagnostics.py" --- BatteryDiagnostics.py/BatteryDiagnostics.py | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 BatteryDiagnostics.py/BatteryDiagnostics.py diff --git a/BatteryDiagnostics.py/BatteryDiagnostics.py b/BatteryDiagnostics.py/BatteryDiagnostics.py new file mode 100644 index 0000000..07d7766 --- /dev/null +++ b/BatteryDiagnostics.py/BatteryDiagnostics.py @@ -0,0 +1,33 @@ +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,Direction.CLOCKWISE) # Specify default direction +left_arm = Motor(Port.C, Direction.CLOCKWISE) # Specify default direction +right_arm = Motor(Port.D, Direction.CLOCKWISE,[[12,36],[12,20,24]]) #Added gear train list for gear ration +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 + +if hub.battery.voltage() > 7800: + print(f"Battery voltage is sufficient: {hub.battery.voltage()}") +elif hub.battery.voltage < 7800 : + print(f"Charging needed: {hub.battery.voltage()}") + +print(hub.battery.current()) +print(hub.imu.heading()) +print(hub.system.info()) \ No newline at end of file From ca0a9df8011789cce97000505994df211048d848 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:20:14 +0000 Subject: [PATCH 12/26] Delete BatteryDiagnostics.py/BatteryDiagnostics.py --- BatteryDiagnostics.py/BatteryDiagnostics.py | 33 --------------------- 1 file changed, 33 deletions(-) delete mode 100644 BatteryDiagnostics.py/BatteryDiagnostics.py diff --git a/BatteryDiagnostics.py/BatteryDiagnostics.py b/BatteryDiagnostics.py/BatteryDiagnostics.py deleted file mode 100644 index 07d7766..0000000 --- a/BatteryDiagnostics.py/BatteryDiagnostics.py +++ /dev/null @@ -1,33 +0,0 @@ -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,Direction.CLOCKWISE) # Specify default direction -left_arm = Motor(Port.C, Direction.CLOCKWISE) # Specify default direction -right_arm = Motor(Port.D, Direction.CLOCKWISE,[[12,36],[12,20,24]]) #Added gear train list for gear ration -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 - -if hub.battery.voltage() > 7800: - print(f"Battery voltage is sufficient: {hub.battery.voltage()}") -elif hub.battery.voltage < 7800 : - print(f"Charging needed: {hub.battery.voltage()}") - -print(hub.battery.current()) -print(hub.imu.heading()) -print(hub.system.info()) \ No newline at end of file From 1a966fd553d1166fb594c86ae515ce2c24d879c0 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:20:58 +0000 Subject: [PATCH 13/26] Upload files to "utils/tests/BatteryDiagnostics.py" --- .../BatteryDiagnostics.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py diff --git a/utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py b/utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py new file mode 100644 index 0000000..07d7766 --- /dev/null +++ b/utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py @@ -0,0 +1,33 @@ +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,Direction.CLOCKWISE) # Specify default direction +left_arm = Motor(Port.C, Direction.CLOCKWISE) # Specify default direction +right_arm = Motor(Port.D, Direction.CLOCKWISE,[[12,36],[12,20,24]]) #Added gear train list for gear ration +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 + +if hub.battery.voltage() > 7800: + print(f"Battery voltage is sufficient: {hub.battery.voltage()}") +elif hub.battery.voltage < 7800 : + print(f"Charging needed: {hub.battery.voltage()}") + +print(hub.battery.current()) +print(hub.imu.heading()) +print(hub.system.info()) \ No newline at end of file From 61d3dd3c06e0b04906455f3908928de7eae9bf62 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:21:24 +0000 Subject: [PATCH 14/26] Delete utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py --- .../BatteryDiagnostics.py | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py diff --git a/utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py b/utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py deleted file mode 100644 index 07d7766..0000000 --- a/utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py +++ /dev/null @@ -1,33 +0,0 @@ -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,Direction.CLOCKWISE) # Specify default direction -left_arm = Motor(Port.C, Direction.CLOCKWISE) # Specify default direction -right_arm = Motor(Port.D, Direction.CLOCKWISE,[[12,36],[12,20,24]]) #Added gear train list for gear ration -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 - -if hub.battery.voltage() > 7800: - print(f"Battery voltage is sufficient: {hub.battery.voltage()}") -elif hub.battery.voltage < 7800 : - print(f"Charging needed: {hub.battery.voltage()}") - -print(hub.battery.current()) -print(hub.imu.heading()) -print(hub.system.info()) \ No newline at end of file From 821924e8757f7a37f0e7f8acf370aac34fd0cd44 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:22:50 +0000 Subject: [PATCH 15/26] Upload files to "utils/tests/FullDiagnostics" --- .../FullDiagnostics/BatteryDiagnostics.py | 33 +++++++++++++++++ .../tests/FullDiagnostics/FullDiagnostics.py | 35 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 utils/tests/FullDiagnostics/BatteryDiagnostics.py create mode 100644 utils/tests/FullDiagnostics/FullDiagnostics.py diff --git a/utils/tests/FullDiagnostics/BatteryDiagnostics.py b/utils/tests/FullDiagnostics/BatteryDiagnostics.py new file mode 100644 index 0000000..07d7766 --- /dev/null +++ b/utils/tests/FullDiagnostics/BatteryDiagnostics.py @@ -0,0 +1,33 @@ +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,Direction.CLOCKWISE) # Specify default direction +left_arm = Motor(Port.C, Direction.CLOCKWISE) # Specify default direction +right_arm = Motor(Port.D, Direction.CLOCKWISE,[[12,36],[12,20,24]]) #Added gear train list for gear ration +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 + +if hub.battery.voltage() > 7800: + print(f"Battery voltage is sufficient: {hub.battery.voltage()}") +elif hub.battery.voltage < 7800 : + print(f"Charging needed: {hub.battery.voltage()}") + +print(hub.battery.current()) +print(hub.imu.heading()) +print(hub.system.info()) \ No newline at end of file diff --git a/utils/tests/FullDiagnostics/FullDiagnostics.py b/utils/tests/FullDiagnostics/FullDiagnostics.py new file mode 100644 index 0000000..af8a6b0 --- /dev/null +++ b/utils/tests/FullDiagnostics/FullDiagnostics.py @@ -0,0 +1,35 @@ +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() +from BatteryDiagnostics import BatteryDiagnostics +battery = BatteryDiagnostics() +clearConfirmation = input("Do you want to clear the console before proceeding? Y/N (default: yes): ") +if(clearConfirmation == "Y" or clearConfirmation == "y" or clearConfirmation == "yes" or clearConfirmation == ""): + print("Clearing console... \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") + +while True: + print("\nWhat diagnostic do you want to perform?") + print("Enter 'b' for Battery diagnostics") + print("Enter 'm' for Motor diagnostics") + print("Enter 'q' to Quit") + + choice = input("Your choice: ").strip().lower() + + if choice == "b": + print("-----------------------BATTERY DIAGNOSTICS-----------------------") + battery.printAll() + + elif choice == "m": + print("------------------------MOTOR DIAGNOSTICS------------------------") + # motor.printAll() # call your motor diagnostics here + print("Motor diagnostics would run here.") + + elif choice == "q": + print("Diagnostics completed successfully. Exiting with code 0. Good luck in the robot game!") + break + + else: + print("Invalid choice. Please enter 'b', 'm', or 'q'.") \ No newline at end of file From 1db4458e164fa644535d639109ac908ec6eb3a58 Mon Sep 17 00:00:00 2001 From: Atharv Nagavarapu <30nagava@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:44:20 +0000 Subject: [PATCH 16/26] Delete utils/tests/FullDiagnostics/BatteryDiagnostics.py --- .../FullDiagnostics/BatteryDiagnostics.py | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 utils/tests/FullDiagnostics/BatteryDiagnostics.py diff --git a/utils/tests/FullDiagnostics/BatteryDiagnostics.py b/utils/tests/FullDiagnostics/BatteryDiagnostics.py deleted file mode 100644 index 07d7766..0000000 --- a/utils/tests/FullDiagnostics/BatteryDiagnostics.py +++ /dev/null @@ -1,33 +0,0 @@ -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,Direction.CLOCKWISE) # Specify default direction -left_arm = Motor(Port.C, Direction.CLOCKWISE) # Specify default direction -right_arm = Motor(Port.D, Direction.CLOCKWISE,[[12,36],[12,20,24]]) #Added gear train list for gear ration -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 - -if hub.battery.voltage() > 7800: - print(f"Battery voltage is sufficient: {hub.battery.voltage()}") -elif hub.battery.voltage < 7800 : - print(f"Charging needed: {hub.battery.voltage()}") - -print(hub.battery.current()) -print(hub.imu.heading()) -print(hub.system.info()) \ No newline at end of file From 63d4b27648b20a5d5f5e3c8ddc58dfccde53b93d Mon Sep 17 00:00:00 2001 From: Atharv Nagavarapu <30nagava@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:44:25 +0000 Subject: [PATCH 17/26] Delete utils/tests/FullDiagnostics/FullDiagnostics.py --- .../tests/FullDiagnostics/FullDiagnostics.py | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 utils/tests/FullDiagnostics/FullDiagnostics.py diff --git a/utils/tests/FullDiagnostics/FullDiagnostics.py b/utils/tests/FullDiagnostics/FullDiagnostics.py deleted file mode 100644 index af8a6b0..0000000 --- a/utils/tests/FullDiagnostics/FullDiagnostics.py +++ /dev/null @@ -1,35 +0,0 @@ -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() -from BatteryDiagnostics import BatteryDiagnostics -battery = BatteryDiagnostics() -clearConfirmation = input("Do you want to clear the console before proceeding? Y/N (default: yes): ") -if(clearConfirmation == "Y" or clearConfirmation == "y" or clearConfirmation == "yes" or clearConfirmation == ""): - print("Clearing console... \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") - -while True: - print("\nWhat diagnostic do you want to perform?") - print("Enter 'b' for Battery diagnostics") - print("Enter 'm' for Motor diagnostics") - print("Enter 'q' to Quit") - - choice = input("Your choice: ").strip().lower() - - if choice == "b": - print("-----------------------BATTERY DIAGNOSTICS-----------------------") - battery.printAll() - - elif choice == "m": - print("------------------------MOTOR DIAGNOSTICS------------------------") - # motor.printAll() # call your motor diagnostics here - print("Motor diagnostics would run here.") - - elif choice == "q": - print("Diagnostics completed successfully. Exiting with code 0. Good luck in the robot game!") - break - - else: - print("Invalid choice. Please enter 'b', 'm', or 'q'.") \ No newline at end of file From f926fbba795e13651a3a1127712690464f77ba4f Mon Sep 17 00:00:00 2001 From: Atharv Nagavarapu <30nagava@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:45:31 +0000 Subject: [PATCH 18/26] Delete utils/tests/ColorSensor.py --- utils/tests/ColorSensor.py | 69 -------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 utils/tests/ColorSensor.py diff --git a/utils/tests/ColorSensor.py b/utils/tests/ColorSensor.py deleted file mode 100644 index 3d5a8d9..0000000 --- a/utils/tests/ColorSensor.py +++ /dev/null @@ -1,69 +0,0 @@ -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() - -color_sensor = ColorSensor(Port.F) - -# Color Settings -# https://docs.pybricks.com/en/latest/parameters/color.html -print("Default Detected Colors:", color_sensor.detectable_colors()) - -# Custom color Hue, Saturation, Brightness value for Lego bricks -Color.MAGENTA = Color(315,100,60) -Color.BLUE = Color(240,100,100) -Color.CYAN = Color(180,100,100) -Color.RED = Color(350, 100, 100) -LEGO_BRICKS_COLOR = [ - Color.BLUE, - Color.GREEN, - Color.WHITE, - Color.RED, - Color.YELLOW, - Color.MAGENTA, - Color.NONE -] -magenta_counter = 0 -stable_color = None -real_color = None -#Update Detectable colors -color_sensor.detectable_colors(LEGO_BRICKS_COLOR) -print(f'Yellow:{Color.YELLOW} : {Color.YELLOW.h}, {Color.YELLOW.s}, {Color.YELLOW.v}') -print("Updated Detected Colors:", color_sensor.detectable_colors()) -async def main(): - while True: - global magenta_counter, stable_color, real_color - color_reflected_percent = await color_sensor.reflection() - print("Reflection: ", color_reflected_percent) - if color_reflected_percent > 15: - color_detected = await color_sensor.color() - - if color_detected == Color.MAGENTA: - magenta_counter += 1 - else: - magenta_counter = 0 - stable_color = color_detected - - # Only accept magenta if it's been stable for a while - usually triggers before other colors so we gotta do this :| - if magenta_counter > 10: - stable_color = Color.MAGENTA - if stable_color != Color.MAGENTA: - stable_color = await color_sensor.color() - - real_color = stable_color - #if(color_detected != Color.NONE): - # return - - print("Magenta counter: ", magenta_counter) - if real_color is not None: - print(f'Detected color: {real_color} : {real_color.h}, {real_color.s}, {real_color.v}') - else: - print("No valid color detected yet.") - await wait(50) - -run_task(main()) \ No newline at end of file From 42ceb9f38e4ef88eb1b5d6edcb79df04558412cb Mon Sep 17 00:00:00 2001 From: Atharv Nagavarapu <30nagava@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:45:34 +0000 Subject: [PATCH 19/26] Delete utils/tests/Diagnostics.py --- utils/tests/Diagnostics.py | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 utils/tests/Diagnostics.py diff --git a/utils/tests/Diagnostics.py b/utils/tests/Diagnostics.py deleted file mode 100644 index 07d7766..0000000 --- a/utils/tests/Diagnostics.py +++ /dev/null @@ -1,33 +0,0 @@ -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,Direction.CLOCKWISE) # Specify default direction -left_arm = Motor(Port.C, Direction.CLOCKWISE) # Specify default direction -right_arm = Motor(Port.D, Direction.CLOCKWISE,[[12,36],[12,20,24]]) #Added gear train list for gear ration -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 - -if hub.battery.voltage() > 7800: - print(f"Battery voltage is sufficient: {hub.battery.voltage()}") -elif hub.battery.voltage < 7800 : - print(f"Charging needed: {hub.battery.voltage()}") - -print(hub.battery.current()) -print(hub.imu.heading()) -print(hub.system.info()) \ No newline at end of file From 59a4c42060fa8ea92f78caea146c2d416d1b75c8 Mon Sep 17 00:00:00 2001 From: Rishikesh Lolapu <31lolapr@elmbrookstudents.org> Date: Sat, 6 Dec 2025 17:47:05 +0000 Subject: [PATCH 20/26] Update competition_codes/sectionals/sectional_main_experimental.py --- .../sectionals/sectional_main_experimental.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_experimental.py index 21a9c0e..5ed26d2 100644 --- a/competition_codes/sectionals/sectional_main_experimental.py +++ b/competition_codes/sectionals/sectional_main_experimental.py @@ -208,14 +208,14 @@ Run #4 """ async def Run4(): await drive_base.straight(700) - await drive_base.turn(-20) - await drive_base.straight(110) + await drive_base.turn(-18) + await drive_base.straight(120) await drive_base.straight(-210) - await drive_base.turn(60) - await drive_base.straight(130) - await right_arm.run_angle(1000, -200) + await drive_base.turn(61) + await drive_base.straight(133) + await right_arm.run_angle(400, -200) await drive_base.straight(90) - await right_arm.run_angle(300, 200) + await right_arm.run_angle(100, 95) await drive_base.straight(-875) async def solve_brush_reveal(): @@ -248,7 +248,7 @@ async def Run6(): await drive_base.turn(-103) await drive_base.straight(-80) await left_arm.run_angle(500, -900) - await drive_base.straight(101) + await drive_base.straight(105) await left_arm.run_angle(700, 285) await drive_base.turn(30) await drive_base.straight(-60) From ddc0f2ccca79cf3da96168d3899fe712a9690310 Mon Sep 17 00:00:00 2001 From: Rishikesh Lolapu <31lolapr@elmbrookstudents.org> Date: Sat, 6 Dec 2025 18:01:47 +0000 Subject: [PATCH 21/26] Update competition_codes/sectionals/sectional_main_dec_6.py --- .../{sectional_main_experimental.py => sectional_main_dec_6.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename competition_codes/sectionals/{sectional_main_experimental.py => sectional_main_dec_6.py} (99%) diff --git a/competition_codes/sectionals/sectional_main_experimental.py b/competition_codes/sectionals/sectional_main_dec_6.py similarity index 99% rename from competition_codes/sectionals/sectional_main_experimental.py rename to competition_codes/sectionals/sectional_main_dec_6.py index 5ed26d2..c0a04f1 100644 --- a/competition_codes/sectionals/sectional_main_experimental.py +++ b/competition_codes/sectionals/sectional_main_dec_6.py @@ -236,7 +236,7 @@ Run#5 - Solves Salvage Operation + Statue Rebuild - Orange Key """ -async def Run6(): +async def Run5(): await drive_base.straight(550) await right_arm.run_angle(300,100) await drive_base.straight(-75) From f1f800783f183df043019b7269797434d8e54592 Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Sat, 6 Dec 2025 20:16:37 +0000 Subject: [PATCH 22/26] Update competition_codes/sectionals/sectional_main_dec_6.py Updates for gear ratio change --- competition_codes/sectionals/sectional_main_dec_6.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_dec_6.py b/competition_codes/sectionals/sectional_main_dec_6.py index c0a04f1..7aeacff 100644 --- a/competition_codes/sectionals/sectional_main_dec_6.py +++ b/competition_codes/sectionals/sectional_main_dec_6.py @@ -123,10 +123,10 @@ async def solve_forge(): await drive_base.straight(-47) async def solve_heavy_lifting(): - await right_arm.run_angle(500,-90) # arm down + await right_arm.run_angle(500,-160) # arm down await wait(100) await drive_base.turn(20) # turn right a little bit - await right_arm.run_angle(500,140) #arm up + await right_arm.run_angle(500,160) #arm up await drive_base.turn(-20) #reset position async def solve_who_lived_here(): From 27e1e2f7514e35528886d8fb5b04b95cb85e41fd Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Sat, 6 Dec 2025 20:35:00 +0000 Subject: [PATCH 23/26] Update competition_codes/sectionals/sectional_main_dec_6.py --- competition_codes/sectionals/sectional_main_dec_6.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_dec_6.py b/competition_codes/sectionals/sectional_main_dec_6.py index 7aeacff..c5f74ff 100644 --- a/competition_codes/sectionals/sectional_main_dec_6.py +++ b/competition_codes/sectionals/sectional_main_dec_6.py @@ -176,9 +176,8 @@ async def Run3(): monitor_distance() ) - async def solve_angler_artifacts(): - await drive_base.straight(920) + await drive_base.straight(940) await drive_base.turn(-90,Stop.HOLD) await drive_base.straight(65) #Solve @@ -187,20 +186,23 @@ async def solve_angler_artifacts(): await drive_base.straight(-110) await drive_base.turn(90) - await drive_base.arc(-150,-100, None) + await drive_base.arc(-150,-103, None) async def solve_tip_the_scale(): - await drive_base.straight(135) + await drive_base.turn(3) + await drive_base.straight(142.5) await right_arm.run_angle(800,-150) await right_arm.run_angle(900,150) await drive_base.straight(-100) await drive_base.turn(-65) - await drive_base.straight(320,Stop.COAST_SMART) + await drive_base.straight(300,Stop.COAST_SMART) await drive_base.arc(10,-47, None) #await drive_base.turn(-23, Stop.COAST_SMART) + + """ Run #4 - Solves the Mineshaft explorer + 2/3 Surface Brush + 1/3 Map Reveal From f838d6b5664e2d57cff84b23992248177e313422 Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Sat, 6 Dec 2025 20:36:10 +0000 Subject: [PATCH 24/26] Update competition_codes/sectionals/sectional_main_dec_6.py --- competition_codes/sectionals/sectional_main_dec_6.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/competition_codes/sectionals/sectional_main_dec_6.py b/competition_codes/sectionals/sectional_main_dec_6.py index c5f74ff..9236075 100644 --- a/competition_codes/sectionals/sectional_main_dec_6.py +++ b/competition_codes/sectionals/sectional_main_dec_6.py @@ -203,6 +203,8 @@ async def solve_tip_the_scale(): + + """ Run #4 - Solves the Mineshaft explorer + 2/3 Surface Brush + 1/3 Map Reveal From a0bec55e97a108b1e459e59fc5d4ffb9ca543776 Mon Sep 17 00:00:00 2001 From: Rishikesh Lolapu <31lolapr@elmbrookstudents.org> Date: Sun, 7 Dec 2025 21:10:25 +0000 Subject: [PATCH 25/26] Update competition_codes/sectionals/sectional_main_dec_6.py --- .../sectionals/sectional_main_dec_6.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_dec_6.py b/competition_codes/sectionals/sectional_main_dec_6.py index 9236075..e671f6c 100644 --- a/competition_codes/sectionals/sectional_main_dec_6.py +++ b/competition_codes/sectionals/sectional_main_dec_6.py @@ -252,12 +252,13 @@ async def Run5(): await drive_base.turn(-103) await drive_base.straight(-80) await left_arm.run_angle(500, -900) - await drive_base.straight(105) - await left_arm.run_angle(700, 285) - await drive_base.turn(30) - await drive_base.straight(-60) - await drive_base.turn(80) - await drive_base.straight(-900) + await drive_base.straight(120) + await drive_base.turn(10) + await left_arm.run_angle(700, 290) + await drive_base.turn(20) + await drive_base.straight(-100) + await drive_base.turn(-120) + await drive_base.straight(900) async def solve_salvage_operation(): await drive_base.straight(500) From 4f21cdc99ca88dd552ed64d74ca96802d8235707 Mon Sep 17 00:00:00 2001 From: nifrali Date: Mon, 8 Dec 2025 00:05:09 +0000 Subject: [PATCH 26/26] Update competition_codes/sectionals/sectional_main_dec_6.py Updated values --- .../sectionals/sectional_main_dec_6.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/competition_codes/sectionals/sectional_main_dec_6.py b/competition_codes/sectionals/sectional_main_dec_6.py index e671f6c..5a4bc39 100644 --- a/competition_codes/sectionals/sectional_main_dec_6.py +++ b/competition_codes/sectionals/sectional_main_dec_6.py @@ -248,17 +248,20 @@ async def Run5(): await drive_base.straight(300) await drive_base.straight(-200) await drive_base.turn(-15) + #solving statue await drive_base.straight(350) - await drive_base.turn(-103) + await drive_base.turn(-104) await drive_base.straight(-80) await left_arm.run_angle(500, -900) await drive_base.straight(120) - await drive_base.turn(10) - await left_arm.run_angle(700, 290) - await drive_base.turn(20) + await drive_base.turn(5) + await left_arm.run_angle(500, 290) + await drive_base.turn(18) await drive_base.straight(-100) - await drive_base.turn(-120) + await drive_base.turn(-90) await drive_base.straight(900) + drive_base.stop() + async def solve_salvage_operation(): await drive_base.straight(500)