# mrbuchixiangcai/micro-wheeled_leg-robot architecture

> Architecture diagram of the GitHub repository mrbuchixiangcai/micro-wheeled_leg-robot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrbuchixiangcai/micro-wheeled_leg-robot
- Repository: https://github.com/mrbuchixiangcai/micro-wheeled_leg-robot

## Overview

##### Project Type and Purpose
- This is a tightly integrated robotics project combining:
- Mechanical design (CAD models, 3D-printed, CNC-machined, and carbon-fiber panels).
- Electronic hardware (four custom PCBs, sensors, and actuators).
- Embedded software (ESP32-based firmware using Arduino IDE and simpleFOC motor control).
- Network/Web interface (WiFi AP/STA with WebSocket JSON communication and browser-based UI).

##### File Structure
- 1.RobotModel: CAD source (`OriginalRobotModel.stp`); manufactured parts separated into 3D printing, CNC, and panel cutting; purchased-parts BOM.
- 2.Hardware: Four PCB projects (Controller, Encoder, IMU, ServoDebug) each with BOM, Gerber, schematic, and source JSON.
- README files describe firmware dependencies, wiring, and usage.

##### Extract Architectural Insights from README
- Main controller: ESP32 + L6234 brushless driver; communicates with AS5600 encoder and MPU6050 IMU over I²C; servo bus uses time-division multiplexing; WebSocket server in firmware serves a web UI stored in flash.
- Firmware built in Arduino IDE leveraging `simpleFOC` and a custom WebSocket library.
- Remote clients (Chrome/Firefox on any OS) connect via WebSocket to control the robot.

1. Mechanical Assembly
– CAD model (.stp) → Manufacturing pipelines (3D print, CNC, panels).
2. Power Subsystem
– Battery pack → XH2.54 connector → 5 V/3.3 V regulators on main PCB.
3. Electronic Hardware
– Main Control PCB (ESP32 + L6234 driver)
– Encoder PCB (AS5600)
– IMU PCB (MPU6050)
– ServoDebug PCB (Serial mux board)
4. Actuators & Sensors
– Brushless wheel motors
– FEETECH bus servos (legs)
– Encoders (AS5600)
– IMU (MPU6050)
5. Embedded Firmware Layer
– Arduino Sketch
– Hardware abstraction: simpleFOC motor driver, I²C driver, serial bus driver, WebSocket server, JSON parser
– Configuration (FEETECH debug settings, encoder calibration)
6. Network & UI
– WiFi AP/STA modes (ESP32 WiFi stack)
– Web page (HTML/JS) stored in flash → served over WebSocket
– Remote client (Browser) with joystick UI
7. External Tools & Libraries
– simpleFOC library
– WebSocket Arduino library
– LCEDA PCB toolchain (for PCB sources)
– FEETECH Debug Software (servo config)

- Battery → Main Control PCB power inputs → voltage regulators → ESP32 & sensors
- ESP32 ↔ AS5600 (I²C lines)
- ESP32 ↔ MPU6050 (same I²C bus)
- ESP32 → L6234 driver → Brushless motors (FOC control commands)
- ESP32 ↔ FEETECH servos (time-division multiplexed serial)
- ESP32 WiFi stack → WebSocket → Browser UI
- Browser → Joystick commands → ESP32 → motor/servo control loop
- Firmware modules ↔ external libraries (simpleFOC, WebSocket, JSON)

c. Architectural Patterns & Principles
- Layered architecture in firmware:
Presentation (WebSocket + web UI)
Control (command dispatcher)
Hardware abstraction (motor, sensor drivers)
- Separation of concerns:
Mechanical CAD → manufacturing
Electronics design → independent PCB modules
Firmware → cross-device abstraction via libraries
- Use of bus multiplexing for servo debugging

d. Key Technologies & Frameworks
- ESP32 (WiFi + dual-core MCU)
- Arduino IDE
- simpleFOC library (brushless control)
- WebSocket + JSON (realtime remote control)
- AS5600, MPU6050 sensors
- L6234PD013TR motor driver
- LCEDA (PCB design)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Mechanical Assembly
    subgraph "Mechanical Assembly"
        MA["CAD Model (.stp)\nand Manufacturing"]:::mech
    end

    %% Power Subsystem
    Battery["Battery Pack"]:::hardware
    subgraph "Power Subsystem"
        PS["Voltage Regulators\n(on Main PCB)"]:::hardware
    end

    %% Electronic Hardware
    subgraph "Electronic Hardware"
        PCB1["Main Control PCB\n(ESP32 + L6234)"]:::hardware
        PCB2["Encoder PCB\n(AS5600)"]:::hardware
        PCB3["IMU PCB\n(MPU6050)"]:::hardware
        PCB4["ServoDebug PCB\n(Serial Mux)"]:::hardware
    end

    %% Actuators & Sensors
    subgraph "Actuators & Sensors"
        Motors["Brushless Wheel Motors"]:::hardware
        Servos["FEETECH Bus Servos"]:::hardware
    end

    %% Firmware Layer
    subgraph "Firmware Layer"
        Sketch["Arduino Sketch"]:::firmware
        Libs["simpleFOC, WebSocket, JSON"]:::firmware
    end

    %% Network & UI
    subgraph "Network & UI"
        WebUI["WebSocket Server + Web UI"]:::network
        Browser["Browser Client\n(Joystick UI)"]:::network
    end

    %% Documentation
    Docs["Project Documentation"]:::docs
    Readme["Firmware Deps & Notes"]:::docs

    %% Connections
    Battery -->|"power"| PS
    PS --> PCB1
    PS --> PCB2
    PS --> PCB3
    PS --> PCB4

    PCB1 -->|"I2C"| PCB2
    PCB1 -->|"I2C"| PCB3
    PCB1 -->|"Serial (TDM)"| PCB4
    PCB1 -->|"FOC PWM"| Motors
    PCB1 -->|"Serial Bus"| Servos

    PCB1 --> Sketch
    Sketch --> Libs
    Sketch --> WebUI

    WebUI --> Browser
    Browser -->|"WebSocket/JSON"| WebUI

    Docs -.-> PCB1
    Docs -.-> Sketch
    Readme -.-> Sketch

    %% Click Events
    click MA "https://github.com/mrbuchixiangcai/micro-wheeled_leg-robot/blob/master/1.RobotModel"
    click PS "https://github.com/mrbuchixiangcai/micro-wheeled_leg-robot/blob/master/2.Hardware/1.ControllerPCB/Schematic.pdf"
    click PCB1 "https://github.com/mrbuchixiangcai/micro-wheeled_leg-robot/blob/master/2.Hardware/1.ControllerPCB"
    click PCB2 "https://github.com/mrbuchixiangcai/micro-wheeled_leg-robot/blob/master/2.Hardware/2.EncoderPCB"
    click PCB3 "https://github.com/mrbuchixiangcai/micro-wheeled_leg-robot/blob/master/2.Hardware/3.IMUPCB"
    click PCB4 "https://github.com/mrbuchixiangcai/micro-wheeled_leg-robot/blob/master/2.Hardware/4.ServoDebugPCB"
    click Docs "https://github.com/mrbuchixiangcai/micro-wheeled_leg-robot/blob/master/4.Docs"
    click Readme "https://github.com/mrbuchixiangcai/micro-wheeled_leg-robot/blob/master/README.md"

    %% Styles
    classDef mech fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef hardware fill:#90EE90,stroke:#000,stroke-width:1px
    classDef firmware fill:#FFA500,stroke:#000,stroke-width:1px
    classDef network fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef docs fill:#EEEEEE,stroke:#000,stroke-width:1px
```
