# jobitjoseph/litewing architecture

> Architecture diagram of the GitHub repository jobitjoseph/litewing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jobitjoseph/litewing
- Repository: https://github.com/jobitjoseph/litewing

## Overview

1. LiteWing is a multi-part drone platform, not a single app. The repository contains the onboard flight firmware, ground-control software, Arduino prototypes, PCB designs, and prebuilt flashing images. The architectural center is the ESP32-S3-based flight controller.

2. The main runtime is an ESP-IDF/CMake firmware build. The `main/` entrypoint boots the system, while `components/` holds reusable modules and drivers. This is a componentized embedded system built on FreeRTOS-style tasking and ESP32 hardware abstraction.

3. The flight stack is largely a Crazyflie-derived port under `components/core/crazyflie/`. That subsystem contains the core control loop and state machine: commander input, estimator, attitude/position controllers, stabilizer, logging, parameters, and CRTP-style communication services.

4. Sensor acquisition sits below the control stack in `components/drivers/` and the Crazyflie HAL layer. The hardware set includes IMU support, barometer, optical flow, range finders, Wi-Fi, motors, LEDs, buzzer, and deck interfaces. These drivers feed raw measurements upward to estimation and telemetry downward to actuation.

5. The estimation boundary is important: IMU, altitude, optical flow, and range data are fused before control decisions are made. The repo includes complementary and Kalman estimator paths, plus dead-reckoning and position-hold experiments in Python that mirror or validate the onboard estimator behavior.

6. Actuation is separated from sensing. Motor control lives in `components/drivers/general/motors/`, while power distribution and stabilizer logic are in the Crazyflie modules. That boundary is where flight commands become individual motor outputs.

7. Communication is centered on wireless control rather than a traditional tethered ground station. The firmware includes ESP-NOW and Wi-Fi support, and the Python utilities contain joystick, Bluetooth, and flight-control scripts that generate control packets or telemetry requests. The architecture expects an external operator device to send commands over a short-range link.

8. The Python tree is the main offboard control and testing layer. It includes one-off flight behaviors, sensor readers, dead-reckoning experiments, takeoff/height-hold flows, and diagnostics for IMU, ToF, optical flow, battery voltage, and motion flow. These scripts are not one product; they are operational tools around the same onboard vehicle.

9. `Python-Scripts/crazyflie-clients-python/` is a substantial ground-control client fork. It provides a GUI, headless client, ZMQ-based automation, input device handling, log/param tools, and calibration/tuning tabs. In the diagram, this is the operator console layer connecting to the drone through the communication stack.

10. Arduino sketches in `LiteWing-Arduino/` appear to be legacy or alternate control implementations. They include drone flight logic, ESP-NOW joystick control, and a ground-station HTML page. These are useful as separate experimental control paths, but they are not the primary firmware architecture.

11. The hardware subtree defines the physical platform and its revisions. KiCad projects for LiteWing V2.5C and V2.6C, BOMs, Gerbers, 3D models, and datasheets show the board-level boundary: ESP32-S3 module, sensor chips, motor connectors, USB-C, and support circuitry. This is the hardware target for the firmware and the source of all sensor/actuator interfaces.

12. The repository also ships binary firmware images under `LiteWing Firmware binary files/`, including bootloader, partition table, and application images. That means the project supports direct flashing/deployment, not only source builds.

13. For an architecture diagram, the clearest layout is: operator tools on one side, wireless link in the middle, onboard ESP32-S3 flight firmware in the center, and physical sensors/motors on the other side. The firmware center should be split into communication, estimation, control, and hardware-driver layers, with the Crazyflie-derived modules called out as the main control framework.

