Compare commits

...

133 Commits

Author SHA1 Message Date
36fb4d94a3 Merge pull request 'Update competition_codes/sectionals/mukwonago_sectionals_final.py' (#55) from dev into main
Reviewed-on: #55
2025-12-09 18:26:13 +00:00
3014305d69 Update competition_codes/sectionals/mukwonago_sectionals_final.py
Fixed return
2025-12-09 17:34:12 +00:00
68d8b346c7 Merge pull request 'Update README.md' (#54) from dev into main
Reviewed-on: #54
2025-12-08 19:18:47 +00:00
f38a3cc625 Update README.md 2025-12-08 19:18:33 +00:00
cfe7b96be5 Merge pull request 'dev' (#53) from dev into main
Reviewed-on: #53
2025-12-08 19:16:23 +00:00
5a805e75fc Update README.md 2025-12-08 19:16:10 +00:00
4d94a35503 Update competition_codes/sectionals/mukwonago_sectionals_final.py 2025-12-08 19:15:10 +00:00
09490f4e3e Merge pull request 'dev' (#52) from dev into main
Reviewed-on: #52
2025-12-08 19:13:47 +00:00
4539ee361f Update README.md 2025-12-08 19:13:17 +00:00
288c4eac26 Update README.md 2025-12-08 17:29:02 +00:00
c2e8ad028a Merge pull request 'dev' (#51) from dev into main
Reviewed-on: #51
2025-12-08 16:55:06 +00:00
4f21cdc99c Update competition_codes/sectionals/sectional_main_dec_6.py
Updated values
2025-12-08 00:05:09 +00:00
a0bec55e97 Update competition_codes/sectionals/sectional_main_dec_6.py 2025-12-07 21:10:25 +00:00
f838d6b566 Update competition_codes/sectionals/sectional_main_dec_6.py 2025-12-06 20:36:10 +00:00
27e1e2f751 Update competition_codes/sectionals/sectional_main_dec_6.py 2025-12-06 20:35:00 +00:00
f1f800783f Update competition_codes/sectionals/sectional_main_dec_6.py
Updates for gear ratio change
2025-12-06 20:16:37 +00:00
d0225f0417 Merge pull request 'Update competition_codes/sectionals/sectional_main_dec_6.py' (#50) from Rishi_dev into dev
Reviewed-on: #50
2025-12-06 20:09:25 +00:00
ddc0f2ccca Update competition_codes/sectionals/sectional_main_dec_6.py 2025-12-06 18:01:47 +00:00
61d1cf709c Merge pull request 'Rishi_dev' (#49) from Rishi_dev into dev
Reviewed-on: #49
2025-12-06 17:48:09 +00:00
59a4c42060 Update competition_codes/sectionals/sectional_main_experimental.py 2025-12-06 17:47:05 +00:00
0247088be2 Merge pull request 'dev' (#48) from dev into Rishi_dev
Reviewed-on: #48
2025-12-06 17:46:32 +00:00
42ceb9f38e Delete utils/tests/Diagnostics.py 2025-12-06 17:45:34 +00:00
f926fbba79 Delete utils/tests/ColorSensor.py 2025-12-06 17:45:31 +00:00
63d4b27648 Delete utils/tests/FullDiagnostics/FullDiagnostics.py 2025-12-06 17:44:25 +00:00
1db4458e16 Delete utils/tests/FullDiagnostics/BatteryDiagnostics.py 2025-12-06 17:44:20 +00:00
821924e875 Upload files to "utils/tests/FullDiagnostics" 2025-12-06 17:22:50 +00:00
61d3dd3c06 Delete utils/tests/BatteryDiagnostics.py/BatteryDiagnostics.py 2025-12-06 17:21:24 +00:00
1a966fd553 Upload files to "utils/tests/BatteryDiagnostics.py" 2025-12-06 17:20:58 +00:00
ca0a9df801 Delete BatteryDiagnostics.py/BatteryDiagnostics.py 2025-12-06 17:20:14 +00:00
8b2ab7b9c2 Upload files to "BatteryDiagnostics.py" 2025-12-06 17:19:39 +00:00
6fee096cf8 Update competition_codes/sectionals/sectional_main_experimental.py 2025-12-06 14:26:20 +00:00
e8607d02ae Update utils/tests/ColorSensor.py 2025-12-05 16:28:00 +00:00
d507a9c204 Update competition_codes/sectionals/sectional_main_experimental.py 2025-12-04 23:46:26 +00:00
8bee9efe6b Add utils/tests/Diagnostics.py
Returns all information about the robot
2025-12-04 23:41:29 +00:00
d235d602ce Update competition_codes/sectionals/sectional_main_experimental.py 2025-12-04 23:33:57 +00:00
e8c25a4e90 Update competition_codes/sectionals/sectional_main_experimental.py 2025-12-04 03:01:19 +00:00
f389ff7101 Update competition_codes/sectionals/sectional_main_experimental.py 2025-12-04 01:46:03 +00:00
51f4d4237c Merge pull request 'atharv-dev' (#47) from atharv-dev into dev
Reviewed-on: #47
2025-11-25 23:11:26 +00:00
489ff94601 Update competition_codes/sectionals/sectional_main_experimental.py 2025-11-25 20:27:57 +00:00
05be290f90 Update competition_codes/sectionals/sectional_main_experimental.py 2025-11-25 20:23:48 +00:00
d4e44bb53f Merge pull request 'for-sectionals/experimental' (#46) from for-sectionals/experimental into atharv-dev
Reviewed-on: #46
2025-11-25 20:21:38 +00:00
751e008854 Experimentals 2025-11-25 13:17:33 -06:00
7d168ff378 Merge pull request 'RegionalFinal.py' (#45) from dev into main
Reviewed-on: #45
2025-11-18 00:50:19 +00:00
d5e9a97fc6 RegionalFinal.py
This is the final code. If changes are needed, please contact (31lolapr@elmbrookstudents.org).
2025-11-15 17:13:26 +00:00
913e12f122 Merge pull request 'dev' (#44) from dev into main
Reviewed-on: #44
2025-11-12 01:22:35 +00:00
9e429cf8f1 Update README.md 2025-11-12 01:15:22 +00:00
eae9c77bcf Update README.md 2025-11-12 01:14:40 +00:00
73ca30ed4c Delete commit-graphnew.html 2025-11-12 01:13:09 +00:00
b08d80b4b6 Delete graph.txt 2025-11-12 01:13:04 +00:00
7047a0d227 Delete commit-graph.html 2025-11-12 01:12:58 +00:00
e254c65c56 Merge pull request 'Update missions/tip the scale.py' (#43) from parthiv-dev into dev
Reviewed-on: #43
2025-11-12 01:12:37 +00:00
b3ec4861c7 Merge pull request 'Add codes_for_scrimmage/regional-final/Final_combined.py' (#42) from Rishi_dev into dev
Reviewed-on: #42
2025-11-12 01:12:07 +00:00
alkadienePhoton
9f5a41eace Merge branch 'dev' of https://codes.fll-65266.org/FLL_65266_LEGO_DYNAMICS/solutions_season_unearthed into dev
Works
2025-11-11 19:11:13 -06:00
alkadienePhoton
686875a066 Fixed conflicts 2025-11-11 19:10:54 -06:00
alkadienePhoton
6d54f9c2d7 Fixed conflicts 2025-11-11 19:10:21 -06:00
10960a8473 Add codes_for_scrimmage/regional-final/Final_combined.py 2025-11-12 01:06:33 +00:00
19f79b91d1 Update utils/FINAL_STARTER_BLANK_CODE.py 2025-11-12 00:37:21 +00:00
1c0896cbeb Add utils/FINAL_STARTER_BLANK_CODE.py
ayaan is SO ANNOYING BRO
2025-11-12 00:31:22 +00:00
d2738e2615 Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-09 22:26:09 +00:00
1ee90ac2e1 Update missions/M8_5.py 2025-11-09 22:16:39 +00:00
a8d8f5c8e0 Update missions/tip the scale.py 2025-11-09 22:03:29 +00:00
31f482f576 Update LINEUPS.md 2025-11-09 01:52:54 +00:00
30a5392e56 Update LINEUPS.md 2025-11-09 01:20:19 +00:00
3b22d28e98 Update LINEUPS.md 2025-11-09 01:12:56 +00:00
alkadienePhoton
9cdb70dd80 Merging with actual stuff fixed #2 2025-11-08 17:51:13 -06:00
alkadienePhoton
c3c875e80e Merging with actual stuff fixed 2025-11-08 17:50:29 -06:00
alkadienePhoton
809789837d Merging 2025-11-08 17:48:31 -06:00
39bfe7b307 Merge pull request 'parthiv-dev' (#39) from parthiv-dev into dev
Reviewed-on: #39
2025-11-08 23:45:13 +00:00
alkadienePhoton
80d6300fc0 Merge branch 'dev' of https://codes.fll-65266.org/FLL_65266_LEGO_DYNAMICS/solutions_season_unearthed into dev
merging dev
2025-11-08 17:43:45 -06:00
alkadienePhoton
b25a2a5feb Merge branch 'Vickram_dev_' into dev
Merging Vickram_dev_ into dev
2025-11-08 17:40:27 -06:00
2d614c0e38 Update LINEUPS.md
well now we have 5 missions?
2025-11-08 22:25:56 +00:00
c7801d17c0 Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-07 23:14:24 +00:00
6e82f4d476 Add missions/New_MapReveal/New_MapReveal_Mineshaft.py
Rishi's updated code
2025-11-07 23:12:55 +00:00
0c4335993a Update missions/tip the scale.py 2025-11-07 23:12:43 +00:00
ff6100a964 changed values to make it work. 2025-11-07 22:52:30 +00:00
974f87c4c4 Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-06 01:53:13 +00:00
a50b0cd1d7 Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-06 01:50:26 +00:00
16e96693cc Update utils/tests/colorsensortest.py 2025-11-06 01:47:54 +00:00
acc44dac22 Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-06 01:44:09 +00:00
411f46d55e Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-06 01:36:51 +00:00
69745c053f Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-06 01:26:47 +00:00
214ea1c22e Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-06 01:24:47 +00:00
074703af1a Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-06 01:24:37 +00:00
9061eef311 Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-06 01:12:19 +00:00
e924043945 Upload files to "utils/tests" 2025-11-06 01:11:00 +00:00
94043eb522 Merge pull request 'Update missions/Boat.py' (#37) from Rishi_dev into dev
Reviewed-on: #37
2025-11-06 01:08:48 +00:00
a690350d1d Update missions/Send_Over_Final.py 2025-11-06 01:08:31 +00:00
8d4b296331 Delete missions/mission_09_old.py 2025-11-06 01:08:04 +00:00
73553b0964 Delete missions/Send_Over.py 2025-11-06 01:07:19 +00:00
b1f378eae7 Delete missions/Sand Mission.py 2025-11-06 01:06:43 +00:00
439aca673f Delete missions/Lift2.py 2025-11-06 01:06:28 +00:00
4b7491637d Delete missions/Lift.py 2025-11-06 01:06:20 +00:00
9ca07a36a8 Update missions/Boat.py 2025-11-06 01:06:09 +00:00
6c6b7f1f02 Delete missions/Heavy_lifting_final.py 2025-11-06 01:06:05 +00:00
b97dcf6837 Delete missions/Heavy lifting.py 2025-11-06 01:05:57 +00:00
eea26150f9 Upload files to "missions" 2025-11-06 01:05:24 +00:00
d056255994 Delete missions/Boat.py 2025-11-06 01:04:37 +00:00
5f0ffea7bc Delete missions/Boat_mission.py 2025-11-06 01:04:31 +00:00
9a573c4eb2 Delete missions/Bautism.py 2025-11-06 01:03:46 +00:00
a0a4fa4792 Merge pull request 'Rishi_dev' (#36) from Rishi_dev into dev
Reviewed-on: #36
2025-11-06 01:01:39 +00:00
14bc8d291a Add missions/Hypo.py 2025-11-06 00:58:52 +00:00
b91e701f4c Upload files to "missions"
from risshi ramdom ahhhh repo
2025-11-06 00:03:28 +00:00
debbc4e4d0 Delete missions/Set2.py 2025-11-06 00:03:03 +00:00
0c7633d92d Update missions/M8_5.py 2025-11-04 18:21:26 +00:00
3b81a3ff2b Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-04 02:57:00 +00:00
401033b185 Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-04 01:18:44 +00:00
9cdd9886e3 Update codes_for_scrimmage/hazmat/HazmatCodeChanges.py 2025-11-04 01:15:50 +00:00
3a45721812 Update codes_for_scrimmage/hazmat/mainhazmatUPD.py 2025-11-04 01:10:02 +00:00
a65ad1470c Update README.md 2025-10-31 16:09:41 +00:00
d1eb92cf25 Merge pull request 'dev' (#35) from dev into main
Reviewed-on: #35
2025-10-31 11:58:01 +00:00
b36a9f3355 Merge pull request 'dev' (#34) from dev into Rishi_dev
Reviewed-on: #34
2025-10-31 11:57:36 +00:00
21e8bd68c2 Merge pull request 'dev' (#33) from dev into Johannes_Dev
Reviewed-on: #33
2025-10-31 11:57:09 +00:00
b4385dcecd Merge pull request 'dev' (#32) from dev into atharv-dev
Reviewed-on: #32
2025-10-31 11:56:39 +00:00
7e1d310e24 New rishi code 2025-10-31 00:29:07 +00:00
37b025088f Merge pull request 'dev' (#30) from dev into Vickram_dev_
Reviewed-on: #30
2025-10-31 00:27:53 +00:00
e785a8ad05 Delete HEAVY_LIFTING_UPD
we dont need it it is alr in missions/
2025-10-30 15:42:53 +00:00
a6bbba9419 Update README.md 2025-10-30 15:42:31 +00:00
8ccf8b9a5a Update README.md 2025-10-30 12:21:46 +00:00
bb95852bf1 Update README.md 2025-10-28 18:22:25 +00:00
9ca160a8c7 Update README.md 2025-10-28 18:11:19 +00:00
882ba3e13a Delete Screenshot 2025-10-28 1.06.30 PM.png 2025-10-28 18:07:08 +00:00
33b926cb1f Upload files to "/" 2025-10-28 18:06:44 +00:00
4ff5de480d Update README.md 2025-10-28 18:06:09 +00:00
aa062122de Merge pull request 'main' (#29) from main into dev
Reviewed-on: #29
2025-10-28 12:23:07 +00:00
0fbb38baeb Merge pull request 'dev' (#28) from dev into main
Reviewed-on: #28
2025-10-27 12:23:13 +00:00
3e1928fcad Merge pull request 'Update missions/tip the scale.py' (#27) from ayaan_dev into dev
Reviewed-on: #27
2025-10-27 12:22:25 +00:00
1dec912abb Update missions/tip the scale.py 2025-10-24 00:11:38 +00:00
d3294bcb0b SCRIMMAGE MERGE!!!
Reviewed-on: #15
yayyyyyyyyyy
2025-10-11 02:30:26 +00:00
5ba2811af3 Merge pull request 'Updated LICENSE and README' (#12) from dev into main
Reviewed-on: #12
2025-10-09 21:16:08 +00:00
387e00b5c3 Merge branch 'dev' 2025-10-09 13:00:26 -05:00
3fdd6ae9d1 Merge to main for Scrimmage 2025-10-09 12:01:36 -05:00
ee0b8eb6a0 Update README.md 2025-09-10 13:28:54 +00:00
a745ed8c79 Merge pull request 'WIP - Test Merge ( dev to main )' (#1) from dev into main
Reviewed-on: #1
2025-09-02 02:32:19 +00:00
28 changed files with 1140 additions and 535 deletions

View File

@@ -1,33 +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
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():
await drive_base.straight(200)
await drive_base.turn(-20)
await drive_base.straight(536)
await drive_base.turn(60, Stop.HOLD)
await drive_base.straight(30)
await right_arm.run_angle(5000,3000)
await drive_base.straight(40)
await right_arm.run_angle(5000,-4000)
await drive_base.straight(-60)
await drive_base.turn(-60)
await drive_base.straight(-670)
run_task(main())

View File

@@ -2,14 +2,14 @@
## These are the line-up positions for the robot game for various missions. ## These are the line-up positions for the robot game for various missions.
- Mission Run #1 (Mission #1) [Right/Blue Home] - The left yellow part of the right arm attachment is positioned with its right edge on the 5th thin line from the left. Note that this is NOT positioned from the back of the robot. - Mission Run #1 (Run #1) [Right/Blue Home] - The left yellow part of the right arm attachment is positioned with its right edge on the 5th thin line from the left. Note that this is NOT positioned from the back of the robot. Also, when counting these lines, make sure you count from the inside curve, not the outside.
- Mission Run #2 (Send Over) [Right/Blue Home] - The robot should be lined up on the vertical edge of the left home. The robot's right side should be positioned on the 1st thin line from the top. Note that the 0th line is the one that is not part of the curve. <img src="https://codes.fll-65266.org/FLL_65266_LEGO_DYNAMICS/solutions_season_unearthed/raw/branch/do-not-merge/r1l.png" alt="Alt text" width="300"/>
- Mission Run #3 (Sand mission) [Right/Blue Home] - The robot should be lined up on the vertical edge of the left home. The robot's left side should be positioned on the 1/2th thin line from the bottom. - Mission Run #2 (Tip the scales) [Right/Blue Home] - The middle of the left edge of the robot should be positioned on the 2nd thick line from the left.
- Mission Run #4 (Boat mission) [Left/Red Home] - The robot should be lined up on the vertical edge of the left home. The robot's right side should be positioned on the 2nd thick line from the bottom. - Mission Run #3 (Send Over) [Right/Blue Home] - The robot should be lined up on the vertical edge of the right home. The robot's right edge should be positioned on the 1st thin line from the top. Note that the 0th line is the one that is in the inner curve.
- Mission Run #5 (Bautism) [Left/Red Home] - The robot's left edge should be positioned at the 1st thick, 2nd thin line from the left. - Mission Run #4 (Run #4) [Left/Red Home] - The robot's left edge should be positioned on the 2nd thick line from the left.
- Mission Run #6 (Not-so-heavy Lifting) [Right/Blue Home] - The robot's right edge should be positioned at the 1st thick from the right. - Mission Run #5 (Boat mission) [Left/Red Home] - There are two alignments for this. When sending off the robot for part 1, the robot should be facing the right home. It's right edge should be positioned at the very bottom edge of the board. Once it completes the pulling part, once it comes back begin part 2. For part 2, the middle of the robot's right side should be positioned in the middle of the 3rd thick and the 3rd thick, 1st thin lines from the top. For both runs the robot should be facing the blue home.

View File

@@ -14,7 +14,7 @@
## Project Overview ## Project Overview
Welcome to the official code repository for **Team 65266 Lego Dynamics**! This repository contains all the Pybricks code powering our robot through the UNEARTHED season missions. Our modular approach allows for flexible mission execution and quick color-sensor-based run selection. Welcome to the official code repository for **Team 65266 - Lego Dynamics**! This repository contains all the Pybricks code powering our robot through the UNEARTHED season missions. Our modular approach allows for flexible mission execution and quick color-sensor-based run selection.
--- ---
@@ -26,8 +26,8 @@ Welcome to the official code repository for **Team 65266 Lego Dynamics**! This r
|-----------|--------------| |-----------|--------------|
| **Robot Name** | Optimus Prime III | | **Robot Name** | Optimus Prime III |
| **Firmware** | Pybricks | | **Firmware** | Pybricks |
| **Attachment Motors** | 2× Large Motors (Ports C & D) | | **Attachment Motors** | 2x Large Motors (Ports C & D) |
| **Drive Motors** | 2× Small Motors (Ports A & B) | | **Drive Motors** | 2x Small Motors (Ports A & B) |
| **Sensors** | Up-facing Color Sensor (Quick Start) | | **Sensors** | Up-facing Color Sensor (Quick Start) |
| **Attachments** | Multiple mission-specific tools | | **Attachments** | Multiple mission-specific tools |
@@ -46,10 +46,10 @@ Our codebase is organized for maximum efficiency and modularity:
``` ```
Repository Repository
┣ run_1.py # Individual mission runs ┣ run_1.py # Individual mission runs
┣ run_2.py # Each file = 1+ mission completions ┣ run_2.py
┣ run_3.py ┣ run_3.py
┣ ... ┣ ...
┗ master.py # 🎯 Combined master file with color-start logic ┗ masterFile.py # 🎯 Combined master file with color-start logic - this changes periodically as we release new versions. Check this README if you are unsure what code should be loaded on the robot.
``` ```
### Workflow ### Workflow
@@ -61,34 +61,42 @@ Repository
## How to Use ## How to Use
### Installation & Deployment ### Installation & Deployment - from the server - everyday
1. **Load the Code** 1. Download the file competition_codes/sectionals/sectional_main_dec_6.py
```bash - You can do this through the repo, by using cURL, or by using git.
# Open the master.py file in Pybricks IDE - Repo - Go to the [latest release](https://codes.fll-65266.org/FLL_65266_LEGO_DYNAMICS/solutions_season_unearthed/releases) and click the "Download as ZIP" button to get the full repository.
``` - Single file - Go to the latest release and click the file link to get the raw master file.
- git CLI -
```git clone https://codes.fll-65266.org/FLL_65266_LEGO_DYNAMICS/solutions_season_unearthed.git```
Then use the master file.
2. **Connect to Robot** 2. Open https://code.pybricks.com/ and select the "Import a file" button on the top of the left bar. Import the .py file. Pair your robot via Bluetooth in Pybricks by selecting the Bluetooth button.
- Pair your robot via Bluetooth in Pybricks
3. **Upload to Robot** - Import button looks like this:
- Click "Download and Run" or send the program to the robot ![alt text](https://codes.fll-65266.org/FLL_65266_LEGO_DYNAMICS/solutions_season_unearthed/raw/branch/do-not-merge/import.png)
- Bluetooth button looks like this:
![alt text](https://codes.fll-65266.org/FLL_65266_LEGO_DYNAMICS/solutions_season_unearthed/raw/branch/do-not-merge/bluetooth.png)
3. **Upload to Robot** - Click "Download and Run" or send the program to the robot
- Run button looks like this: ![alt text](https://codes.fll-65266.org/FLL_65266_LEGO_DYNAMICS/solutions_season_unearthed/raw/branch/do-not-merge/run.png)
4. **Start Your Run** 4. **Start Your Run**
- Hold a colored LEGO brick up to the color sensor - If starting without Pybricks, press the center circular button on the SPIKE Prime Hub to start the program.
- Different colors trigger different mission runs! - Hold a colored LEGO brick up to the color sensor.
- Different colors trigger different mission runs - color mapping is below.
### Color Start System ### Color Start System
| Color | Mission | Celebration Sound | | Color | Mission |
|-------|-----------|------------------| |-------|-----------|
| Green 🟩 | Run 1 | Victory Fanfare | | ```Green 🟩 ```| Run 1 |
| White ⚪ | Run 2 | Rickroll Inspired | | ```Purple 🟪 ```| Run 2 |
| Yellow 🟨 | Run 3 | Success Chime | | ```Red 🟥 ```| Run 3 |
| Orange 🟧 | Run 4 | Power Up | | ```Yellow 🟨 ```| Run 4 |
| Blue 🟦 | Run 5 | Power Up | | ```Blue 🟦 ```| Run 5 |
| Red 🟥 | Run 6 | Ta-Da! | | ```Orange 🟧 ```| Run 6 |
> **Tip** Organize your colored bricks before the match for quick run selection!
--- ---
@@ -114,9 +122,7 @@ Team members can contribute by:
**GNU General Public License v3.0** **GNU General Public License v3.0**
```
You can take inspiration from our code, but you can't take our exact code. You can take inspiration from our code, but you can't take our exact code.
```
This project is licensed under GPL-3.0 - see the [LICENSE](LICENSE) file for complete details. This project is licensed under GPL-3.0 - see the [LICENSE](LICENSE) file for complete details.
@@ -130,14 +136,8 @@ This project is licensed under GPL-3.0 - see the [LICENSE](LICENSE) file for com
## Contact & Support ## Contact & Support
**Team 65266 Lego Dynamics** **Team 65266 - Lego Dynamics**
Questions about our approach? Interested in collaboration? Reach out! Questions about our approach? Interested in collaboration? Reach out!
--- ---
<div align="center">
Star this repo if you found it helpful!
</div>

220
RegionalFinal.py Normal file
View File

@@ -0,0 +1,220 @@
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 = 300 # mm
async def drive_forward():
"""Drive forward continuously using DriveBase."""
drive_base.drive(400, 0)
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
await drive_base.stop
print(f"Wall detected at {distance}mm!")
break
# Small delay to prevent overwhelming the sensor
await wait(50)
# New Section
async def Run1(): # From M8_5.py
right_arm.run_angle(1000,450)
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(5000,-450, Stop.HOLD)
await right_arm.run_angle(5000,450, Stop.HOLD)
await right_arm.run_angle(5000,-450, Stop.HOLD)
await right_arm.run_angle(5000,450, Stop.HOLD)
await right_arm.run_angle(5000,-450, Stop.HOLD)
right_arm.run_angle(5000,450, 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(-500,None,600)
async def Run2(): # From Heavy_lifting_final.py
await drive_base.straight(200)
await drive_base.turn(-20)
await drive_base.straight(536)
await drive_base.turn(60, Stop.HOLD)
await drive_base.straight(30)
await right_arm.run_angle(5000, 2900)
await drive_base.straight(40)
await right_arm.run_angle(5000, -4000)
await drive_base.straight(-60)
await drive_base.turn(-60)
await drive_base.straight(-670)
async def Run3(): # tip the scale.py
right_arm.run_angle(500,400)
await drive_base.straight(800)
await drive_base.turn(90)
await drive_base.straight(86)
await right_arm.run_angle(800,-600)
await right_arm.run_angle(900,800)
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,-4000)
await drive_base.straight(-110)
await drive_base.turn(90)
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, -1200)
await drive_base.straight(84)
await right_arm.run_angle(300, 1200)
await drive_base.straight(-900)
# 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(-102.5)
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, 270)
await drive_base.turn(30)
await drive_base.straight(-60)
# 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 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()
reflected = await color_sensor.reflection()
color = detect_color(h, s, v, reflected)
if color == "Red":
print('Running Mission 3')
await Run3() #red
elif color == "Orange":
print('Running Mission 6')
await Run6() #orange
elif color == "Yellow":
print('Running Mission 4')
await Run4() #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 Run2() #purple - vertically
else:
print(f"Unknown color detected (Hue: {h}, Sat: {s}, Val: {v})")
await wait(10)
# Run the main function
run_task(main())

View File

@@ -140,40 +140,41 @@ async def Run4(): # From Send_Over_Final.py
# Add Rishi's code here # Add Rishi's code here
async def Run5(): async def Run5():
await drive_base.straight(519) await drive_base.straight(700)
await left_arm.run_angle(-10000, 300) await drive_base.turn(-18)
await left_arm.run_angle(10000, 600)
await drive_base.straight(160)
await drive_base.turn(-30)
await drive_base.straight(50)
await right_arm.run_angle(3000, 3000)
await drive_base.straight(-150)
await drive_base.turn(120)
await drive_base.straight(25)
await right_arm.run_angle(10000, -3000)
await drive_base.straight(-110)
await drive_base.turn(-43)
await right_arm.run_angle(10000, -3000)
await drive_base.straight(295)
await right_arm.run_angle(10000, 9000)
await drive_base.straight(-65)
await drive_base.turn(45)
await drive_base.straight(175)
await drive_base.turn(24.5)
await drive_base.straight(-100)
await right_arm.run_angle(10000, -8500)
await drive_base.straight(100) await drive_base.straight(100)
await right_arm.run_angle(10000, 3500) await drive_base.straight(-205)
await drive_base.turn(-30) await drive_base.turn(63)
await drive_base.straight(-300) await drive_base.straight(125)
await drive_base.turn(-80) await arm_motor.run_angle(1000, -1200)
await drive_base.straight(-700) await drive_base.straight(84)
await arm_motor.run_angle(300, 1200)
await drive_base.straight(-875)
# Add - Adi's code here # Add - Adi's code here
async def Run6(): async def Run6():
await drive_base.straight(750) await drive_base.straight(500)
await drive_base.straight(-650) 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(-94)
await drive_base.straight(-80)
await left_arm.run_angle(500, 900)
await drive_base.straight(50)
await drive_base.turn(-10)
await drive_base.straight(50)
await left_arm.run_angle(700, -200)
await drive_base.turn(30)
await drive_base.straight(-60)
await drive_base.turn(80)
await drive_base.straight(-900)
# Function to classify color based on HSV # Function to classify color based on HSV

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 = 300 # mm WALL_DISTANCE = 200 # mm
async def drive_forward(): async def drive_forward():
"""Drive forward continuously using DriveBase.""" """Drive forward continuously using DriveBase."""
@@ -45,31 +45,49 @@ async def monitor_distance():
# New Section # New Section
async def Run1(): # From M8_5.py async def Run1(): # From M8_5.py
left_arm.run_angle(1000, -300)
right_arm.run_angle(1000, 500) right_arm.run_angle(1000,450)
await drive_base.straight(320) left_arm.run_angle(500,-90)
await right_arm.run_angle(5000, -500, Stop.HOLD) await drive_base.straight(200)
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(277)
await drive_base.turn(20)
await drive_base.straight(65)
await drive_base.turn(-30)
right_arm.run_angle(50, 500)
await drive_base.turn(45)
await drive_base.straight(-145)
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(-600)
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(5000,-450, Stop.HOLD)
await right_arm.run_angle(5000,450, Stop.HOLD)
await right_arm.run_angle(5000,-450, Stop.HOLD)
await right_arm.run_angle(5000,450, Stop.HOLD)
await right_arm.run_angle(5000,-450, Stop.HOLD)
right_arm.run_angle(5000,450, 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(-500,None,600)
async def Run2(): # From Heavy_lifting_final.py async def Run2(): # From Heavy_lifting_final.py
await drive_base.straight(200) await drive_base.straight(200)
await drive_base.turn(-20) await drive_base.turn(-20)
@@ -105,77 +123,62 @@ async def Run3(): # tip the scale.py
await drive_base.turn(40) # turning right await drive_base.turn(40) # turning right
await left_arm.run_angle(410,-400) #lift a little bit await left_arm.run_angle(410,-400) #lift a little bit
await drive_base.straight(80) await drive_base.straight(80)
await drive_base.turn(-41) #ma din din din dun 67 41 21 69 await drive_base.turn(-41) #ma din din din dun 67 41 21
await drive_base.straight(900) await drive_base.straight(900)
async def Run4(): # From Send_Over_Final.py async def Run4(): # From Send_Over_Final.py
#Get to mission
await drive_base.straight(920) await drive_base.straight(920)
await drive_base.turn(-90,Stop.HOLD) await drive_base.turn(-90,Stop.HOLD)
await drive_base.straight(65) await drive_base.straight(65)
#Solve mission #Solve
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
await drive_base.straight(-110) await drive_base.straight(-110)
await drive_base.turn(90) await drive_base.turn(90)
# while True:
# distance_mm = await lazer_ranger.distance()
# print('distancing...',distance_mm)
# if distance_mm < 300:
# drive_base.stop
# break
# else:
# drive_base.straight(300)
# print('running...')
# await wait(10)
await multitask( await multitask(
drive_forward(), drive_forward(),
monitor_distance() monitor_distance()
) )
# Add Rishi's code here # Add Rishi's code here
async def Run5(): async def Run5():
await drive_base.straight(519) await drive_base.straight(600)
await left_arm.run_angle(-10000, 300)
await left_arm.run_angle(10000, 600)
await drive_base.straight(160)
await drive_base.turn(-30)
await drive_base.straight(50)
await right_arm.run_angle(3000, 3000)
await drive_base.straight(-150)
await drive_base.turn(120)
await drive_base.straight(25)
await right_arm.run_angle(10000, -3000)
await drive_base.straight(-110)
await drive_base.turn(-43)
await right_arm.run_angle(10000, -3000)
await drive_base.straight(295)
await right_arm.run_angle(10000, 9000)
await drive_base.straight(-65)
await drive_base.turn(45)
await drive_base.straight(175)
await drive_base.turn(24.5)
await drive_base.straight(-100) await drive_base.straight(-100)
await right_arm.run_angle(10000, -8500) await drive_base.straight(150)
await drive_base.turn(60)
await drive_base.straight(100) await drive_base.straight(100)
await right_arm.run_angle(10000, 3500) await drive_base.turn(-86)
await drive_base.turn(-30) await drive_base.straight(120)
await drive_base.straight(-300) await drive_base.turn(-45)
await drive_base.turn(-80) await drive_base.straight(-200)
await drive_base.straight(-700) await drive_base.turn(75)
# Add - Adi's code here # Add - Adi's code here
async def Run6(): async def Run6():
await drive_base.straight(750) await drive_base.straight(500)
await drive_base.straight(-650) 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(-94)
await drive_base.straight(-80)
await left_arm.run_angle(500, 900)
await drive_base.straight(50)
await drive_base.turn(-10)
await drive_base.straight(50)
await left_arm.run_angle(700, -200)
await drive_base.turn(30)
await drive_base.straight(-60)
await drive_base.turn(80)
await drive_base.straight(-900)
# Function to classify color based on HSV # Function to classify color based on HSV
def detect_color(h, s, v, reflected): def detect_color(h, s, v, reflected):
if reflected > 4: if reflected > 4:

View File

@@ -0,0 +1,221 @@
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 = 300 # mm
async def drive_forward():
"""Drive forward continuously using DriveBase."""
drive_base.drive(400, 0)
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
await drive_base.stop
print(f"Wall detected at {distance}mm!")
break
# Small delay to prevent overwhelming the sensor
await wait(50)
# New Section
async def Run1(): # From M8_5.py
right_arm.run_angle(1000,450)
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(5000,-450, Stop.HOLD)
await right_arm.run_angle(5000,450, Stop.HOLD)
await right_arm.run_angle(5000,-450, Stop.HOLD)
await right_arm.run_angle(5000,450, Stop.HOLD)
await right_arm.run_angle(5000,-450, Stop.HOLD)
right_arm.run_angle(5000,450, 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(-500,None,600)
async def Run2(): # From Heavy_lifting_final.py
await drive_base.straight(200)
await drive_base.turn(-20)
await drive_base.straight(536)
await drive_base.turn(60, Stop.HOLD)
await drive_base.straight(30)
await right_arm.run_angle(5000, 2900)
await drive_base.straight(40)
await right_arm.run_angle(5000, -4000)
await drive_base.straight(-60)
await drive_base.turn(-60)
await drive_base.straight(-670)
async def Run3(): # tip the scale.py
right_arm.run_angle(500,400)
await drive_base.straight(800)
await drive_base.turn(90)
await drive_base.straight(86)
await right_arm.run_angle(800,-600)
await right_arm.run_angle(900,800)
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,-4000)
await drive_base.straight(-110)
await drive_base.turn(90)
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, -1200)
await drive_base.straight(84)
await right_arm.run_angle(300, 1200)
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)
# 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 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()
reflected = await color_sensor.reflection()
color = detect_color(h, s, v, reflected)
if color == "Red":
print('Running Mission 3')
await Run3() #red
elif color == "Orange":
print('Running Mission 6')
await Run6() #orange
elif color == "Yellow":
print('Running Mission 4')
await Run4() #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 Run2() #purple - vertically
else:
print(f"Unknown color detected (Hue: {h}, Sat: {s}, Val: {v})")
await wait(10)
# Run the main function
run_task(main())

View File

@@ -0,0 +1,383 @@
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
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 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
if distance is None:
continue
# Small delay to prevent overwhelming the sensor
await wait(50)
"""
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)
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)
async def solve_silo():
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)
"""
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()
# return to base
await drive_base.arc(-500,None,600)
drive_base.stop()
async def solve_forge():
await right_arm.run_target(50,50)
# 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,-160) # arm down
await wait(100)
await drive_base.turn(20) # turn right a little bit
await right_arm.run_angle(500,160) #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)
"""
Run#3
- Combined angler artifacts and tip the scale
- Yellow key
"""
async def Run3():
await solve_angler_artifacts()
await solve_tip_the_scale()
#cross over to red side
await multitask(
drive_forward(),
monitor_distance()
)
async def solve_angler_artifacts():
await drive_base.straight(940)
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,-103, None)
async def solve_tip_the_scale():
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(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
- Blue Key
"""
async def Run4():
await drive_base.straight(700)
await drive_base.turn(-18)
await drive_base.straight(120)
await drive_base.straight(-210)
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(100, 95)
#await drive_base.straight(-875)
#return with arc
await drive_base.straight(-600)
await drive_base.arc(10,-47, None)
await drive_base.straight(-400,Stop.COAST_SMART)
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)
"""
Run#5
- Solves Salvage Operation + Statue Rebuild
- Orange Key
"""
async def Run5():
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)
#solving statue
await drive_base.straight(350)
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(5)
await left_arm.run_angle(500, 290)
await drive_base.turn(18)
await drive_base.straight(-100)
await drive_base.turn(-90)
await drive_base.straight(900)
drive_base.stop()
async def solve_salvage_operation():
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)
async def solve_statue_rebuild():
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)
"""
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()
await drive_base.straight(640)
await drive_base.straight(-150)
await drive_base.turn(-8)
await left_arm.run_angle(500, -520)
await drive_base.straight(300)
await wait(50)
await left_arm.run_angle(500, 700)
#return to base
await drive_base.straight(-300)
drive_base.stop()
async def solve_site_mark_1():
await drive_base.straight(500)
await right_arm.run_angle(100, -10)
await wait(50)
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)
# 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 == "Green":
print('Running Mission 1')
await Run1()
elif color == "Red":
print('Running Mission 2')
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_7')
await Run6_7()
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())

View File

@@ -2,26 +2,36 @@ from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch from pybricks.tools import wait, StopWatch, run_task, multitask
from pybricks.tools import run_task,multitask
hub = PrimeHub() 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) left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.B) right_motor = Motor(Port.B)
left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE)
right_arm = Motor(Port.D)
arm_motor = Motor(Port.D, Direction.CLOCKWISE)
arm_motor_left= Motor(Port.C, Direction.CLOCKWISE)
# 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=68.8, axle_track=180) drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180)
drive_base.settings(550,700,100,100) print('The default settings are: ' + str(drive_base.settings()))
drive_base.settings(300,1000,300,750)
# Optionally, uncomment the line below to use the gyro for improved accuracy.
drive_base.use_gyro(True) drive_base.use_gyro(True)
first_run = False
async def main(): async def main():
await drive_base.straight(750) await drive_base.straight(700)
await drive_base.straight(-650) await drive_base.turn(-17)
await drive_base.straight(100)
await drive_base.straight(-205)
await drive_base.turn(62)
await drive_base.straight(125)
await arm_motor.run_angle(1000, -1200)
await drive_base.straight(87)
await arm_motor.run_angle(300, 1200)
await drive_base.straight(-875)
run_task(main()) run_task(main())

View File

@@ -1,27 +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
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(880,850,700,700)
drive_base.use_gyro(True)
first_run = True
async def main():
await drive_base.straight(750)
await drive_base.straight(-650)
run_task(main())

View File

@@ -1,37 +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
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():
await right_arm.run_angle(2000,1000)
await drive_base.straight(200)
await drive_base.turn(-20)
await drive_base.straight(525)
await drive_base.turn(60)
await drive_base.straight(30)
await right_arm.run_angle(2000,-1000)
await drive_base.straight(30)
await right_arm.run_angle(3000,1000)
await drive_base.straight(-60)
await drive_base.turn(-60)
await drive_base.straight(-525)
await drive_base.turn(20)
await drive_base.straight(-200)

View File

@@ -1,36 +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
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():
#Get to mission
await drive_base.straight(200)
await drive_base.turn(-20)
await drive_base.straight(525)
await drive_base.turn(60)
#Solve mission
await drive_base.straight(50)
await right_arm.run_angle(2000,1000)
await drive_base.straight(-50)
await drive_base.turn(45)
await drive_base.straight(50)
await right_arm.run_angle(350,-1000)
#Return home
await drive_base.straight(-100)
await drive_base.turn(-100)
await drive_base.straight(-600)
run_task(main())

View File

@@ -2,7 +2,7 @@ from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch, run_task from pybricks.tools import wait, StopWatch, run_task, multitask
hub = PrimeHub() hub = PrimeHub()
@@ -23,23 +23,15 @@ drive_base.settings(300,1000,300,750)
drive_base.use_gyro(True) drive_base.use_gyro(True)
async def main(): async def main():
await drive_base.straight(519) await drive_base.straight(700)
await arm_motor_left.run_angle(300, -100) await drive_base.turn(-17)
await arm_motor_left.run_angle(300, 500) await drive_base.straight(100)
await drive_base.straight(180) await drive_base.straight(-205)
await drive_base.turn(-37) await drive_base.turn(62)
await drive_base.straight(50) await drive_base.straight(125)
await arm_motor.run_angle(300, -400) await arm_motor.run_angle(1000, -1200)
await drive_base.straight(-150) await drive_base.straight(87)
await drive_base.turn(135) await arm_motor.run_angle(300, 1200)
await drive_base.straight(50) await drive_base.straight(-875)
await arm_motor.run_angle(300, 400)
await drive_base.straight(-75)
await arm_motor.run_angle(300, 300)
await drive_base.turn(-50)
await drive_base.straight(162)
await arm_motor.run_angle(100, -200)
await drive_base.straight(30)
await arm_motor.run_angle(50,-500)
run_task(main()) run_task(main())

View File

@@ -1,34 +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
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():
await drive_base.straight(200)
await drive_base.turn(-20)
await drive_base.straight(525)
await drive_base.turn(60)
await drive_base.straight(50)
await right_arm.run_angle(2000,1000)
await drive_base.straight(-50)
await drive_base.turn(45)
await drive_base.straight(50)
await right_arm.run_angle(350,-1000)
await drive_base.turn(-100)
await drive_base.straight(-600)
run_task(main())

View File

@@ -1,34 +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
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():
await drive_base.straight(200)
await drive_base.turn(-20)
await drive_base.straight(525)
await drive_base.turn(60)
await drive_base.straight(50)
await right_arm.run_angle(2000,1000)
await drive_base.straight(-50)
await drive_base.turn(45)
await drive_base.straight(50)
await right_arm.run_angle(350,-1000)
await drive_base.turn(-100)
await drive_base.straight(-600)
run_task(main())

View File

@@ -19,31 +19,47 @@ drive_base.settings(600,500,300,200)
drive_base.use_gyro(True) drive_base.use_gyro(True)
async def main(): async def main():
left_arm.run_angle(1000, 300)
right_arm.run_angle(1000,500) right_arm.run_angle(1000,450)
await drive_base.straight(320) left_arm.run_angle(500,-90)
await drive_base.straight(200)
await right_arm.run_angle(5000,-500, Stop.HOLD) await drive_base.turn(-40)
await right_arm.run_angle(5000,500, Stop.HOLD) await drive_base.straight(325)
await right_arm.run_angle(5000,-500, Stop.HOLD) await left_arm.run_angle(500,90)
await right_arm.run_angle(5000,500, Stop.HOLD)
await right_arm.run_angle(5000,-500, Stop.HOLD)
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(-20)
await drive_base.straight(277) await drive_base.turn(15)
await drive_base.turn(20)
await drive_base.straight(65)
await drive_base.turn(-30) await drive_base.straight(-173)
right_arm.run_angle(50,500)
await drive_base.turn(45) await drive_base.turn(45)
await drive_base.straight(-145) await drive_base.straight(120)
await drive_base.turn(-60) left_arm.run_angle(1000,-670)
await drive_base.straight(90)
await left_arm.run_angle(1000,-450) await right_arm.run_angle(5000,-450, Stop.HOLD)
await drive_base.straight(-145) await right_arm.run_angle(5000,450, Stop.HOLD)
await left_arm.run_angle(1000,450) await right_arm.run_angle(5000,-450, Stop.HOLD)
await drive_base.straight(10) await right_arm.run_angle(5000,450, Stop.HOLD)
await drive_base.turn(35) await right_arm.run_angle(5000,-450, Stop.HOLD)
await drive_base.straight(-600) right_arm.run_angle(5000,450, 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(-500,None,600)
run_task(main()) run_task(main())

View 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())

View File

@@ -37,14 +37,6 @@ async def main():
await drive_base.straight(-100) await drive_base.straight(-100)
await drive_base.turn(-54) await drive_base.turn(-54)
await arm_motor.run_angle(10000, -3000) await arm_motor.run_angle(10000, -3000)
await drive_base.straight(250)
await drive_base.turn(-5)
await arm_motor.run_angle(10000, 7000)
await drive_base.straight(-50)
await drive_base.turn(68)
await arm_motor.run_angle(10000, -6000)
await drive_base.straight(200) await drive_base.straight(200)
await arm_motor.run_angle(10000, 4000) await arm_motor.run_angle(10000, 10000)
await drive_base.turn(-40)
await arm_motor.run_angle(10000, 7000)
run_task(main()) run_task(main())

View File

@@ -1,29 +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
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(400,500,100,100)
drive_base.use_gyro(True)
async def main():
await drive_base.straight(500)
await right_arm.run_angle(300,100)
await drive_base.straight(-100)
await right_arm.run_angle(300,-100)
await drive_base.straight(-350)
run_task(main())

View File

@@ -19,28 +19,41 @@ drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, 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
async def drive_forward():
"""Drive forward continuously using DriveBase."""
drive_base.drive(400, 0)
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
await drive_base.stop
print(f"Wall detected at {distance}mm!")
break
# Small delay to prevent overwhelming the sensor
await wait(50)
async def main(): async def main():
#Get to mission await drive_base.straight(-920)
await drive_base.straight(920)
await drive_base.turn(-90,Stop.HOLD) await drive_base.turn(-90,Stop.HOLD)
await drive_base.straight(65) await drive_base.straight(65)
#Solve mission #Solve
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
await drive_base.straight(-110) await drive_base.straight(-110)
await drive_base.turn(90) await drive_base.turn(90)
await drive_base.straight(500)
while True:
distance_mm = await lazer_ranger.distance()
print('distancing...',distance_mm)
if distance_mm < 300:
drive_base.stop
break
else:
drive_base.straight(300)
print('running...')
await wait(10)
await multitask(
drive_forward(),
monitor_distance()
)
run_task(main()) run_task(main())

View File

@@ -1,44 +0,0 @@
# ---JOHANNES---
# THIS CODE IS NOT USED ANYMORE AND SHOULD NOT BE USED!!!!!!
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())

View File

@@ -15,31 +15,23 @@ left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE)
right_arm = Motor(Port.D) right_arm = Motor(Port.D)
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180)
drive_base.settings(300,1000,300,200) drive_base.settings(600,500,300,200)
#drive_base.use_gyro(True) drive_base.use_gyro(True)
async def main(): async def main():
left_arm.run_angle(500,200)
right_arm.run_angle(500,200) right_arm.run_angle(500,400)
await drive_base.straight(70) await drive_base.straight(800)
await drive_base.turn(90)
await drive_base.straight(88)
await right_arm.run_angle(100,-300)
await right_arm.run_angle(400,400)
await drive_base.turn(-55) await drive_base.straight(-100)
await drive_base.straight(900) await drive_base.turn(90)
await drive_base.turn(92.5) await drive_base.straight(800)
drive_base.brake()
await drive_base.straight(75)
await drive_base.straight(21)
await right_arm.run_angle(500,-250)
await right_arm.run_angle(500,250)
await drive_base.turn(55)
await left_arm.run_angle(300,-400)
await drive_base.turn(46.5)
await drive_base.turn(-40)
await drive_base.straight(900)
run_task(main()) run_task(main())

View File

@@ -1,31 +1,29 @@
from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop 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 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() hub = PrimeHub()
left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.B) right_motor = Motor(Port.B)
left_arm = Motor(Port.C)
left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE)
right_arm = Motor(Port.D) right_arm = Motor(Port.D)
lazer_ranger = UltrasonicSensor(Port.E)
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) color_sensor = ColorSensor(Port.F)
# DriveBase configuration
drive_base.settings(600,500,300,200) WHEEL_DIAMETER = 68.8 # mm
AXLE_TRACK = 180 # mm
drive_base = DriveBase(left_motor, right_motor, WHEEL_DIAMETER, AXLE_TRACK)
drive_base.settings(600, 500, 300, 200)
drive_base.use_gyro(True) drive_base.use_gyro(True)
WALL_DISTANCE = 200 # mm
async def main(): async def main():
# Your code goes here
await drive_base.straight(915) run_task(main())
await drive_base.turn(-90)
await drive_base.straight(60)
await left_arm.run_angle(10000,-4000)
await drive_base.straight(-90)
await drive_base.turn(80)
await drive_base.straight(2000)
run_task(main())