A Ball Robot Based On ESP32 for ESP32-S3
An ESP32 camera project for ESP32-S3.
Parts and sourceBefore you start
Confirm board compatibility and supported firmware targets in the upstream documentation.
Upstream README
ESP32 足球机器人 All-in-One 控制台

中文
这是一个面向小型足球机器人/小球车的完整实验项目:电脑运行一个 Python WebUI,同时管理小车电机、IMU 姿态、两路摄像头、YOLO/YOLOE 识别、实体摇杆、语音控制,以及无人机俯拍视角下的 football 到 football gate 自动路径控制。
主入口是 all_in_one_webui.py。它会把网页控制、摄像头接收、YOLOE 推理、实体遥控器代理、IMU 可视化和语音方向控制整合在一个页面里。
能做什么
- 控制双电机小车:PWM 调试、差速摇杆、前进/后退/转向/停止。
- 读取编码器、RPM、IMU 姿态,并在网页里显示 3D 姿态。
- 接收小车摄像头画面和独立 YOLO 摄像头画面。
- 用 YOLO/YOLOE 识别
football、football gate等目标。 - 将 YOLO 识别框中心点做匹配,计算小球相对球门应前进、后退、向左或向右的连续路径。
- 通过已有
/drive?throttle=&steering=接口把路径指令连续发送给小车,不需要修改 stick 或小车固件协议。 - 支持实体摇杆遥控器,并可在 WebUI 中开启/关闭小车转发。
- 支持 XIAO ESP32S3 Sense 板载麦克风语音方向控制,语音识别走 DashScope Realtime ASR。
- 可选 Android 控制器工程,用手机直接控制 ESP32 小车。
目录结构
.
├── all_in_one_webui.py # 推荐主入口:三合一/多合一 WebUI
├── voice_drive_realtime.py # 语音识别 sidecar,接收 ESP32 麦克风 PCM
├── voice_requirements.txt # 语音 sidecar 依赖
├── .env.example # 本地环境变量示例,不含真实密钥
├── esp32/
│ └── esp32_motor_control/
│ └── esp32_motor_control.ino # 小车电机、编码器、IMU、摄像头固件
├── physical_remote/
│ ├── esp32_joystick_remote/
│ │ └── esp32_joystick_remote.ino # 实体摇杆遥控器固件
│ └── README.md # 遥控器单独说明
├── esp32_camera_yolo8_project/
│ ├── esp32_camera_stream/
│ │ └── esp32_camera_stream.ino # 独立 YOLO 摄像头固件
│ ├── app_camera_yolo.py # 早期独立 YOLO WebUI
│ ├── requirements.txt # YOLO 依赖
│ └── README.md # 独立 YOLO 摄像头说明
└── android-controller/ # 可选 Android 原生控制器
app.py、app_all_in_one.py、physical_remote/app_remote.py、esp32_camera_yolo8_project/app_camera_yolo.py 是早期拆分入口,推荐日常使用 all_in_one_webui.py。
硬件清单
核心小车:
- Seeed Studio XIAO ESP32S3 或 XIAO ESP32S3 Sense。
- 两个带编码器直流电机。
- 两块 DRV8871 直流电机驱动板。
- 外部电机电源,例如 12V 电池或电源模块。
- BNO080/BNO085 IMU 模块。
- 可选:XIAO ESP32S3 Sense 摄像头,用作小车第一视角。
实体摇杆遥控器:
- 第二块 XIAO ESP32S3 / XIAO ESP32S3 Sense。
- 摇杆模块,带
VRx、VRy、SW。 - 可选:Sense 版本板载 PDM 麦克风,用于语音方向控制。
YOLO/无人机俯拍摄像头:
- 第三块 XIAO ESP32S3 Sense 摄像头,或其他能运行项目摄像头固件的 ESP32 摄像头板。
- 也可以把这块摄像头固定在无人机、云台或球场上方支架上,拍摄整个球场。
电脑端:
- macOS / Windows / Linux 均可。
- Python 3.9+。
- 如果要跑 YOLOE,建议有性能较好的 CPU/GPU;没有 GPU 也可以先低帧率测试。
材料表(采购参考)
| 类别 | 用途 | 参考链接 | 建议数量 |
|---|---|---|---|
| 透明外壳 | 小车外壳/结构固定 | 淘宝链接 | 1 套 |
| 12V 直流电机 | 小车左右驱动轮 | 淘宝链接 | 2 个 |
| 12V 锂电池 | 电机主电源 | 淘宝链接 | 1 块 |
| ESP32 开发板 | 小车主控、遥控器、摄像头节点 | 淘宝链接 | 2-3 块 |
| 电机驱动板 | 驱动 12V 直流电机 | 天猫链接 | 2 块 |
| 12V 转 5V 降压模块 | 从电池给 ESP32/外设供电 | 淘宝链接 | 1 个 |
| 九轴 IMU | 姿态检测、航向纠偏 | 淘宝链接 | 1 个 |
这些链接是采购参考。公开 README 中只保留商品链接,不包含账号、订单或个人信息。
安全注意
本仓库已经把示例固件里的 Wi-Fi 改成占位符:
const char* WIFI_SSID = "YOUR_WIFI_SSID";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
你需要在本地烧录前改成自己的 Wi-Fi。
第一步:准备 Python 环境
在项目根目录创建虚拟环境:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
安装 All-in-One 所需依赖:
pip install ultralytics opencv-python numpy websockets
如果只运行基础小车控制,不启用 YOLO 和语音,可以先不装 ultralytics 和 websockets,但完整功能建议一次装好。
第二步:配置本地环境变量
复制示例配置:
cp .env.example .env.local
编辑 .env.local:
DASHSCOPE_API_KEY=your_dashscope_api_key_here
PUBLIC_IP=192.168.1.100
ESP32_BASE_URL=http://192.168.1.11
ROBOT_ESP32_URL=http://192.168.1.11
REMOTE_ESP32_URL=http://192.168.1.60
YOLO_CAMERA_ALLOWED_IP=192.168.1.71
ROBOT_CAMERA_ALLOWED_IP=192.168.1.11
TARGET_CLASSES=football, football gate
说明:
PUBLIC_IP是运行 Python WebUI 的电脑 IP,ESP32 摄像头会连到这台电脑。ESP32_BASE_URL/ROBOT_ESP32_URL是小车 ESP32 的地址。REMOTE_ESP32_URL是实体摇杆 ESP32 的地址。YOLO_CAMERA_ALLOWED_IP是独立 YOLO 摄像头 ESP32 的地址。DASHSCOPE_API_KEY只用于语音识别;不用语音可以留空。
.env.local 已在 .gitignore 中忽略。
第三步:小车硬件接线
编码器
电机 1:
| 电机编码器线 | XIAO ESP32S3 |
|---|---|
| 编码器 VCC | 3V3 |
| 编码器 GND | GND |
| A 相 | D0 / GPIO1 |
| B 相 | D1 / GPIO2 |
电机 2:
| 电机编码器线 | XIAO ESP32S3 |
|---|---|
| 编码器 VCC | 3V3 |
| 编码器 GND | GND |
| A 相 | D4 / GPIO5 |
| B 相 | D5 / GPIO6 |
DRV8871 电机驱动
电机 1:
| DRV8871 | XIAO ESP32S3 |
|---|---|
IN1 |
D2 / GPIO3 |
IN2 |
D3 / GPIO4 |
GND |
GND |
电机 2:
| DRV8871 | XIAO ESP32S3 |
|---|---|
IN1 |
D9 / GPIO8 |
IN2 |
D10 / GPIO9 |
GND |
GND |
两个 DRV8871 的 POWER+ / POWER- 接外部电机电源。ESP32、驱动板、电机电源必须共地。不要用 ESP32 的 3V3/5V 直接给电机供电。
BNO080/BNO085 IMU
| IMU | XIAO ESP32S3 |
|---|---|
VIN / 3V3 |
3V3 |
GND |
GND |
SDA |
D6 / GPIO43 |
SCL |
D7 / GPIO44 |
第四步:烧录小车固件
- 用 Arduino IDE 打开
esp32/esp32_motor_control/esp32_motor_control.ino。 - 安装开发板包:
esp32。 - 安装库:
ArduinoWebsockets、SparkFun BNO080 Arduino Library。 - 开发板选择
Seeed XIAO ESP32S3。 - 修改顶部配置:
const char* WIFI_SSID = "你的WiFi名称";
const char* WIFI_PASSWORD = "你的WiFi密码";
const char* PYTHON_SERVER_IP = "运行 all_in_one_webui.py 的电脑 IP";
- 上传固件,打开串口监视器,记录小车 IP。
- 把
.env.local里的ESP32_BASE_URL/ROBOT_ESP32_URL改成小车 IP。
第五步:烧录实体摇杆固件
摇杆接线:
| 摇杆模块 | XIAO ESP32S3 |
|---|---|
GND |
GND |
+5V |
3.3V-OUT |
VRx |
D10 / GPIO9 |
VRy |
D9 / GPIO8 |
SW |
D8 / GPIO7 |
烧录步骤:
- 打开
physical_remote/esp32_joystick_remote/esp32_joystick_remote.ino。 - 修改
WIFI_SSID、WIFI_PASSWORD、ROBOT_ESP32_IP、VOICE_SERVER_HOST。 - 上电时保持摇杆居中,固件会自动校准中心。
- 串口监视器里记录遥控器 IP。
- 把
.env.local的REMOTE_ESP32_URL改成遥控器 IP。
WebUI 中可以开启“实体遥控器小车转发”。开启后网页摇杆会被锁定,避免两个控制源同时发指令。
第六步:烧录独立 YOLO 摄像头
- 打开
esp32_camera_yolo8_project/esp32_camera_stream/esp32_camera_stream.ino。 - 修改:
const char* WIFI_SSID = "你的WiFi名称";
const char* WIFI_PASSWORD = "你的WiFi密码";
const char* CAMERA_WS_HOST = "运行 all_in_one_webui.py 的电脑 IP";
- 上传固件。
- 串口监视器里记录摄像头 IP。
- 把
.env.local的YOLO_CAMERA_ALLOWED_IP改成该 IP。
这块摄像头会连接:
ws://电脑IP:8081/ws/camera
如果它挂在无人机上,建议先固定在高处测试,确认能稳定拍完整球场,再上无人机飞行测试。
第七步:启动 All-in-One WebUI
在项目根目录运行:
source .venv/bin/activate
python all_in_one_webui.py
浏览器打开:
http://127.0.0.1:8000
局域网其他设备访问:
http://你的电脑IP:8000
页面包含:
- 小车控制。
- 语音摇杆控制状态。
- IMU 闭环辅助参数。
- 小车摄像头和 YOLOE 识别摄像头。
- 无人机追球路径。
- IMU 3D 姿态。
- 实体摇杆遥控器孪生。
第八步:使用 YOLO 自动路径
- 保证独立 YOLO 摄像头画面能在 WebUI 中显示。
- 在“检测类型”输入:
football, football gate
- 点击“应用检测类型”。
- 等待画面里出现小球和球门框。
- 在“无人机追球路径”区域点击“开启自动路径”。
系统会做这些事:
- 从 YOLO 检测结果里筛选
football和football gate。 - 计算两个框中心点。
- 多个球或多个球门同时出现时,选择中心距离最近的一对。
- 根据中心点向量计算
throttle和steering。 - 连续调用小车已有
/drive?throttle=&steering=接口。 - 识别超时、到达球门中心或关闭自动路径时停车。
常用环境变量:
| 变量 | 默认值 | 说明 |
|---|---|---|
AUTO_PATH_ENABLED |
0 |
启动时是否自动开启路径控制 |
AUTO_PATH_BALL_CLASSES |
football, sports ball, ball |
识别为球的类别 |
AUTO_PATH_GATE_CLASSES |
football gate, gate, goal |
识别为球门的类别 |
AUTO_PATH_INTERVAL_MS |
160 |
自动发送路径指令间隔 |
AUTO_PATH_STALE_MS |
900 |
检测结果超时停车时间 |
AUTO_PATH_MIN_SPEED |
18 |
最小速度 |
AUTO_PATH_MAX_SPEED |
65 |
最大速度 |
AUTO_PATH_STEERING_LIMIT |
80 |
转向限幅 |
AUTO_PATH_DEADZONE_RATIO |
0.04 |
中心点死区,占画面对角线比例 |
AUTO_PATH_ARRIVAL_RATIO |
0.06 |
认为到达的距离,占画面对角线比例 |
语音控制
语音链路是:
实体摇杆 ESP32 麦克风 -> voice_drive_realtime.py -> DashScope Realtime ASR -> all_in_one_webui.py -> 小车 /drive
启动前设置 .env.local 中的 DASHSCOPE_API_KEY,然后运行:
python all_in_one_webui.py
all_in_one_webui.py 默认会内置启动语音 sidecar。识别到“前进、后退、向左、向右、停止、左前、右后”等方向词后,会转换成小车摇杆向量。
Android 控制器
android-controller/ 是可选原生 Android 工程。用 Android Studio 打开该目录,等待 Gradle 同步后运行到手机。
它适合手机和 ESP32 在同一热点或局域网下直连,不依赖 Python WebUI。首次构建会自动生成 android-controller/build/、android-controller/app/build/ 和 android-controller/local.properties,这些都不应该提交。
常见问题
YOLO 首次运行很慢
首次运行可能会下载模型权重。模型文件如 *.pt 已被 .gitignore 忽略,不建议上传 GitHub。
WebUI 看不到摄像头
检查三点:
- ESP32 摄像头串口里是否显示已连接 WebSocket。
CAMERA_WS_HOST是否是电脑局域网 IP,而不是127.0.0.1。.env.local里的YOLO_CAMERA_ALLOWED_IP/ROBOT_CAMERA_ALLOWED_IP是否和设备实际 IP 一致。
小车不动
检查:
- ESP32 串口是否打印了正确 IP。
- 浏览器打开
http://小车IP/status是否有 JSON 返回。 - 电机电源是否单独供电。
- ESP32、DRV8871、电机电源是否共地。
- WebUI 里是否开启了实体遥控器转发或自动路径,导致网页手动控制被锁定。
自动路径方向反了
无人机/摄像头安装方向会影响画面坐标。先把摄像头固定,观察画面箭头和小车实际方向。如果左右相反,可以先在机械安装上旋转摄像头或调整小车前进方向;后续也可以在 WebUI 层增加方向镜像参数。
API 简表
All-in-One WebUI:
GET /:主页面。GET /api/status:代理小车状态。GET /api/imu-state:IMU 状态。GET /api/camera-state:小车摄像头状态。GET /api/yolo-camera-state:YOLO 摄像头状态。GET /api/yolo-state:YOLO 检测状态。GET /api/auto-path-state:自动路径状态。POST /api/auto-path-config:开启/关闭自动路径或调整参数。POST /api/yolo-config:更新检测类别。POST /api/voice-drive:语音方向命令入口。POST /imu:小车 ESP32 上报 IMU JSON。
小车 ESP32:
GET /statusPOST /drive?throttle=0&steering=0POST /pwm?motor=1&value=50POST /stopPOST /config?...
实体摇杆 ESP32:
GET /statusPOST /stopPOST /recalibratePOST /forward?enabled=1POST /orientation?rotate=90POST /mode?assistMode=2
English
This is a complete experimental project for a small football robot / ball robot. A Python WebUI runs on a computer and coordinates the robot motors, IMU pose, two camera streams, YOLO / YOLOE detection, a physical joystick remote, voice control, and a drone top-view path controller that drives a football toward a football gate.
The recommended entry point is all_in_one_webui.py. It combines web control, camera receiving, YOLOE inference, remote-controller proxying, IMU visualization, voice direction control, and automatic path planning in one page.
What It Can Do
- Control a two-motor robot with PWM debugging, differential joystick driving, forward / backward / turning / stop commands.
- Read encoder feedback, RPM, and IMU pose, then visualize the robot pose in 3D in the browser.
- Receive both the robot camera stream and an independent YOLO camera stream.
- Detect targets such as
footballandfootball gatewith YOLO / YOLOE. - Match the center points of the detected football and football gate boxes, then compute continuous forward / backward / left / right path commands.
- Send path commands through the existing
/drive?throttle=&steering=API, without changing the stick or robot firmware protocol. - Support a physical joystick remote, with WebUI controls to enable or disable forwarding to the robot.
- Support voice direction control through the XIAO ESP32S3 Sense onboard microphone and DashScope Realtime ASR.
- Provide an optional native Android controller for direct phone-to-ESP32 control.
Project Structure
.
├── all_in_one_webui.py # Recommended all-in-one WebUI entry point
├── voice_drive_realtime.py # Voice sidecar for ESP32 microphone PCM audio
├── voice_requirements.txt # Voice sidecar dependency list
├── .env.example # Local environment template without real secrets
├── esp32/
│ └── esp32_motor_control/
│ └── esp32_motor_control.ino # Robot motor, encoder, IMU, camera firmware
├── physical_remote/
│ ├── esp32_joystick_remote/
│ │ └── esp32_joystick_remote.ino # Physical joystick remote firmware
│ └── README.md # Standalone remote-controller notes
├── esp32_camera_yolo8_project/
│ ├── esp32_camera_stream/
│ │ └── esp32_camera_stream.ino # Independent YOLO camera firmware
│ ├── app_camera_yolo.py # Earlier standalone YOLO WebUI
│ ├── requirements.txt # YOLO dependencies
│ └── README.md # Standalone YOLO camera notes
└── android-controller/ # Optional native Android controller
app.py, app_all_in_one.py, physical_remote/app_remote.py, and esp32_camera_yolo8_project/app_camera_yolo.py are earlier split entry points. For normal use, run all_in_one_webui.py.
Hardware List
Core robot:
- Seeed Studio XIAO ESP32S3 or XIAO ESP32S3 Sense.
- Two DC motors with encoders.
- Two DRV8871 DC motor driver boards.
- External motor power supply, such as a 12V battery or power module.
- BNO080 / BNO085 IMU module.
- Optional XIAO ESP32S3 Sense camera for first-person robot view.
Physical joystick remote:
- A second XIAO ESP32S3 / XIAO ESP32S3 Sense.
- Joystick module with
VRx,VRy, andSWpins. - Optional Sense onboard PDM microphone for voice control.
YOLO / drone top-view camera:
- A third XIAO ESP32S3 Sense camera, or another ESP32 camera board that can run the camera firmware.
- The camera can be mounted on a drone, a gimbal, or an overhead frame to capture the whole field.
Computer side:
- macOS / Windows / Linux.
- Python 3.9+.
- A decent CPU / GPU is recommended for YOLOE. CPU-only testing is possible at lower frame rates.
Bill of Materials
| Item | Purpose | Reference Link | Suggested Qty |
|---|---|---|---|
| Transparent shell | Robot body / mechanical mounting | Taobao | 1 set |
| 12V DC motor | Left and right drive wheels | Taobao | 2 |
| 12V lithium battery | Main motor power | Taobao | 1 |
| ESP32 board | Robot main controller, remote controller, camera node | Taobao | 2-3 |
| Motor driver board | Drive 12V DC motors | Tmall | 2 |
| 12V-to-5V buck module | Power ESP32 / peripherals from the battery | Taobao | 1 |
| 9-axis IMU | Pose sensing and heading correction | Taobao | 1 |
These links are purchase references only. The public README keeps only product links and does not include account, order, or personal information.
Security Notes
The example firmware uses placeholder Wi-Fi credentials:
const char* WIFI_SSID = "YOUR_WIFI_SSID";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
Before flashing locally, replace them with your own Wi-Fi credentials. Do not commit real credentials to a public repository.
Step 1: Prepare Python
Create a virtual environment in the project root:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
Install the all-in-one dependencies:
pip install ultralytics opencv-python numpy websockets
If you only need basic robot control and do not use YOLO or voice control, you can skip ultralytics and websockets at first. For the full feature set, install everything.
Step 2: Configure Local Environment Variables
Copy the example configuration:
cp .env.example .env.local
Edit .env.local:
DASHSCOPE_API_KEY=your_dashscope_api_key_here
PUBLIC_IP=192.168.1.100
ESP32_BASE_URL=http://192.168.1.11
ROBOT_ESP32_URL=http://192.168.1.11
REMOTE_ESP32_URL=http://192.168.1.60
YOLO_CAMERA_ALLOWED_IP=192.168.1.71
ROBOT_CAMERA_ALLOWED_IP=192.168.1.11
TARGET_CLASSES=football, football gate
Notes:
PUBLIC_IPis the LAN IP of the computer running the Python WebUI.ESP32_BASE_URL/ROBOT_ESP32_URLpoint to the robot ESP32.REMOTE_ESP32_URLpoints to the physical joystick ESP32.YOLO_CAMERA_ALLOWED_IPpoints to the independent YOLO camera ESP32.DASHSCOPE_API_KEYis only required for voice recognition.
.env.local is ignored by .gitignore.
Step 3: Wire the Robot Hardware
Encoders
Motor 1:
| Motor encoder wire | XIAO ESP32S3 |
|---|---|
| Encoder VCC | 3V3 |
| Encoder GND | GND |
| Phase A | D0 / GPIO1 |
| Phase B | D1 / GPIO2 |
Motor 2:
| Motor encoder wire | XIAO ESP32S3 |
|---|---|
| Encoder VCC | 3V3 |
| Encoder GND | GND |
| Phase A | D4 / GPIO5 |
| Phase B | D5 / GPIO6 |
DRV8871 Motor Drivers
Motor 1:
| DRV8871 | XIAO ESP32S3 |
|---|---|
IN1 |
D2 / GPIO3 |
IN2 |
D3 / GPIO4 |
GND |
GND |
Motor 2:
| DRV8871 | XIAO ESP32S3 |
|---|---|
IN1 |
D9 / GPIO8 |
IN2 |
D10 / GPIO9 |
GND |
GND |
Connect each DRV8871 POWER+ / POWER- to the external motor power supply. ESP32, motor drivers, and motor power ground must be common. Do not power the motors directly from the ESP32 3V3/5V pins.
BNO080 / BNO085 IMU
| IMU | XIAO ESP32S3 |
|---|---|
VIN / 3V3 |
3V3 |
GND |
GND |
SDA |
D6 / GPIO43 |
SCL |
D7 / GPIO44 |
Step 4: Flash the Robot Firmware
- Open
esp32/esp32_motor_control/esp32_motor_control.inoin Arduino IDE. - Install the
esp32board package. - Install
ArduinoWebsocketsandSparkFun BNO080 Arduino Library. - Select
Seeed XIAO ESP32S3as the board. - Update the top configuration:
const char* WIFI_SSID = "Your Wi-Fi SSID";
const char* WIFI_PASSWORD = "Your Wi-Fi password";
const char* PYTHON_SERVER_IP = "IP of the computer running all_in_one_webui.py";
- Upload the firmware and open Serial Monitor to record the robot IP.
- Update
ESP32_BASE_URL/ROBOT_ESP32_URLin.env.local.
Step 5: Flash the Physical Joystick Firmware
Joystick wiring:
| Joystick module | XIAO ESP32S3 |
|---|---|
GND |
GND |
+5V |
3.3V-OUT |
VRx |
D10 / GPIO9 |
VRy |
D9 / GPIO8 |
SW |
D8 / GPIO7 |
Flash steps:
- Open
physical_remote/esp32_joystick_remote/esp32_joystick_remote.ino. - Update
WIFI_SSID,WIFI_PASSWORD,ROBOT_ESP32_IP, andVOICE_SERVER_HOST. - Keep the joystick centered while powering on. The firmware calibrates the center automatically.
- Record the remote-controller IP from Serial Monitor.
- Update
REMOTE_ESP32_URLin.env.local.
The WebUI can enable physical-remote forwarding. Once enabled, the browser joystick is locked to avoid two control sources sending commands at the same time.
Step 6: Flash the Independent YOLO Camera
- Open
esp32_camera_yolo8_project/esp32_camera_stream/esp32_camera_stream.ino. - Update:
const char* WIFI_SSID = "Your Wi-Fi SSID";
const char* WIFI_PASSWORD = "Your Wi-Fi password";
const char* CAMERA_WS_HOST = "IP of the computer running all_in_one_webui.py";
- Upload the firmware.
- Record the camera IP from Serial Monitor.
- Update
YOLO_CAMERA_ALLOWED_IPin.env.local.
The camera connects to:
ws://computer-ip:8081/ws/camera
If the camera is mounted on a drone, test it from a fixed overhead position first to confirm it can capture the whole field before flight testing.
Step 7: Start the All-in-One WebUI
Run from the project root:
source .venv/bin/activate
python all_in_one_webui.py
Open in browser:
http://127.0.0.1:8000
Other devices on the LAN can open:
http://your-computer-ip:8000
The page includes robot control, voice status, IMU assist parameters, robot camera, YOLOE camera, drone path planning, 3D IMU pose, and a physical remote twin.
Step 8: Use YOLO Automatic Path Control
- Make sure the independent YOLO camera stream appears in the WebUI.
- Set detection classes to:
football, football gate
- Click
Apply detection classes. - Wait until both the ball and gate box appear.
- Click
Enable automatic pathin the drone path section.
The system will:
- Filter
footballandfootball gatefrom YOLO detections. - Compute the center point of each box.
- Pick the closest ball-gate pair if multiple candidates appear.
- Convert the center-point vector into
throttleandsteering. - Continuously call the existing robot
/drive?throttle=&steering=API. - Stop when detections are stale, the ball reaches the gate center, or automatic path is disabled.
Common environment variables:
| Variable | Default | Description |
|---|---|---|
AUTO_PATH_ENABLED |
0 |
Enable automatic path on startup |
AUTO_PATH_BALL_CLASSES |
football, sports ball, ball |
Classes treated as the ball |
AUTO_PATH_GATE_CLASSES |
football gate, gate, goal |
Classes treated as the gate |
AUTO_PATH_INTERVAL_MS |
160 |
Interval for sending path commands |
AUTO_PATH_STALE_MS |
900 |
Stop if detection results are older than this |
AUTO_PATH_MIN_SPEED |
18 |
Minimum speed |
AUTO_PATH_MAX_SPEED |
65 |
Maximum speed |
AUTO_PATH_STEERING_LIMIT |
80 |
Steering clamp |
AUTO_PATH_DEADZONE_RATIO |
0.04 |
Center deadzone as image diagonal ratio |
AUTO_PATH_ARRIVAL_RATIO |
0.06 |
Arrival radius as image diagonal ratio |
Voice Control
Voice pipeline:
Physical joystick ESP32 microphone -> voice_drive_realtime.py -> DashScope Realtime ASR -> all_in_one_webui.py -> robot /drive
Set DASHSCOPE_API_KEY in .env.local, then run:
python all_in_one_webui.py
all_in_one_webui.py starts the voice sidecar by default. Direction words such as forward, backward, left, right, stop, left-forward, and right-backward are converted into robot joystick vectors.
Android Controller
android-controller/ is an optional native Android project. Open it in Android Studio, wait for Gradle sync, then run it on a phone.
It is designed for direct phone-to-ESP32 control on the same hotspot or LAN and does not require the Python WebUI. Android build/, .gradle/, and local.properties files should not be committed.
FAQ
YOLO is slow on the first run
The first run may download model weights. Files such as *.pt are ignored by .gitignore and should not be uploaded to GitHub.
The WebUI cannot see the camera
Check:
- Whether the ESP32 camera Serial Monitor says the WebSocket is connected.
- Whether
CAMERA_WS_HOSTis the computer LAN IP, not127.0.0.1. - Whether
YOLO_CAMERA_ALLOWED_IP/ROBOT_CAMERA_ALLOWED_IPin.env.localmatch the actual device IPs.
The robot does not move
Check:
- Whether the ESP32 printed the correct IP in Serial Monitor.
- Whether
http://robot-ip/statusreturns JSON in a browser. - Whether the motors have a separate power supply.
- Whether ESP32, DRV8871, and the motor power supply share ground.
- Whether physical remote forwarding or automatic path control is enabled, which locks browser manual control.
Automatic path direction is reversed
The drone / camera mounting orientation affects image coordinates. Fix the camera first and compare the overlay arrow with the robot motion. If left and right are reversed, rotate the camera mechanically or adjust the robot forward direction. A WebUI-level mirror parameter can also be added later.
API Summary
All-in-One WebUI:
GET /: main page.GET /api/status: proxy robot status.GET /api/imu-state: IMU status.GET /api/camera-state: robot camera status.GET /api/yolo-camera-state: YOLO camera status.GET /api/yolo-state: YOLO detection status.GET /api/auto-path-state: automatic path status.POST /api/auto-path-config: enable / disable automatic path or adjust parameters.POST /api/yolo-config: update detection classes.POST /api/voice-drive: voice direction command endpoint.POST /imu: robot ESP32 IMU JSON upload endpoint.
Robot ESP32:
GET /statusPOST /drive?throttle=0&steering=0POST /pwm?motor=1&value=50POST /stopPOST /config?...
Physical joystick ESP32:
GET /statusPOST /stopPOST /recalibratePOST /forward?enabled=1POST /orientation?rotate=90POST /mode?assistMode=2