# thales625/libgnc architecture

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

- Interactive diagram: https://gitdiagram.com/thales625/libgnc
- Repository: https://github.com/thales625/libgnc

## Overview

This repository combines a header-only GNC math/control/navigation library with a quadrotor simulator and an embedded avionics interface. The intended flight-control flow is exposed through Avionics: it uses an estimated state for LQR control and produces rotor commands; Python bindings expose that interface, while the simulation scripts provide a separate simulation workflow. The sampled sources do not show how EmbeddedBackend connects the simulator and avionics, and Avionics’ Kalman prediction/measurement updates are commented out, so those links are omitted.

Main entry points: [`include/libgnc/navigation/kalman/kalman.hpp`](https://github.com/thales625/libgnc/blob/main/include/libgnc/navigation/kalman/kalman.hpp) (Kalman filter), [`simulation/environment/drone.py`](https://github.com/thales625/libgnc/blob/main/simulation/environment/drone.py) (Drone dynamics), [`simulation/include/avionics.hpp`](https://github.com/thales625/libgnc/blob/main/simulation/include/avionics.hpp) (Flight avionics), [`simulation/static.py`](https://github.com/thales625/libgnc/blob/main/simulation/static.py) (Static simulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flight["Flight Control"]
  node_avionics["Flight avionics<br/>[avionics.hpp]"]
  node_kalman["Kalman filter<br/>[kalman.hpp]"]
  node_lqr["LQR controller<br/>[lqr.hpp]"]
end

subgraph group_simulation["Quadrotor Simulation"]
  node_static_sim["Static simulation<br/>[static.py]"]
  node_backend["Simulation backend<br/>[embedded.py]"]
  node_drone["Drone dynamics<br/>[drone.py]"]
  node_rotor["Rotor model<br/>[rotor.py]"]
  node_sensors["Sensor models<br/>[sensors.py]"]
  node_earth["Earth model<br/>[earth.py]"]
  node_solver["RK4 solver<br/>[solver.py]"]
  node_sim_results["Simulation plots<br/>[static.py]"]
end

subgraph group_math["GNC Core"]
  node_vectors["Vectors<br/>[vector.hpp]"]
  node_matrices["Matrices<br/>[matrix.hpp]"]
  node_quaternion["Quaternions<br/>[quaternion.hpp]"]
end

subgraph group_embedded["Embedded Interface"]
  node_bindings["Python bindings"]
  node_embedded_demo["ESP demo<br/>[main.cpp]"]
end

node_operator(("Simulation user"))

node_operator -->|"starts"| node_static_sim
node_static_sim -->|"steps simulation"| node_backend
node_static_sim -->|"collects and plots"| node_sim_results
node_static_sim -->|"converts attitude"| node_quaternion
node_bindings -->|"exposes"| node_avionics
node_avionics -->|"reads state"| node_kalman
node_avionics -->|"updates control"| node_lqr
node_avionics -->|"uses vectors"| node_vectors
node_kalman -->|"matrix operations"| node_matrices
node_kalman -->|"state operations"| node_vectors
node_kalman -->|"converts attitude"| node_quaternion
node_lqr -->|"computes control"| node_vectors
node_drone -->|"updates rotors"| node_rotor
node_drone -->|"updates sensors"| node_sensors
node_drone -->|"reads gravity and density"| node_earth
node_drone -->|"steps dynamics"| node_solver
node_embedded_demo -->|"uses vectors"| node_vectors
node_embedded_demo -.->|"includes filter"| node_kalman

click node_static_sim "https://github.com/thales625/libgnc/blob/main/simulation/static.py"
click node_backend "https://github.com/thales625/libgnc/blob/main/simulation/embedded.py"
click node_drone "https://github.com/thales625/libgnc/blob/main/simulation/environment/drone.py"
click node_rotor "https://github.com/thales625/libgnc/blob/main/simulation/environment/rotor.py"
click node_sensors "https://github.com/thales625/libgnc/blob/main/simulation/environment/sensors.py"
click node_earth "https://github.com/thales625/libgnc/blob/main/simulation/environment/earth.py"
click node_solver "https://github.com/thales625/libgnc/blob/main/simulation/environment/solver.py"
click node_avionics "https://github.com/thales625/libgnc/blob/main/simulation/include/avionics.hpp"
click node_bindings "https://github.com/thales625/libgnc/blob/main/simulation/bindings/avionics_pybind.cpp"
click node_kalman "https://github.com/thales625/libgnc/blob/main/include/libgnc/navigation/kalman/kalman.hpp"
click node_lqr "https://github.com/thales625/libgnc/blob/main/include/libgnc/control/lqr/lqr.hpp"
click node_vectors "https://github.com/thales625/libgnc/blob/main/include/libgnc/math/vector.hpp"
click node_matrices "https://github.com/thales625/libgnc/blob/main/include/libgnc/math/matrix.hpp"
click node_quaternion "https://github.com/thales625/libgnc/blob/main/include/libgnc/math/quaternion.hpp"
click node_sim_results "https://github.com/thales625/libgnc/blob/main/simulation/static.py"
click node_embedded_demo "https://github.com/thales625/libgnc/blob/main/main/main.cpp"

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_avionics,node_kalman,node_lqr,node_operator toneBlue
class node_static_sim,node_backend,node_drone,node_rotor,node_sensors,node_earth,node_solver,node_sim_results toneAmber
class node_vectors,node_matrices,node_quaternion toneMint
class node_bindings,node_embedded_demo toneRose
```

## Components

### Flight Control

- [Flight avionics](https://github.com/thales625/libgnc/blob/main/simulation/include/avionics.hpp): `simulation/include/avionics.hpp`
- [Kalman filter](https://github.com/thales625/libgnc/blob/main/include/libgnc/navigation/kalman/kalman.hpp): `include/libgnc/navigation/kalman/kalman.hpp`
- [LQR controller](https://github.com/thales625/libgnc/blob/main/include/libgnc/control/lqr/lqr.hpp): `include/libgnc/control/lqr/lqr.hpp`

### Quadrotor Simulation

- [Static simulation](https://github.com/thales625/libgnc/blob/main/simulation/static.py): `simulation/static.py`
- [Simulation backend](https://github.com/thales625/libgnc/blob/main/simulation/embedded.py): `simulation/embedded.py`
- [Drone dynamics](https://github.com/thales625/libgnc/blob/main/simulation/environment/drone.py): `simulation/environment/drone.py`
- [Rotor model](https://github.com/thales625/libgnc/blob/main/simulation/environment/rotor.py): `simulation/environment/rotor.py`
- [Sensor models](https://github.com/thales625/libgnc/blob/main/simulation/environment/sensors.py): `simulation/environment/sensors.py`
- [Earth model](https://github.com/thales625/libgnc/blob/main/simulation/environment/earth.py): `simulation/environment/earth.py`
- [RK4 solver](https://github.com/thales625/libgnc/blob/main/simulation/environment/solver.py): `simulation/environment/solver.py`
- [Simulation plots](https://github.com/thales625/libgnc/blob/main/simulation/static.py): `simulation/static.py`

### GNC Core

- [Vectors](https://github.com/thales625/libgnc/blob/main/include/libgnc/math/vector.hpp): `include/libgnc/math/vector.hpp`
- [Matrices](https://github.com/thales625/libgnc/blob/main/include/libgnc/math/matrix.hpp): `include/libgnc/math/matrix.hpp`
- [Quaternions](https://github.com/thales625/libgnc/blob/main/include/libgnc/math/quaternion.hpp): `include/libgnc/math/quaternion.hpp`

### Embedded Interface

- [Python bindings](https://github.com/thales625/libgnc/blob/main/simulation/bindings/avionics_pybind.cpp): `simulation/bindings/avionics_pybind.cpp`
- [ESP demo](https://github.com/thales625/libgnc/blob/main/main/main.cpp): `main/main.cpp`

### Other components

- **Simulation user**

## Connections

- Simulation user → Static simulation: starts
- Static simulation → Simulation backend: steps simulation
- Static simulation → Simulation plots: collects and plots
- Static simulation → Quaternions: converts attitude
- Python bindings → Flight avionics: exposes
- Flight avionics → Kalman filter: reads state
- Flight avionics → LQR controller: updates control
- Flight avionics → Vectors: uses vectors
- Kalman filter → Matrices: matrix operations
- Kalman filter → Vectors: state operations
- Kalman filter → Quaternions: converts attitude
- LQR controller → Vectors: computes control
- Drone dynamics → Rotor model: updates rotors
- Drone dynamics → Sensor models: updates sensors
- Drone dynamics → Earth model: reads gravity and density
- Drone dynamics → RK4 solver: steps dynamics
- ESP demo → Vectors: uses vectors
- ESP demo → Kalman filter: includes filter
