# thecorecomet/comet_imu architecture

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

- Interactive diagram: https://gitdiagram.com/thecorecomet/comet_imu
- Repository: https://github.com/thecorecomet/comet_imu

## Overview

COMET_IMU is an embedded C++ library that unifies supported IMU sensors behind a common API. The main workflow initializes or auto-detects a sensor, binds its bus and driver, updates readings, optionally computes orientation with on-chip fusion or a software filter, and exposes results and calibration controls. The graph preserves the documented multi-IMU capability and the major bus, driver, and fusion branches. Some internal update and detector details are unsampled, so those links are omitted where the excerpts do not establish them.

Main entry points: [`src/COMET_IMU.cpp`](https://github.com/thecorecomet/comet_imu/blob/main/src/COMET_IMU.cpp) (COMET_IMU API), [`src/fusion/SensorFusion.h`](https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/SensorFusion.h) (Fusion Contract), [`src/drivers/BaseIMUDriver.h`](https://github.com/thecorecomet/comet_imu/blob/main/src/drivers/BaseIMUDriver.h) (Driver Contract), [`src/drivers/Bosch`](https://github.com/thecorecomet/comet_imu/tree/main/src/drivers/Bosch) (Bosch Drivers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Unified API"]
  node_api["COMET_IMU API<br/>[COMET_IMU.cpp]"]
  node_types["IMU Data Types<br/>[IMUTypes.h]"]
end

subgraph group_transport["Bus Transport"]
  node_detector["Bus Detection<br/>[BusDetector.cpp]"]
  node_businterface["Bus Interface<br/>[BusInterface.h]"]
  node_i2c["I2C Bus<br/>[I2CBus.cpp]"]
  node_spi["SPI Bus<br/>[SPIBus.cpp]"]
end

subgraph group_drivers["Sensor Drivers"]
  node_bosch["Bosch Drivers"]
  node_invensense["InvenSense Drivers"]
  node_st["ST Drivers"]
  node_basedriver["Driver Contract<br/>[BaseIMUDriver.h]"]
end

subgraph group_fusion["Orientation Fusion"]
  node_fusioncontract["Fusion Contract<br/>[SensorFusion.h]"]
  node_madgwick["Madgwick Filter<br/>[MadgwickFilter.cpp]"]
  node_mahony["Mahony Filter<br/>[MahonyFilter.cpp]"]
  node_kalman["Kalman Filter<br/>[KalmanFilter.cpp]"]
  node_complementary["Complementary Filter"]
end

node_user(("Application"))
node_sensor(("Physical IMU"))

node_user -->|"initializes and updates"| node_api
node_api -->|"scans bus"| node_detector
node_api -->|"creates I2C bus"| node_i2c
node_api -->|"creates SPI bus"| node_spi
node_api -->|"selects driver"| node_bosch
node_api -->|"selects driver"| node_invensense
node_api -->|"selects driver"| node_st
node_bosch -->|"implements contract"| node_basedriver
node_invensense -->|"implements contract"| node_basedriver
node_st -->|"implements contract"| node_basedriver
node_basedriver -->|"uses bus"| node_businterface
node_api -->|"selects filter"| node_madgwick
node_api -->|"selects filter"| node_mahony
node_api -->|"selects filter"| node_kalman
node_api -->|"selects filter"| node_complementary
node_madgwick -->|"implements contract"| node_fusioncontract
node_mahony -->|"implements contract"| node_fusioncontract
node_kalman -->|"implements contract"| node_fusioncontract
node_complementary -->|"implements contract"| node_fusioncontract
node_api -->|"updates fusion"| node_fusioncontract
node_api -->|"exposes sensor data"| node_types
node_sensor -.->|"transfers readings"| node_i2c
node_sensor -.->|"transfers readings"| node_spi

click node_api "https://github.com/thecorecomet/comet_imu/blob/main/src/COMET_IMU.cpp"
click node_types "https://github.com/thecorecomet/comet_imu/blob/main/src/IMUTypes.h"
click node_detector "https://github.com/thecorecomet/comet_imu/blob/main/src/bus/BusDetector.cpp"
click node_businterface "https://github.com/thecorecomet/comet_imu/blob/main/src/bus/BusInterface.h"
click node_i2c "https://github.com/thecorecomet/comet_imu/blob/main/src/bus/I2CBus.cpp"
click node_spi "https://github.com/thecorecomet/comet_imu/blob/main/src/bus/SPIBus.cpp"
click node_bosch "https://github.com/thecorecomet/comet_imu/tree/main/src/drivers/Bosch"
click node_invensense "https://github.com/thecorecomet/comet_imu/tree/main/src/drivers/InvenSense"
click node_st "https://github.com/thecorecomet/comet_imu/tree/main/src/drivers/ST"
click node_basedriver "https://github.com/thecorecomet/comet_imu/blob/main/src/drivers/BaseIMUDriver.h"
click node_fusioncontract "https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/SensorFusion.h"
click node_madgwick "https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/MadgwickFilter.cpp"
click node_mahony "https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/MahonyFilter.cpp"
click node_kalman "https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/KalmanFilter.cpp"
click node_complementary "https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/ComplementaryFilter.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_api,node_types toneBlue
class node_detector,node_businterface,node_i2c,node_spi toneAmber
class node_bosch,node_invensense,node_st,node_basedriver toneMint
class node_fusioncontract,node_madgwick,node_mahony,node_kalman,node_complementary toneRose
class node_user,node_sensor toneIndigo
```

## Components

### Unified API

- [COMET_IMU API](https://github.com/thecorecomet/comet_imu/blob/main/src/COMET_IMU.cpp): `src/COMET_IMU.cpp`
- [IMU Data Types](https://github.com/thecorecomet/comet_imu/blob/main/src/IMUTypes.h): `src/IMUTypes.h`

### Bus Transport

- [Bus Detection](https://github.com/thecorecomet/comet_imu/blob/main/src/bus/BusDetector.cpp): `src/bus/BusDetector.cpp`
- [Bus Interface](https://github.com/thecorecomet/comet_imu/blob/main/src/bus/BusInterface.h): `src/bus/BusInterface.h`
- [I2C Bus](https://github.com/thecorecomet/comet_imu/blob/main/src/bus/I2CBus.cpp): `src/bus/I2CBus.cpp`
- [SPI Bus](https://github.com/thecorecomet/comet_imu/blob/main/src/bus/SPIBus.cpp): `src/bus/SPIBus.cpp`

### Sensor Drivers

- [Bosch Drivers](https://github.com/thecorecomet/comet_imu/tree/main/src/drivers/Bosch): `src/drivers/Bosch`
- [InvenSense Drivers](https://github.com/thecorecomet/comet_imu/tree/main/src/drivers/InvenSense): `src/drivers/InvenSense`
- [ST Drivers](https://github.com/thecorecomet/comet_imu/tree/main/src/drivers/ST): `src/drivers/ST`
- [Driver Contract](https://github.com/thecorecomet/comet_imu/blob/main/src/drivers/BaseIMUDriver.h): `src/drivers/BaseIMUDriver.h`

### Orientation Fusion

- [Fusion Contract](https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/SensorFusion.h): `src/fusion/SensorFusion.h`
- [Madgwick Filter](https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/MadgwickFilter.cpp): `src/fusion/MadgwickFilter.cpp`
- [Mahony Filter](https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/MahonyFilter.cpp): `src/fusion/MahonyFilter.cpp`
- [Kalman Filter](https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/KalmanFilter.cpp): `src/fusion/KalmanFilter.cpp`
- [Complementary Filter](https://github.com/thecorecomet/comet_imu/blob/main/src/fusion/ComplementaryFilter.cpp): `src/fusion/ComplementaryFilter.cpp`

### Other components

- **Application**
- **Physical IMU**

## Connections

- Application → COMET_IMU API: initializes and updates (evidence: `README.md`)
- COMET_IMU API → Bus Detection: scans bus (evidence: `src/COMET_IMU.cpp`)
- COMET_IMU API → I2C Bus: creates I2C bus (evidence: `src/COMET_IMU.cpp`)
- COMET_IMU API → SPI Bus: creates SPI bus (evidence: `src/COMET_IMU.cpp`)
- COMET_IMU API → Bosch Drivers: selects driver (evidence: `src/COMET_IMU.cpp`)
- COMET_IMU API → InvenSense Drivers: selects driver (evidence: `src/COMET_IMU.cpp`)
- COMET_IMU API → ST Drivers: selects driver (evidence: `src/COMET_IMU.cpp`)
- Bosch Drivers → Driver Contract: implements contract (evidence: `src/drivers/Bosch/DriverBNO08x.h`)
- InvenSense Drivers → Driver Contract: implements contract (evidence: `src/drivers/BaseIMUDriver.h`)
- ST Drivers → Driver Contract: implements contract (evidence: `src/drivers/BaseIMUDriver.h`)
- Driver Contract → Bus Interface: uses bus (evidence: `src/drivers/BaseIMUDriver.h`)
- COMET_IMU API → Madgwick Filter: selects filter (evidence: `src/COMET_IMU.cpp`)
- COMET_IMU API → Mahony Filter: selects filter
- COMET_IMU API → Kalman Filter: selects filter (evidence: `src/COMET_IMU.cpp`)
- COMET_IMU API → Complementary Filter: selects filter
- Madgwick Filter → Fusion Contract: implements contract
- Mahony Filter → Fusion Contract: implements contract
- Kalman Filter → Fusion Contract: implements contract
- Complementary Filter → Fusion Contract: implements contract
- COMET_IMU API → Fusion Contract: updates fusion (evidence: `src/COMET_IMU.cpp`)
- COMET_IMU API → IMU Data Types: exposes sensor data
- Physical IMU → I2C Bus: transfers readings
- Physical IMU → SPI Bus: transfers readings
