# hhh-habib/piku-2.1-rev-a-advanced-firmware architecture

> Architecture diagram of the GitHub repository hhh-habib/piku-2.1-rev-a-advanced-firmware, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hhh-habib/piku-2.1-rev-a-advanced-firmware
- Repository: https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware

## Overview

PIKU is standalone ESP32-S3 firmware for an environmental-inspection robot. Its main workflow is operator control through the embedded dashboard, with the firmware gathering sensor and IMU readings, applying safety checks, and dispatching manual or autonomous movement to the motors; telemetry is then surfaced locally and over the dashboard. AUTO includes obstacle avoidance, boxed-in recovery, and sonar reacquisition; environmental hazard response and optional nRF24 communication are distinct capabilities. Relationships for sampled modules are supported by the source index or excerpts; other capability links cite the README, so unsampled implementation details are not inferred.

Main entry points: [`src/main.cpp`](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/main.cpp) (Firmware service loop), [`src/NavigationManager.cpp`](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/NavigationManager.cpp) (AUTO navigation), [`src/WebDashboard.cpp`](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/WebDashboard.cpp) (HTTP dashboard), [`src/DashboardPublisher.cpp`](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/DashboardPublisher.cpp) (Dashboard data publisher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Robot Control"]
  node_main["Firmware service loop<br/>[main.cpp]"]
  node_navigation["AUTO navigation"]
  node_recovery["V3.2 recovery policy"]
  node_reacquire["Sonar reacquisition"]
  node_drive["Manual drive commands"]
  node_motors["Motor controller"]
  node_servo["Servo scanner<br/>[ServoScanner.cpp]"]
end

subgraph group_sensing["Sensing And Safety"]
  node_sensors["Sensor acquisition<br/>[SensorManager.cpp]"]
  node_imu["IMU telemetry<br/>[ImuManager.cpp]"]
  node_safety["Hazard and motion guards<br/>[SafetyManager.cpp]"]
end

subgraph group_interface["Operator Interface"]
  node_dashboard["HTTP dashboard<br/>[WebDashboard.cpp]"]
  node_assets["Embedded dashboard assets"]
  node_wifi["Wi-Fi reconnect policy"]
end

subgraph group_telemetry["Status And Radio"]
  node_publisher["Dashboard data publisher"]
  node_display["OLED status display<br/>[DisplayManager.cpp]"]
  node_radio["Experimental nRF24 link<br/>[RadioManager.cpp]"]
  node_trace["Navigation trace"]
  node_buzzer["Audible alerts<br/>[BuzzerManager.cpp]"]
end

node_operator(("Robot operator"))
node_browser(("Browser client"))

node_operator -->|"operates"| node_browser
node_browser -->|"sends controls"| node_dashboard
node_dashboard -.->|"queues commands"| node_main
node_main -->|"initializes"| node_dashboard
node_main -->|"updates AUTO"| node_navigation
node_main -->|"dispatches commands"| node_drive
node_main -->|"updates readings"| node_sensors
node_main -->|"updates guards"| node_safety
node_main -->|"updates telemetry"| node_imu
node_main -->|"publishes status"| node_publisher
node_main -->|"refreshes display"| node_display
node_main -->|"updates radio"| node_radio
node_main -->|"records navigation"| node_trace
node_main -->|"updates alerts"| node_buzzer
node_navigation -->|"reads samples"| node_sensors
node_navigation -->|"checks hazards"| node_safety
node_navigation -->|"uses turn data"| node_imu
node_navigation -->|"commands motion"| node_motors
node_navigation -->|"scans directions"| node_servo
node_navigation -->|"uses policy"| node_recovery
node_navigation -->|"uses policy"| node_reacquire
node_drive -->|"dispatches movement"| node_motors
node_publisher -->|"reads status"| node_sensors
node_publisher -->|"updates display data"| node_display
node_publisher -->|"sets telemetry"| node_dashboard
node_dashboard -->|"serves assets"| node_assets
node_dashboard -->|"handles reconnects"| node_wifi
node_browser -->|"polls telemetry"| node_dashboard
node_radio -.->|"experimental path"| node_operator

click node_main "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/main.cpp"
click node_navigation "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/NavigationManager.cpp"
click node_recovery "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/include/StuckRecoveryV2Policy.h"
click node_reacquire "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/include/SonarReacquirePolicy.h"
click node_drive "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/DriveCommandHandler.cpp"
click node_motors "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/MotorController.cpp"
click node_servo "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/ServoScanner.cpp"
click node_sensors "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/SensorManager.cpp"
click node_imu "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/ImuManager.cpp"
click node_safety "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/SafetyManager.cpp"
click node_dashboard "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/WebDashboard.cpp"
click node_assets "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/WebDashboardAssets.cpp"
click node_wifi "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/include/StaReconnectPolicy.h"
click node_publisher "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/DashboardPublisher.cpp"
click node_display "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/DisplayManager.cpp"
click node_radio "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/RadioManager.cpp"
click node_trace "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/NavigationTrace.cpp"
click node_buzzer "https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/BuzzerManager.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_main,node_navigation,node_recovery,node_reacquire,node_drive,node_motors,node_servo,node_browser toneBlue
class node_sensors,node_imu,node_safety toneAmber
class node_dashboard,node_assets,node_wifi toneMint
class node_publisher,node_display,node_radio,node_trace,node_buzzer toneRose
class node_operator toneIndigo
```

## Components

### Robot Control

- [Firmware service loop](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/main.cpp): `src/main.cpp`
- [AUTO navigation](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/NavigationManager.cpp): `src/NavigationManager.cpp`
- [V3.2 recovery policy](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/include/StuckRecoveryV2Policy.h): `include/StuckRecoveryV2Policy.h`
- [Sonar reacquisition](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/include/SonarReacquirePolicy.h): `include/SonarReacquirePolicy.h`
- [Manual drive commands](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/DriveCommandHandler.cpp): `src/DriveCommandHandler.cpp`
- [Motor controller](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/MotorController.cpp): `src/MotorController.cpp`
- [Servo scanner](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/ServoScanner.cpp): `src/ServoScanner.cpp`

### Sensing And Safety

- [Sensor acquisition](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/SensorManager.cpp): `src/SensorManager.cpp`
- [IMU telemetry](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/ImuManager.cpp): `src/ImuManager.cpp`
- [Hazard and motion guards](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/SafetyManager.cpp): `src/SafetyManager.cpp`

### Operator Interface

- [HTTP dashboard](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/WebDashboard.cpp): `src/WebDashboard.cpp`
- [Embedded dashboard assets](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/WebDashboardAssets.cpp): `src/WebDashboardAssets.cpp`
- [Wi-Fi reconnect policy](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/include/StaReconnectPolicy.h): `include/StaReconnectPolicy.h`

### Status And Radio

- [Dashboard data publisher](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/DashboardPublisher.cpp): `src/DashboardPublisher.cpp`
- [OLED status display](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/DisplayManager.cpp): `src/DisplayManager.cpp`
- [Experimental nRF24 link](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/RadioManager.cpp): `src/RadioManager.cpp`
- [Navigation trace](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/NavigationTrace.cpp): `src/NavigationTrace.cpp`
- [Audible alerts](https://github.com/hhh-habib/piku-2.1-rev-a-advanced-firmware/blob/master/src/BuzzerManager.cpp): `src/BuzzerManager.cpp`

### Other components

- **Robot operator**
- **Browser client**

## Connections

- Robot operator → Browser client: operates (evidence: `README.md`)
- Browser client → HTTP dashboard: sends controls (evidence: `README.md`)
- HTTP dashboard → Firmware service loop: queues commands
- Firmware service loop → HTTP dashboard: initializes (evidence: `src/main.cpp`)
- Firmware service loop → AUTO navigation: updates AUTO (evidence: `src/main.cpp`)
- Firmware service loop → Manual drive commands: dispatches commands (evidence: `src/main.cpp`)
- Firmware service loop → Sensor acquisition: updates readings (evidence: `src/main.cpp`)
- Firmware service loop → Hazard and motion guards: updates guards (evidence: `src/main.cpp`)
- Firmware service loop → IMU telemetry: updates telemetry (evidence: `src/main.cpp`)
- Firmware service loop → Dashboard data publisher: publishes status (evidence: `src/main.cpp`)
- Firmware service loop → OLED status display: refreshes display (evidence: `src/main.cpp`)
- Firmware service loop → Experimental nRF24 link: updates radio (evidence: `src/main.cpp`)
- Firmware service loop → Navigation trace: records navigation (evidence: `src/main.cpp`)
- Firmware service loop → Audible alerts: updates alerts (evidence: `src/main.cpp`)
- AUTO navigation → Sensor acquisition: reads samples
- AUTO navigation → Hazard and motion guards: checks hazards
- AUTO navigation → IMU telemetry: uses turn data
- AUTO navigation → Motor controller: commands motion
- AUTO navigation → Servo scanner: scans directions
- AUTO navigation → V3.2 recovery policy: uses policy
- AUTO navigation → Sonar reacquisition: uses policy
- Manual drive commands → Motor controller: dispatches movement
- Dashboard data publisher → Sensor acquisition: reads status
- Dashboard data publisher → OLED status display: updates display data
- Dashboard data publisher → HTTP dashboard: sets telemetry
- HTTP dashboard → Embedded dashboard assets: serves assets (evidence: `src/WebDashboard.cpp`)
- HTTP dashboard → Wi-Fi reconnect policy: handles reconnects (evidence: `src/WebDashboard.cpp`)
- Browser client → HTTP dashboard: polls telemetry (evidence: `README.md`)
- Experimental nRF24 link → Robot operator: experimental path (evidence: `README.md`)
