Skip to content

Commit 4474917

Browse files
committed
Add missing esp32 files
1 parent 14979e9 commit 4474917

File tree

8 files changed

+3246
-0
lines changed

8 files changed

+3246
-0
lines changed

soccer-robots-esp32/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# ESP32 Robots
2+
3+
The robots are run on:
4+
- WEMOS **ESP32-S2-Mini** Development Board
5+
- Repeat Robotics **Budget Ant DESC**, which drives the DC motors
6+
- Repeat Robotics **Antweight Brushed DC Motors**
7+
- Headway LiFePO4 **40152S Battery**
8+
- **MT3608** DC-DC Boost Converter
9+
10+
## Setting Up Environment
11+
12+
Make sure your esp_idf toolchain is installed and you can run idf.py. Follow the steps for installation of ESP-IDF, you can use VS Code's extension for it if needed.
13+
Before we build and flash our project to the microcontroller, we need to tell esp_idf what microcontroller we're flashing to (which is the ESP32-S2).
14+
15+
Run `idf.py set-target esp32s2`
16+
17+
## Setup WiFi Connection
18+
19+
Run `idf.py menuconfig`
20+
21+
1. Navigate to "Connectivity Configuration"
22+
2. Edit WIFI SSID and Password accordingly.
23+
3. Save and exit.
24+
25+
The ESP32 is set up to do two things primarily: take commands from the raspberry pi and then drive the motors according to those commands.
26+
27+
The ESP has a TCP connection set up with the Raspberry Pi. It does this by connecting to the same wifi as the Raspberry Pi. This should be RPIHotspot, currently the configuration for the wifi and its password may be different so this may need to be changed. Take note of the esp's ip address from the serial monitor; that will be put into the raspberry pi programer so that it knows what address it should connect to.
28+
29+
The Raspberry Pi should send messages which include "readyCheck" when the website wants to see if the robots are ready, "reset" when the game ends, "ignore" for test messages, and different keys to signify different types of movement.
30+
31+
We also use semaphores to balance between the multithreading we do between the movement and the receiving input.
32+
33+
Finally, as for the movement we use basically s-curves for smooth control. The equation I use has the curve looks kind of like this, where "s" and "f" are the different speeds we want to move between.
34+
![image](https://github.com/user-attachments/assets/8f57eb09-9af4-40c4-bd81-6aa076cef75f)
35+
36+
So basically our x value will change over time (which we do with a hardware timer), and our y value will be the new speed we are using. This allows us to smoothly change between different speeds depending on what's being pressed.
37+
38+
One important note is that the correct pulse widths don't seem to really be accurate to what's given on the ESC documentation (which is <https://repeat-robotics.com/buy/desc/>). It might be just with the one ESC we had working though. I would check the new ESC's to see the valid pulse width ranges and valid duty cycles needed. While you'd expect the valid duty cycle %'s to be 36-50 and 86-100, those do get the valid pulse widths, but they don't seem to really work.
39+
40+
Also note you have to initially set the duty cycle to in between reverse and forward, and you have to slowly increase it in either direction. So let's say the valid ranges are in fact 36-50 for reverse and 86-100. You can't just do duty = 90 and expect it to work. You'd say have to do duty = 60, and incement it until it reaches 90 to drive the motors. Likewise in reverse.
41+
42+
To understand a bit better on how motors work, research pulse width modulation, duty cycles, positive pulse width and know about frequency/period.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef WIFI_CONNECTIVITY_H
2+
#define WIFI_CONNECTIVITY_H
3+
4+
#include "esp_wifi.h"
5+
6+
bool wifi_init_sta(void);
7+
bool wifi_setup_init(void);
8+
9+
#endif
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file was generated using idf.py save-defconfig. It can be edited manually.
2+
# Espressif IoT Development Framework (ESP-IDF) 5.4.2 Project Minimal Configuration
3+
#
4+
CONFIG_IDF_TARGET="esp32s2"
5+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
6+
CONFIG_ESP_WIFI_SSID="Mahd's Galaxy A14 5G"
7+
CONFIG_ESP_WIFI_PASSWORD="ayu5t4fwnsu37xk"
8+
CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y
9+
CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y
10+
CONFIG_ESP_CONSOLE_USB_CDC=y
11+
CONFIG_LOG_COLORS=y
12+
CONFIG_LWIP_STATS=y
13+
CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y
14+
CONFIG_LWIP_DEBUG=y
15+
CONFIG_LWIP_DNS_DEBUG=y
16+
CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y

0 commit comments

Comments
 (0)