# tangwp1588/mini-mechanum-wheel-robot architecture

> Architecture diagram of the GitHub repository tangwp1588/mini-mechanum-wheel-robot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tangwp1588/mini-mechanum-wheel-robot
- Repository: https://github.com/tangwp1588/mini-mechanum-wheel-robot

## Overview

This is STM32 firmware for a four-wheel mecanum robot. The documented runtime workflow accepts ESP32 gamepad commands, applies drive-mode and yaw correction, computes wheel targets, closes each wheel’s speed loop using encoder feedback, and drives the motors. It also provides an ST7789 telemetry and PID-tuning interface. The README documents the control stages; excerpts confirm startup, controller handling, UART, and display integration. Several control and UI implementation details were not sampled, so those links rely on README evidence.

Main entry points: [`Core/Src/controller_input.c`](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/controller_input.c) (Controller processing), [`Core/Src/uart_handler.c`](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/uart_handler.c) (Gamepad UART), [`Core/Src/pid.c`](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/pid.c) (Yaw correction), [`Core/Src/kinematics.c`](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/kinematics.c) (Mecanum kinematics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Runtime startup"]
  node_startup_main["Firmware startup<br/>[main.c]"]
end

subgraph group_input["Command and sensing"]
  node_input_uart["Gamepad UART<br/>[uart_handler.c]"]
  node_input_process["Controller processing<br/>[controller_input.c]"]
  node_imu_driver["IMU interface<br/>[bno08x.c]"]
end

subgraph group_control["Motion control"]
  node_orientation["Yaw correction<br/>[pid.c]"]
  node_kinematics["Mecanum kinematics<br/>[kinematics.c]"]
  node_speed_pid["Wheel speed PID<br/>[pid.c]"]
end

subgraph group_hardware["Hardware interfaces"]
  node_motor_output["Motor output<br/>[motor.c]"]
  node_encoder["Encoder feedback<br/>[encoder.c]"]
end

subgraph group_ui["Display and tuning"]
  node_display_driver["ST7789 display<br/>[st7789.c]"]
  node_menu["Telemetry and PID menu<br/>[menu.c]"]
end

node_operator(("Remote operator"))
node_esp32{{"ESP32 wireless"}}
node_imu{{"BNO085 IMU"}}
node_driver{{"TB6612 driver"}}
node_wheels{{"Four encoder motors"}}

node_operator -->|"sends commands"| node_esp32
node_esp32 -->|"transmits input"| node_input_uart
node_startup_main -->|"initializes UART"| node_input_uart
node_input_uart -.->|"provides controller data"| node_input_process
node_imu -->|"provides heading"| node_imu_driver
node_input_process -->|"enables correction"| node_orientation
node_imu_driver -->|"supplies yaw"| node_orientation
node_orientation -->|"corrects command"| node_kinematics
node_input_process -->|"selects drive mode"| node_kinematics
node_kinematics -->|"sets wheel targets"| node_speed_pid
node_encoder -->|"feeds speed feedback"| node_speed_pid
node_speed_pid -->|"sets motor drive"| node_motor_output
node_motor_output -->|"drives outputs"| node_driver
node_driver -->|"powers motors"| node_wheels
node_startup_main -->|"initializes display"| node_display_driver
node_menu -.->|"renders telemetry"| node_display_driver
node_operator -->|"tunes PID"| node_menu

click node_startup_main "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/main.c"
click node_input_uart "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/uart_handler.c"
click node_input_process "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/controller_input.c"
click node_imu_driver "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/bno08x.c"
click node_orientation "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/pid.c"
click node_kinematics "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/kinematics.c"
click node_speed_pid "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/pid.c"
click node_motor_output "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/motor.c"
click node_encoder "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/encoder.c"
click node_display_driver "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Drivers/ST7789/st7789.c"
click node_menu "https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/menu.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup_main toneBlue
class node_input_uart,node_input_process,node_imu_driver toneAmber
class node_orientation,node_kinematics,node_speed_pid toneMint
class node_motor_output,node_encoder toneRose
class node_display_driver,node_menu,node_operator,node_esp32,node_imu,node_driver,node_wheels toneIndigo
```

## Components

### Runtime startup

- [Firmware startup](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/main.c): `Core/Src/main.c`

### Command and sensing

- [Gamepad UART](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/uart_handler.c): `Core/Src/uart_handler.c`
- [Controller processing](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/controller_input.c): `Core/Src/controller_input.c`
- [IMU interface](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/bno08x.c): `Core/Src/bno08x.c`

### Motion control

- [Yaw correction](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/pid.c): `Core/Src/pid.c`
- [Mecanum kinematics](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/kinematics.c): `Core/Src/kinematics.c`
- [Wheel speed PID](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/pid.c): `Core/Src/pid.c`

### Hardware interfaces

- [Motor output](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/motor.c): `Core/Src/motor.c`
- [Encoder feedback](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/encoder.c): `Core/Src/encoder.c`

### Display and tuning

- [ST7789 display](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Drivers/ST7789/st7789.c): `Drivers/ST7789/st7789.c`
- [Telemetry and PID menu](https://github.com/tangwp1588/mini-mechanum-wheel-robot/blob/main/Core/Src/menu.c): `Core/Src/menu.c`

### Other components

- **Remote operator**
- **ESP32 wireless**
- **BNO085 IMU**
- **TB6612 driver**
- **Four encoder motors**

## Connections

- Remote operator → ESP32 wireless: sends commands (evidence: `README.md`)
- ESP32 wireless → Gamepad UART: transmits input (evidence: `README.md`)
- Firmware startup → Gamepad UART: initializes UART (evidence: `Core/Src/main.c`)
- Gamepad UART → Controller processing: provides controller data
- BNO085 IMU → IMU interface: provides heading (evidence: `README.md`)
- Controller processing → Yaw correction: enables correction (evidence: `Core/Src/controller_input.c`)
- IMU interface → Yaw correction: supplies yaw (evidence: `README.md`)
- Yaw correction → Mecanum kinematics: corrects command (evidence: `README.md`)
- Controller processing → Mecanum kinematics: selects drive mode (evidence: `README.md`)
- Mecanum kinematics → Wheel speed PID: sets wheel targets (evidence: `README.md`)
- Encoder feedback → Wheel speed PID: feeds speed feedback (evidence: `README.md`)
- Wheel speed PID → Motor output: sets motor drive (evidence: `README.md`)
- Motor output → TB6612 driver: drives outputs (evidence: `README.md`)
- TB6612 driver → Four encoder motors: powers motors (evidence: `README.md`)
- Firmware startup → ST7789 display: initializes display (evidence: `Core/Src/main.c`)
- Telemetry and PID menu → ST7789 display: renders telemetry
- Remote operator → Telemetry and PID menu: tunes PID (evidence: `README.md`)
