An autonomous robot control system built on STM32H7 microcontroller with camera-based and encoder-based navigation, and sensor fusion.
The active production firmware for the STM32H745 microcontroller running on the Cortex-M7 core.
Key Features:
- CAN-based sensor data consumption
- Camera-based waypoint navigation system
- Encoder-based odometry and position tracking
- PWM motor control
- UART command interface
Structure:
CM7/Core/Src/main.c- Main control loop, navigation logic, sensor processingDrivers/- STM32 HAL drivers
CAN Message IDs:
0x125- Motor control commands0x126- Angular velocity (IMU gyroscope)0x127- Linear acceleration (IMU accelerometer)0x128- Camera position data (x, y, width)
ESP32-C3 based sensor aggregation and communication hub.
Purpose: Collects data from multiple sensors and forwards it to the STM32H7 via CAN bus.
Components:
sensor_hub.ino- Main sketch integrating all sensorsble_server.ino- BLE server for remote control (extra feature)ble_client.h- BLE client for camera position dataimu.ino- MPU6050 IMU data acquisitionencoder.ino- Wheel encoder reading
Hardware:
- ESP32-C3 microcontroller
- MCP2515 CAN controller
- MPU6050 IMU sensor
- Optical encoders
Optional PC-based wireless control interface using BLE.
Files:
-
ble_client.py- Main controller connecting to sensor hub- WASD keyboard control
- Gamepad support (Xbox/PS controllers)
- Real-time throttle/steering commands
- Configurable scaling factors
-
combined_input.py- Unified keyboard + gamepad input handler- Button mapping and axis normalization
- Rising/falling edge detection
- Toggle states
-
keybrd.py- Legacy keyboard-only handler -
scales.txt- Control sensitivity configuration0.7 # Throttle scale 0.6 # Steering scale
Usage:
cd ble_controller
python3 ble_client.py
# Use WASD or gamepad to control
# Press X or A button to toggle LED
# ESC to exitTesting and development utilities.
Contents:
ble_client/ble_client.ino- Standalone BLE-to-CAN camera bridge- Used for testing camera integration independently
- Has fake data mode for STM32 testing without hardware
- Simpler alternative to full sensor_hub for debugging
When to use:
- Testing camera-based navigation without full system
- Debugging CAN message format (0x128)
- Simulating camera input with
ENABLE_FAKE_DATA = true
- Open
stm32_h7_reto/in STM32CubeIDE - Build both CM7 and CM4 cores
- Flash to STM32H745 Nucleo board
- Open
sensor_hub/sensor_hub.inoin Arduino IDE - Select ESP32-C3 board
- Install libraries: BLEDevice, Adafruit_MPU6050, mcp_can
- Upload to ESP32-C3
- Ensure sensor hub is running with BLE server enabled
- Install Python dependencies:
pip install bleak pynput inputs
- Run the controller:
cd py python3 ble_client.py
- Camera-based waypoint navigation - Tracks objects via BLE camera feed
- Encoder-based waypoint system - Odometry-based path following
- IMU orientation and motion tracking
- Wheel encoder position estimation
- Camera object tracking and position
- CAN bus for sensor data (500kbps)
- BLE for camera data transmission
- UART for debugging and commands
- Manual remote control - Direct keyboard/gamepad control via BLE (optional)
Recent development timeline:
377d7cb - camera-based waypoint event system working
20ea45f - camera data being received, encoder-based waypoint system working
4d67993 - added encoder-based waypointLoop
0ceab1d - sending raw IMU values via CAN
3d2152a - remote control working perfectly!
- STM32H745ZI-Q Nucleo board (dual-core)
- ESP32-C3 microcontroller
- MCP2515 CAN controller module
- MPU6050 IMU sensor
- Optical encoders
- Motor drivers (ESC compatible)
- BLE camera (phone or ESP32-CAM)
Current branch: feature/thirdDelivery
Main branch: main
Last Updated: November 24, 2025