# blgjsy/cf-drone architecture

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

- Interactive diagram: https://gitdiagram.com/blgjsy/cf-drone
- Repository: https://github.com/blgjsy/cf-drone

## Overview

This repository combines three flight-control codebases: CF-Drone (the currently maintained controller per the README), Flix (a planned successor with simulation and log utilities), and an older, explicitly incomplete STM32 project. The sampled STM32 main loop reads sensors, updates attitude and barometric estimates, drives control/output and display functions, and reports telemetry. Flix’s sampled code establishes reusable vector and quaternion math; its simulator and tooling are visible in the tree but their runtime wiring was not sampled, so those connections are omitted.

Main entry points: [`huojianfeikong/User/main.c`](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/User/main.c) (Flight loop), [`flix/gazebo/simulator.cpp`](https://github.com/blgjsy/cf-drone/blob/main/flix/gazebo/simulator.cpp) (Gazebo simulator), [`flix/flix/quaternion.h`](https://github.com/blgjsy/cf-drone/blob/main/flix/flix/quaternion.h) (Quaternion math), [`flix/gazebo/Arduino.h`](https://github.com/blgjsy/cf-drone/blob/main/flix/gazebo/Arduino.h) (Arduino compatibility)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cf["CF-Drone flight control"]
  node_pilot["Flight controller"]
  node_mpu["MPU9250 driver<br/>[MPU9250.cpp]"]
  node_sbus["SBUS receiver<br/>[SBUS.cpp]"]
  node_cfmath["Attitude math<br/>[quaternion.h]"]
end

subgraph group_flix["Flix simulation and tools"]
  node_sim["Gazebo simulator<br/>[simulator.cpp]"]
  node_arduino["Arduino compatibility<br/>[Arduino.h]"]
  node_vec["Vector math<br/>[vector.h]"]
  node_quat["Quaternion math<br/>[quaternion.h]"]
  node_pyflix["Python Flix API<br/>[flix.py]"]
  node_logtools["Log utilities<br/>[log.py]"]
end

subgraph group_rocket["STM32 project"]
  node_main["Flight loop<br/>[main.c]"]
  node_imu["IMU acquisition<br/>[ICM42688.c]"]
  node_baro["Barometer<br/>[SPL06.c]"]
  node_gps["GPS receiver<br/>[GPS.c]"]
  node_attitude["Attitude estimate<br/>[IMU.h]"]
  node_velocity["Velocity filter<br/>[Velocity.c]"]
  node_control["Canard control<br/>[Servo.c]"]
  node_display["OLED display<br/>[OLED.c]"]
  node_serial["Serial telemetry<br/>[Serial.c]"]
  node_outputs["Relay outputs<br/>[Relay.c]"]
end

subgraph group_mcu["STM32 platform"]
  node_timer["Timer peripherals<br/>[Timer.c]"]
  node_stm32["STM32 startup<br/>[system_stm32f10x.c]"]
end

node_main -->|"reads data"| node_baro
node_main -->|"reads data"| node_imu
node_main -->|"updates attitude"| node_attitude
node_main -->|"parses GPS"| node_gps
node_main -->|"filters altitude"| node_velocity
node_main -->|"commands control"| node_control
node_main -->|"shows readings"| node_display
node_main -->|"prints telemetry"| node_serial
node_main -->|"sets relays"| node_outputs
node_main -->|"configures timers"| node_timer
node_quat -->|"uses vectors"| node_vec
node_sim -.->|"uses API"| node_arduino

click node_pilot "https://github.com/blgjsy/cf-drone/tree/main/CF-Drone"
click node_mpu "https://github.com/blgjsy/cf-drone/blob/main/CF-Drone/drivers/MPU9250.cpp"
click node_sbus "https://github.com/blgjsy/cf-drone/blob/main/CF-Drone/drivers/SBUS.cpp"
click node_cfmath "https://github.com/blgjsy/cf-drone/blob/main/CF-Drone/quaternion.h"
click node_sim "https://github.com/blgjsy/cf-drone/blob/main/flix/gazebo/simulator.cpp"
click node_arduino "https://github.com/blgjsy/cf-drone/blob/main/flix/gazebo/Arduino.h"
click node_vec "https://github.com/blgjsy/cf-drone/blob/main/flix/flix/vector.h"
click node_quat "https://github.com/blgjsy/cf-drone/blob/main/flix/flix/quaternion.h"
click node_pyflix "https://github.com/blgjsy/cf-drone/blob/main/flix/tools/pyflix/flix.py"
click node_logtools "https://github.com/blgjsy/cf-drone/blob/main/flix/tools/log.py"
click node_main "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/User/main.c"
click node_imu "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/ICM42688.c"
click node_baro "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/SPL06.c"
click node_gps "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/GPS.c"
click node_attitude "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/IMU.h"
click node_velocity "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/System/Velocity.c"
click node_control "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/Servo.c"
click node_display "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/OLED.c"
click node_serial "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/Serial.c"
click node_outputs "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/Relay.c"
click node_timer "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/System/Timer.c"
click node_stm32 "https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Start/system_stm32f10x.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_pilot,node_mpu,node_sbus,node_cfmath toneBlue
class node_sim,node_arduino,node_vec,node_quat,node_pyflix,node_logtools toneAmber
class node_main,node_imu,node_baro,node_gps,node_attitude,node_velocity,node_control,node_display,node_serial,node_outputs toneMint
class node_timer,node_stm32 toneRose
```

## Components

### CF-Drone flight control

- [Flight controller](https://github.com/blgjsy/cf-drone/tree/main/CF-Drone): `CF-Drone`
- [MPU9250 driver](https://github.com/blgjsy/cf-drone/blob/main/CF-Drone/drivers/MPU9250.cpp): `CF-Drone/drivers/MPU9250.cpp`
- [SBUS receiver](https://github.com/blgjsy/cf-drone/blob/main/CF-Drone/drivers/SBUS.cpp): `CF-Drone/drivers/SBUS.cpp`
- [Attitude math](https://github.com/blgjsy/cf-drone/blob/main/CF-Drone/quaternion.h): `CF-Drone/quaternion.h`

### Flix simulation and tools

- [Gazebo simulator](https://github.com/blgjsy/cf-drone/blob/main/flix/gazebo/simulator.cpp): `flix/gazebo/simulator.cpp`
- [Arduino compatibility](https://github.com/blgjsy/cf-drone/blob/main/flix/gazebo/Arduino.h): `flix/gazebo/Arduino.h`
- [Vector math](https://github.com/blgjsy/cf-drone/blob/main/flix/flix/vector.h): `flix/flix/vector.h`
- [Quaternion math](https://github.com/blgjsy/cf-drone/blob/main/flix/flix/quaternion.h): `flix/flix/quaternion.h`
- [Python Flix API](https://github.com/blgjsy/cf-drone/blob/main/flix/tools/pyflix/flix.py): `flix/tools/pyflix/flix.py`
- [Log utilities](https://github.com/blgjsy/cf-drone/blob/main/flix/tools/log.py): `flix/tools/log.py`

### STM32 project

- [Flight loop](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/User/main.c): `huojianfeikong/User/main.c`
- [IMU acquisition](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/ICM42688.c): `huojianfeikong/Hardware/ICM42688.c`
- [Barometer](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/SPL06.c): `huojianfeikong/Hardware/SPL06.c`
- [GPS receiver](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/GPS.c): `huojianfeikong/Hardware/GPS.c`
- [Attitude estimate](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/IMU.h): `huojianfeikong/Hardware/IMU.h`
- [Velocity filter](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/System/Velocity.c): `huojianfeikong/System/Velocity.c`
- [Canard control](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/Servo.c): `huojianfeikong/Hardware/Servo.c`
- [OLED display](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/OLED.c): `huojianfeikong/Hardware/OLED.c`
- [Serial telemetry](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/Serial.c): `huojianfeikong/Hardware/Serial.c`
- [Relay outputs](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Hardware/Relay.c): `huojianfeikong/Hardware/Relay.c`

### STM32 platform

- [Timer peripherals](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/System/Timer.c): `huojianfeikong/System/Timer.c`
- [STM32 startup](https://github.com/blgjsy/cf-drone/blob/main/huojianfeikong/Start/system_stm32f10x.c): `huojianfeikong/Start/system_stm32f10x.c`

## Connections

- Flight loop → Barometer: reads data (evidence: `huojianfeikong/User/main.c`)
- Flight loop → IMU acquisition: reads data (evidence: `huojianfeikong/User/main.c`)
- Flight loop → Attitude estimate: updates attitude (evidence: `huojianfeikong/User/main.c`)
- Flight loop → GPS receiver: parses GPS (evidence: `huojianfeikong/User/main.c`)
- Flight loop → Velocity filter: filters altitude (evidence: `huojianfeikong/User/main.c`)
- Flight loop → Canard control: commands control (evidence: `huojianfeikong/User/main.c`)
- Flight loop → OLED display: shows readings (evidence: `huojianfeikong/User/main.c`)
- Flight loop → Serial telemetry: prints telemetry (evidence: `huojianfeikong/User/main.c`)
- Flight loop → Relay outputs: sets relays (evidence: `huojianfeikong/User/main.c`)
- Flight loop → Timer peripherals: configures timers (evidence: `huojianfeikong/User/main.c`)
- Quaternion math → Vector math: uses vectors (evidence: `flix/flix/quaternion.h`)
- Gazebo simulator → Arduino compatibility: uses API
