Skip to content

Commit 1e0faa6

Browse files
committed
Merge branch 'main' of https://github.com/UTDallasEPICS/Soccer-Robots into Damian
2 parents b276d5a + 3a0fc9d commit 1e0faa6

File tree

16 files changed

+2329
-3
lines changed

16 files changed

+2329
-3
lines changed

cad/F25/launcher_assembly.SLDASM

1.74 MB
Binary file not shown.

cad/F25/launcher_wheel.SLDPRT

78.9 KB
Binary file not shown.

cad/F25/motor.SLDASM

1.65 MB
Binary file not shown.

cad/F25/motor_holder.SLDPRT

166 KB
Binary file not shown.

documentation/goalpost_design_docs.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Main objective was to come up with goalpost design, so I created 2.
2-
## From 9/11 to 9/18
2+
33
### goalpost.SLDPRT
44
- Simplified design of Su25, made bigger about 15in wide to accommodate ball and bigger robots.
55
- Box style design, ball exits on the side
@@ -13,3 +13,6 @@ Main objective was to come up with goalpost design, so I created 2.
1313
### 3D Printing
1414
- Need to 3D print one of these, Bambu Studio has tools to break this into parts but need to familiarize myself
1515
- Also need a 3D printer, EPICS lab one is kind of small so try to get access to something else to speed things up
16+
### launcher_assembly.SLDASM
17+
- Uses a "flywheel" to launch the ball, much like tennis ball launchers
18+
- The "wheel" in this model is a LEGO 56x26 tire, part number 55976

