# embedded-purdue/slayterhil architecture

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

- Interactive diagram: https://gitdiagram.com/embedded-purdue/slayterhil
- Repository: https://github.com/embedded-purdue/slayterhil

## Overview

SlayterHIL is a hardware-in-the-loop system for exercising drone flight software without a real flight. The documented path is simulation-generated sensor output, deterministic injection by the Test Node, and evaluation on the flight controller; the dashboard provides the user interface and a playback view of simulation output. Internally, the simulator combines drone dynamics, control, and IMU generation. The README supports the HIL and playback relationships, but sampled source does not establish dashboard-to-test orchestration or the complete Test Node transfer path, so those links are omitted.

Main entry points: [`flight_sim/src/main.cpp`](https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/main.cpp) (Simulation runner), [`test_node/app/src/main.c`](https://github.com/embedded-purdue/slayterhil/blob/main/test_node/app/src/main.c) (Test Node bridge), [`flight_controller/app/src/main.c`](https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/main.c) (Controller entry), [`flight_controller/app/src/bno.c`](https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/bno.c) (Sensor readers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Test dashboard"]
  node_dashboard_ui["Dashboard UI<br/>[script.js]"]
  node_dashboard_server["Dashboard server<br/>[server.py]"]
  node_sim_view["Sim output view<br/>[script.js]"]
end

subgraph group_simulation["Flight simulation"]
  node_simulator["Simulation runner<br/>[main.cpp]"]
  node_drone_dynamics["Drone dynamics<br/>[rigid_body.cpp]"]
  node_position_control["Position control"]
  node_velocity_control["Velocity control"]
  node_imu_generation["IMU generation<br/>[imu_generation.cpp]"]
  node_sim_output["Simulation output files<br/>[main.cpp]"]
end

subgraph group_hil["HIL bridge"]
  node_test_node["Test Node bridge<br/>[main.c]"]
  node_sensor_emulation["Sensor injection<br/>[sensor_emulation.c]"]
  node_spi_bitbang["SPI bit-bang driver<br/>[spis_bitbang.c]"]
end

subgraph group_controller["Flight controller"]
  node_flight_controller["Controller entry<br/>[main.c]"]
  node_state_machine["Flight state machine<br/>[state_machine.c]"]
  node_sensor_readers["Sensor readers<br/>[bno.c]"]
  node_flight_control["Flight control and PID<br/>[control.c]"]
  node_bno_driver["BNO055 driver<br/>[bno055.c]"]
end

subgraph group_protocol["Sensor transport"]
  node_sensor_protocol["Sensor packet schema<br/>[sensor_data.proto]"]
  node_spi_transport["SPI transport<br/>[SpiTransport.cpp]"]
end

node_user(("Test user"))

node_user -->|"uses"| node_dashboard_ui
node_dashboard_server -->|"serves"| node_dashboard_ui
node_simulator -->|"writes"| node_sim_output
node_sim_output -->|"plays back"| node_sim_view
node_simulator -->|"provides sensor outputs"| node_test_node
node_test_node -.->|"runs injection"| node_sensor_emulation
node_test_node -->|"injects sensors"| node_flight_controller
node_simulator -.->|"updates"| node_drone_dynamics
node_simulator -.->|"uses"| node_position_control
node_simulator -->|"uses"| node_velocity_control
node_simulator -->|"generates IMU"| node_imu_generation
node_flight_controller -->|"starts threads"| node_sensor_readers
node_flight_controller -->|"includes control"| node_flight_control
node_flight_controller -->|"includes interface"| node_state_machine
node_sensor_readers -.->|"reads sensor"| node_bno_driver
node_simulator -.->|"uses packet format"| node_sensor_protocol
node_test_node -.->|"transfers over SPI"| node_spi_transport

click node_dashboard_ui "https://github.com/embedded-purdue/slayterhil/blob/main/app/dashboard/script.js"
click node_dashboard_server "https://github.com/embedded-purdue/slayterhil/blob/main/app/dashboard/server.py"
click node_sim_view "https://github.com/embedded-purdue/slayterhil/blob/main/app/dashboard/script.js"
click node_simulator "https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/main.cpp"
click node_drone_dynamics "https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/rigid_body.cpp"
click node_position_control "https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/positionController.cpp"
click node_velocity_control "https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/velocityController.cpp"
click node_imu_generation "https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/imu_generation.cpp"
click node_sim_output "https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/main.cpp"
click node_test_node "https://github.com/embedded-purdue/slayterhil/blob/main/test_node/app/src/main.c"
click node_sensor_emulation "https://github.com/embedded-purdue/slayterhil/blob/main/test_node/app/src/threads/c/sensor_emulation.c"
click node_spi_bitbang "https://github.com/embedded-purdue/slayterhil/blob/main/test_node/modules/spis_bitbang/drivers/spis_bitbang/spis_bitbang.c"
click node_flight_controller "https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/main.c"
click node_state_machine "https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/state_machine.c"
click node_sensor_readers "https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/bno.c"
click node_flight_control "https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/control.c"
click node_bno_driver "https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/drivers/sensor/bno055/bno055.c"
click node_sensor_protocol "https://github.com/embedded-purdue/slayterhil/blob/main/shared/proto/sensor_data.proto"
click node_spi_transport "https://github.com/embedded-purdue/slayterhil/blob/main/SPI_Slave_Driver/SpiTransport.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_dashboard_ui,node_dashboard_server,node_sim_view,node_user toneBlue
class node_simulator,node_drone_dynamics,node_position_control,node_velocity_control,node_imu_generation,node_sim_output toneAmber
class node_test_node,node_sensor_emulation,node_spi_bitbang toneMint
class node_flight_controller,node_state_machine,node_sensor_readers,node_flight_control,node_bno_driver toneRose
class node_sensor_protocol,node_spi_transport toneIndigo
```

## Components

### Test dashboard

- [Dashboard UI](https://github.com/embedded-purdue/slayterhil/blob/main/app/dashboard/script.js): `app/dashboard/script.js`
- [Dashboard server](https://github.com/embedded-purdue/slayterhil/blob/main/app/dashboard/server.py): `app/dashboard/server.py`
- [Sim output view](https://github.com/embedded-purdue/slayterhil/blob/main/app/dashboard/script.js): `app/dashboard/script.js`

### Flight simulation

- [Simulation runner](https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/main.cpp): `flight_sim/src/main.cpp`
- [Drone dynamics](https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/rigid_body.cpp): `flight_sim/src/rigid_body.cpp`
- [Position control](https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/positionController.cpp): `flight_sim/src/positionController.cpp`
- [Velocity control](https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/velocityController.cpp): `flight_sim/src/velocityController.cpp`
- [IMU generation](https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/imu_generation.cpp): `flight_sim/src/imu_generation.cpp`
- [Simulation output files](https://github.com/embedded-purdue/slayterhil/blob/main/flight_sim/src/main.cpp): `flight_sim/src/main.cpp`

### HIL bridge

- [Test Node bridge](https://github.com/embedded-purdue/slayterhil/blob/main/test_node/app/src/main.c): `test_node/app/src/main.c`
- [Sensor injection](https://github.com/embedded-purdue/slayterhil/blob/main/test_node/app/src/threads/c/sensor_emulation.c): `test_node/app/src/threads/c/sensor_emulation.c`
- [SPI bit-bang driver](https://github.com/embedded-purdue/slayterhil/blob/main/test_node/modules/spis_bitbang/drivers/spis_bitbang/spis_bitbang.c): `test_node/modules/spis_bitbang/drivers/spis_bitbang/spis_bitbang.c`

### Flight controller

- [Controller entry](https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/main.c): `flight_controller/app/src/main.c`
- [Flight state machine](https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/state_machine.c): `flight_controller/app/src/state_machine.c`
- [Sensor readers](https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/bno.c): `flight_controller/app/src/bno.c`
- [Flight control and PID](https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/app/src/control.c): `flight_controller/app/src/control.c`
- [BNO055 driver](https://github.com/embedded-purdue/slayterhil/blob/main/flight_controller/drivers/sensor/bno055/bno055.c): `flight_controller/drivers/sensor/bno055/bno055.c`

### Sensor transport

- [Sensor packet schema](https://github.com/embedded-purdue/slayterhil/blob/main/shared/proto/sensor_data.proto): `shared/proto/sensor_data.proto`
- [SPI transport](https://github.com/embedded-purdue/slayterhil/blob/main/SPI_Slave_Driver/SpiTransport.cpp): `SPI_Slave_Driver/SpiTransport.cpp`

### Other components

- **Test user**

## Connections

- Test user → Dashboard UI: uses (evidence: `README.md`)
- Dashboard server → Dashboard UI: serves (evidence: `README.md`)
- Simulation runner → Simulation output files: writes (evidence: `README.md`)
- Simulation output files → Sim output view: plays back (evidence: `README.md`)
- Simulation runner → Test Node bridge: provides sensor outputs (evidence: `README.md`)
- Test Node bridge → Sensor injection: runs injection
- Test Node bridge → Controller entry: injects sensors (evidence: `README.md`)
- Simulation runner → Drone dynamics: updates
- Simulation runner → Position control: uses
- Simulation runner → Velocity control: uses (evidence: `flight_sim/src/main.cpp`)
- Simulation runner → IMU generation: generates IMU (evidence: `flight_sim/src/main.cpp`)
- Controller entry → Sensor readers: starts threads (evidence: `flight_controller/app/src/main.c`)
- Controller entry → Flight control and PID: includes control (evidence: `flight_controller/app/src/main.c`)
- Controller entry → Flight state machine: includes interface (evidence: `flight_controller/app/src/main.c`)
- Sensor readers → BNO055 driver: reads sensor
- Simulation runner → Sensor packet schema: uses packet format
- Test Node bridge → SPI transport: transfers over SPI