Main entry points: [`components/core/crazyflie/modules/src/stabilizer.c`](https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/stabilizer.c) (Crazyflie core), [`components/core/crazyflie/hal/src/wifilink.c`](https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/hal/src/wifilink.c) (Wireless link), [`hardware/LieWingV2.6.C/LieWingV2.6.C.kicad_sch`](https://github.com/jobitjoseph/litewing/blob/main/hardware/LieWingV2.6.C/LieWingV2.6.C.kicad_sch) (Board V2.6C), [`main/main.c`](https://github.com/jobitjoseph/litewing/blob/main/main/main.c) (Main boot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Onboard firmware"]
  node_main_entry["Main boot<br/>ESP-IDF entrypoint<br/>[main.c]"]
  node_platform["Platform<br/>ESP32 abstraction<br/>[platform_esp32.c]"]
  node_crazyflie_core["Crazyflie core<br/>flight stack<br/>[stabilizer.c]"]
  node_commander["Commander<br/>input routing<br/>[commander.c]"]
  node_estimator["Estimator<br/>state estimation<br/>[estimator.c]"]
  node_controllers["Controllers<br/>attitude/position control<br/>[controller.c]"]
  node_stabilizer["Stabilizer<br/>mixing loop<br/>[stabilizer.c]"]
  node_comm_stack["Wireless link<br/>CRTP/ESP-NOW<br/>[wifilink.c]"]
  node_sensor_hal["Sensor HAL<br/>device interfaces<br/>[sensors.c]"]
  node_drivers["Drivers<br/>[motors.c]"]
  node_motors["Motors<br/>actuation driver<br/>[motors.c]"]
  node_sensors["Sensors<br/>[mpu6050.c]"]
end

subgraph group_offboard["Offboard tools"]
  node_cfclient["CF client<br/>ground-control UI<br/>[gui.py]"]
  node_pytools["Python tools<br/>ops scripts<br/>[main.py]"]
  node_arduino["Arduino forks<br/>alternate control<br/>[LiteWing.ino]"]
end

subgraph group_hardware["Hardware"]
  node_hardware_v25["Board V2.5C<br/>PCB revision"]
  node_hardware_v26["Board V2.6C<br/>PCB revision"]
  node_datasheets["Datasheets<br/>component docs"]
end

subgraph group_images["Binary images"]
  node_fw_binaries[("Flash images<br/>prebuilt firmware<br/>[LiteWing.bin]")]
end

node_main_entry -->|"boots on"| node_platform
node_main_entry -->|"starts"| node_crazyflie_core
node_crazyflie_core -->|"consumes"| node_commander
node_crazyflie_core -->|"uses"| node_estimator
node_crazyflie_core -->|"runs"| node_controllers
node_controllers -->|"feeds"| node_stabilizer
node_stabilizer -->|"drives"| node_motors
node_sensor_hal -->|"supplies"| node_estimator
node_sensors -->|"read by"| node_sensor_hal
node_drivers -->|"hosts"| node_sensors
node_drivers -->|"controls"| node_motors
node_comm_stack -->|"carries"| node_commander
node_comm_stack -->|"connects"| node_cfclient
node_pytools -->|"sends"| node_comm_stack
node_arduino -->|"uses"| node_comm_stack
node_cfclient -.->|"orchestrates"| node_pytools
node_hardware_v26 -->|"targets"| node_sensor_hal
node_hardware_v26 -->|"maps to"| node_drivers
node_hardware_v25 -.->|"evolves to"| node_hardware_v26
node_datasheets -.->|"documents"| node_hardware_v26
node_fw_binaries -->|"deploys"| node_main_entry

click node_main_entry "https://github.com/jobitjoseph/litewing/blob/main/main/main.c"
click node_platform "https://github.com/jobitjoseph/litewing/blob/main/components/platform/platform_esp32.c"
click node_crazyflie_core "https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/stabilizer.c"
click node_commander "https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/commander.c"
click node_estimator "https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/estimator.c"
click node_controllers "https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/controller.c"
click node_stabilizer "https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/stabilizer.c"
click node_comm_stack "https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/hal/src/wifilink.c"
click node_sensor_hal "https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/hal/src/sensors.c"
click node_drivers "https://github.com/jobitjoseph/litewing/blob/main/components/drivers/general/motors/motors.c"
click node_motors "https://github.com/jobitjoseph/litewing/blob/main/components/drivers/general/motors/motors.c"
click node_sensors "https://github.com/jobitjoseph/litewing/blob/main/components/drivers/i2c_devices/mpu6050/mpu6050.c"
click node_cfclient "https://github.com/jobitjoseph/litewing/blob/main/Python-Scripts/crazyflie-clients-python/src/cfclient/gui.py"
click node_pytools "https://github.com/jobitjoseph/litewing/blob/main/Python-Scripts/main.py"
click node_arduino "https://github.com/jobitjoseph/litewing/blob/main/LiteWing-Arduino/Arduino-LiteWing-DMP/LiteWing.ino"
click node_hardware_v25 "https://github.com/jobitjoseph/litewing/blob/main/hardware/LiteWingV2.5C/LiteWingV2.5C.kicad_sch"
click node_hardware_v26 "https://github.com/jobitjoseph/litewing/blob/main/hardware/LieWingV2.6.C/LieWingV2.6.C.kicad_sch"
click node_datasheets "https://github.com/jobitjoseph/litewing/blob/main/hardware/datasheet/ESP32-S3-WROOM-1/ESP32-S3_datasheet_en.pdf"
click node_fw_binaries "https://github.com/jobitjoseph/litewing/blob/main/LiteWing Firmware binary files/LiteWing.bin"

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_main_entry,node_platform,node_crazyflie_core,node_commander,node_estimator,node_controllers,node_stabilizer,node_comm_stack,node_sensor_hal,node_drivers,node_motors,node_sensors toneBlue
class node_cfclient,node_pytools,node_arduino toneAmber
class node_hardware_v25,node_hardware_v26,node_datasheets toneMint
class node_fw_binaries toneRose
```

## Components

### Onboard firmware

ESP32-S3 flight controller firmware and embedded control stack.

- [Main boot](https://github.com/jobitjoseph/litewing/blob/main/main/main.c): ESP-IDF entrypoint · Firmware startup and system wiring for the onboard controller. · `main/main.c`
- [Platform](https://github.com/jobitjoseph/litewing/blob/main/components/platform/platform_esp32.c): ESP32 abstraction · Board/platform glue between ESP32-specific services and the flight stack. · `components/platform/platform_esp32.c`
- [Crazyflie core](https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/stabilizer.c): flight stack · Ported control framework and task-oriented flight runtime. · `components/core/crazyflie/modules/src/stabilizer.c`
- [Commander](https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/commander.c): input routing · Receives control commands and high-level flight intents. · `components/core/crazyflie/modules/src/commander.c`
- [Estimator](https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/estimator.c): state estimation · Fuses IMU, altitude, flow, and range data into vehicle state. · `components/core/crazyflie/modules/src/estimator.c`
- [Controllers](https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/controller.c): attitude/position control · Attitude and position control loops that turn state and setpoints into thrust and rates. · `components/core/crazyflie/modules/src/controller.c`
- [Stabilizer](https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/modules/src/stabilizer.c): mixing loop · Main stabilization loop and power distribution coordination. · `components/core/crazyflie/modules/src/stabilizer.c`
- [Wireless link](https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/hal/src/wifilink.c): CRTP/ESP-NOW · Command and telemetry transport over Wi-Fi, ESP-NOW, and related links. · `components/core/crazyflie/hal/src/wifilink.c`
- [Sensor HAL](https://github.com/jobitjoseph/litewing/blob/main/components/core/crazyflie/hal/src/sensors.c): device interfaces · Low-level sensor and peripheral interfaces for IMU, barometer, flow, range, power, and I/O. · `components/core/crazyflie/hal/src/sensors.c`
- [Drivers](https://github.com/jobitjoseph/litewing/blob/main/components/drivers/general/motors/motors.c): ESP32 drivers · Reusable device drivers for motors, LEDs, buzzer, Wi-Fi, I2C, SPI, and deck interfaces. · `components/drivers/general/motors/motors.c`
- [Motors](https://github.com/jobitjoseph/litewing/blob/main/components/drivers/general/motors/motors.c): actuation driver · Motor output control and motor mapping for the airframe. · `components/drivers/general/motors/motors.c`
- [Sensors](https://github.com/jobitjoseph/litewing/blob/main/components/drivers/i2c_devices/mpu6050/mpu6050.c): physical sensors · IMU, barometer, optical flow, and range sensing inputs feeding estimation. · `components/drivers/i2c_devices/mpu6050/mpu6050.c`

### Offboard tools

Python, Arduino, and ground-control tooling around the vehicle.

- [CF client](https://github.com/jobitjoseph/litewing/blob/main/Python-Scripts/crazyflie-clients-python/src/cfclient/gui.py): ground-control UI · Forked Crazyflie operator console with GUI, headless mode, logging, tuning, and input handling. · `Python-Scripts/crazyflie-clients-python/src/cfclient/gui.py`
- [Python tools](https://github.com/jobitjoseph/litewing/blob/main/Python-Scripts/main.py): ops scripts · Flight behaviors, sensor readers, hold flows, and validation scripts for the drone. · `Python-Scripts/main.py`
- [Arduino forks](https://github.com/jobitjoseph/litewing/blob/main/LiteWing-Arduino/Arduino-LiteWing-DMP/LiteWing.ino): alternate control · Legacy or experimental Arduino-based flight and ESP-NOW control sketches. · `LiteWing-Arduino/Arduino-LiteWing-DMP/LiteWing.ino`

### Hardware

PCB revisions and manufacturing artifacts for the physical platform.

- [Board V2.5C](https://github.com/jobitjoseph/litewing/blob/main/hardware/LiteWingV2.5C/LiteWingV2.5C.kicad_sch): PCB revision · Earlier LiteWing PCB revision and its fabrication outputs. · `hardware/LiteWingV2.5C/LiteWingV2.5C.kicad_sch`
- [Board V2.6C](https://github.com/jobitjoseph/litewing/blob/main/hardware/LieWingV2.6.C/LieWingV2.6.C.kicad_sch): PCB revision · Current LiteWing PCB revision with schematic, layout, BOM, and production data. · `hardware/LieWingV2.6.C/LieWingV2.6.C.kicad_sch`
- [Datasheets](https://github.com/jobitjoseph/litewing/blob/main/hardware/datasheet/ESP32-S3-WROOM-1/ESP32-S3_datasheet_en.pdf): component docs · Reference documentation for the ESP32-S3, sensors, and flow hardware. · `hardware/datasheet/ESP32-S3-WROOM-1/ESP32-S3_datasheet_en.pdf`

### Binary images

Prebuilt firmware images for flashing and deployment.

- [Flash images](https://github.com/jobitjoseph/litewing/blob/HEAD/LiteWing%20Firmware%20binary%20files/LiteWing.bin): prebuilt firmware · Bootloader, partition table, and application binaries for direct flashing. · `LiteWing Firmware binary files/LiteWing.bin`

## Connections

- Main boot → Platform: boots on · Main firmware initializes board services and runtime glue.
- Main boot → Crazyflie core: starts · Entrypoint launches the flight stack.
- Crazyflie core → Commander: consumes · Flight stack reads operator commands and setpoints.
- Crazyflie core → Estimator: uses · Control loops depend on fused state estimates.
- Crazyflie core → Controllers: runs · Core invokes attitude and position controllers.
- Controllers → Stabilizer: feeds · Controller outputs are stabilized and mixed for actuation.
- Stabilizer → Motors: drives · Stabilization resolves into motor commands.
- Sensor HAL → Estimator: supplies · Sensor measurements are passed into estimation.
- Sensors → Sensor HAL: read by · Hardware sensors are accessed through HAL wrappers.
- Drivers → Sensors: hosts · Driver layer implements sensor and peripheral devices.
- Drivers → Motors: controls · Driver layer implements motor output hardware.
- Wireless link → Commander: carries · Wireless packets deliver control commands to the vehicle.
- Wireless link → CF client: connects · Operator console communicates with the onboard link stack.
- Python tools → Wireless link: sends · Python scripts generate control and telemetry traffic.
- Arduino forks → Wireless link: uses · Arduino sketches implement alternate ESP-NOW control paths.
- CF client → Python tools: orchestrates · Ground-control tooling and scripts complement the GUI client.
- Board V2.6C → Sensor HAL: targets · Current PCB revision defines the onboard sensor and I/O boundary.
- Board V2.6C → Drivers: maps to · Board peripherals are realized by the firmware drivers.
- Board V2.5C → Board V2.6C: evolves to · Earlier PCB revision precedes the current board design.
- Datasheets → Board V2.6C: documents · Reference specs describe the board's integrated parts.
- Flash images → Main boot: deploys · Prebuilt images correspond to the onboard firmware.