raspberrypi/README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ If you run the script, you do not have to do the following:
4848
To run this, you want to first activate **EspManager.py**. This is basically the process that will communicate with the Raspberry Pi's. It does this by creating child processes, and each child
4949
makes a TCP connection with a single ESP, and communicates with the parent back and forth with unnamed pipes. **ControllerPi.py** and **GmServerPi.py** will send relevant information to **EspManager.py**
5050
through another socket connection. Here's a diagram to explain the purpose of each process a bit better (apologies for the poor quality).
51-
![image](https://github.com/user-attachments/assets/55c1ff86-75d5-41fe-a101-83da67798dfa)
51+
<img width="4445" height="3950" alt="better diagram" src="https://github.com/user-attachments/assets/e2b624f2-6dc2-4511-8342-c66bf52103d8" />
52+
5253

5354
Now to run the Raspberry Pi server, we will first run **EspManager.py**, move that to background, then run **GmServerPi.py**, move that to background, then run **ControllerPi.py**, move that to background,
5455
and that will be all you need to do. Note that you **MUST** run it in this order, otherwise because of the order of socket connections it won't work properly.
@@ -84,26 +85,61 @@ ask your mentor for further details.
8485

8586
### EspManager.py
8687

88+
This takes in data about motor inputs for each robot and signals from the game manager (game start, robot ready check, game end), and sends the appropriate data to each robot.
89+
90+
To connect with each robot, it forks itself (basically like makes a clone of the program that also starts at the same code line where the fork was) based on however many robots there are. If there are 2 robots, for instnace, there will be 2 forks, and thus 2 child processes will be made.
91+
92+
May need to research pipes, forking, piping, and processes to understand this.
93+
94+
Then, when it receives a request for ready connection from GmServerPi.py, it relays that through pipes to its child processes, which then send a message to the robots asking if they're ready. If they are, they should return back their own success message successfully. Then if all robots returned success message, send that to the game manager file which then tells that to the website.
95+
96+
Also, for motor inputs, ControllerPi.py sends its ID alongside the motor inputs. EspManager checks the ID and sends it to the correct child process, which then sends those inputs to the esp32.
97+
98+
It also has shared memory shared with GmServerPi.py, which is where the current game timer is stored. Basically, when the game ends, it puts in the shared memory that the game is over. EspManager reads from this frequently, and when it sees the game is over, it can shut off communication with the robots, and prepare for reconnection.
99+
87100
### ControllerPi.py
88101

102+
This connects with the website's Controller file, and when the website sends inpts from the user, it directs those inputs to EspManager.py. Pretty straighforward, though it also checks if the input the user sends is the same input as before. If it is, then it doesn't send it, as that doesn't change anything.
103+
89104
### GmServerPi.py
90105

106+
This connects with the website's game manager file. It handles and responds to certain messages from the website. For example, if it receives a packet to check if robots are ready, it sends that request to espmanager, gets a response, and sends that response back up to the website.
107+
108+
When it receives game start command, it begeins running the game, waiting until the timer's up, and when it is it puts in shared memeory with GmServer that time is up, to let it know to disconnect the robots. Then it restarts with waiting fora game to start. It also sends the timer to the website, as it actually is what has the decreasing timer.
109+
91110
### ESPClient.py
92111

112+
This is just a class where each object represents a connection with an esp32, used as a helper function. It has functions like trying to connect to the esp, sending data, and receiging data, alongside error handling too.
93113

94114
# Camera
95115

96116
## cleanCode.py
97117

118+
This creates a page that's hosted on the raspberry pi at a ip address and port to stream the camera display to. It initializes with the camera and starts a server to host the stream on, and connects them to the stream.... somehow. Probably when it calls self.wfile.write(frame), where it writes the current frame of the camera.
119+
98120
## combinedCam.py
99121

100-
## apriltagLiveFeed.py
122+
This is like the file above, but this time it makes it so if there's keyboard presses of WASD on the raspberry pi, it moves the camera lens to show a differnet place of the field. At least, I'm assuming that's the intention.
101123

124+
NOTE: THIS ONE MAY BE OUTDATED; CHECK WITH DAMIAN ON THIS.
102125

126+
## apriltagLiveFeed.py
127+
128+
This is basically exactly like the above, but now if you put an april tag in front of the camera, this code will detect that april tag. The code to detect the april tag will be useful likely, use this as reference when implementing the algorithm to send robots to charging stations. It may be outdated in the same way that combinedCam is outdated.
103129

104130

105131
## backtracking.py
106132

133+
There isn't any file named this, I assume it's just backTest.py. This seems to first do the same as above, streaming it but also showing the april tag on the screen. Right now, it puts the movement instruction on the frame, so ideally the only thing that needs to be done is sending it.
134+
135+
It seems right now it's configured to send 2 pieces of data to the motor: first, the direction of movement (rotationg left, rotating right, moving backwards, moving forwards, stopping) as well has how much to rotate in each direciton. Now, main issue will be configuring that to become packets to send to the esp32. Have fun with that!
136+
137+
Also note that each car has 4 states. State 0 is rotating to face target, state 1 is moring towards target, state 2 is doing final rotation, and state 3 means finished arriving and rotating at charigng station.
138+
107139
## backupTag.py
108140

141+
This seems to be like a prototype of the one above? It uses a file that doesn't exist anymore (backtracking.py, though an archive of it is at https://github.com/UTDallasEPICS/Soccer-Robots/blob/1eee7dc0c4098b2c6e86b0c17d89b73867ff42a8/raspberrypi/scripts/archive/Backtracking.py.txt#L4). Even so, backupTag.py references a method in backtracking.py "get_direction", that I can't find in the backtracking.py archive file.
142+
109143
## carConnect.py
144+
145+
This is a file that was used to connect to the ESP32. Back when I made the ESPClient.py file I didn't know this one existed, but all it does for now is just connect and send a handshake, and that's it. Now though, it seems we don't need it since ESPClient.py and ESPManager.py does everything this would've already done.

soccer-robots-esp32/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch
6+
.history
7+
**/build/
8+
**/build_*/
9+
**/managed_components/
10+
.DS_Store
11+
sdkconfig.old
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
],
7+
"unwantedRecommendations": [
8+
"ms-vscode.cpptools-extension-pack"
9+
]
10+
}

soccer-robots-esp32/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.16.0)
2+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
3+
project(soccer-robots-esp32)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
dependencies:
2+
espressif/esp_tinyusb:
3+
component_hash: a8558cc89dae68552cb7a20123ffcb8db81a8a25bd560bc4d5b2f60a12bd6afb
4+
source:
5+
service_url: https://api.components.espressif.com/
6+
type: service
7+
version: 2.0.1
8+
espressif/tinyusb:
9+
component_hash: aec03a6402b66695719fa1121b7d9eee8031922df5c8a3f4b54a51874f65bbd6
10+
source:
11+
service_url: https://api.components.espressif.com/
12+
type: service
13+
version: 0.18.0~5
14+
idf:
15+
component_hash: null
16+
source:
17+
type: idf
18+
version: 5.4.0
19+
manifest_hash: 4b471081c3fe65af5e23fc00f412d6b1c559ff895dbab2e2bebbd2940f482f81
20+
target: esp32s2
21+
version: 1.0.0

0 commit comments

Comments
 (0)