# ivnkarpenko/berdanka-test architecture

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

- Interactive diagram: https://gitdiagram.com/ivnkarpenko/berdanka-test
- Repository: https://github.com/ivnkarpenko/berdanka-test
- Video tour (about a minute): https://gitdiagram.com/ivnkarpenko/berdanka-test/video

## Overview

This repository implements an IMU-based orientation and target-status display, with TCP clients that can set a target angle and, on Windows, optionally derive target angles from camera detections. The main workflow is sensor orientation → quantized angles and target comparison → serial telemetry for Processing; client-supplied angles set the spawn reference. Source excerpts support the firmware and client behavior, while the Processing sketch’s implementation is not sampled.

Main entry points: [`src/main.cpp`](https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp) (TCP server), [`tools/windows_tcp_gui.py`](https://github.com/ivnkarpenko/berdanka-test/blob/main/tools/windows_tcp_gui.py) (Windows GUI), [`tools/jetson_tcp_gui.py`](https://github.com/ivnkarpenko/berdanka-test/blob/main/tools/jetson_tcp_gui.py) (Jetson GUI), [`yolo11n.pt`](https://github.com/ivnkarpenko/berdanka-test/blob/main/yolo11n.pt) (YOLO model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Arduino firmware"]
  node_arduino["Orientation controller<br/>[main.cpp]"]
  node_angle["Angle processing<br/>[main.cpp]"]
  node_target["Spawn and target state<br/>[main.cpp]"]
  node_tcp["TCP server<br/>[main.cpp]"]
  node_serial["Serial telemetry<br/>[main.cpp]"]
end

subgraph group_clients["TCP clients"]
  node_windows["Windows GUI<br/>[windows_tcp_gui.py]"]
  node_jetson["Jetson GUI<br/>[jetson_tcp_gui.py]"]
end

subgraph group_vision["Camera vision"]
  node_vision["Detection and angle conversion<br/>[windows_tcp_gui.py]"]
  node_model["YOLO model<br/>[yolo11n.pt]"]
end

subgraph group_display["Serial display"]
  node_processing["Serial animation"]
end

node_operator(("Operator"))
node_imu{{"ICM-20948 IMU"}}
node_camera{{"Camera"}}

node_imu -->|"provides sensor data"| node_arduino
node_arduino -->|"reads orientation"| node_angle
node_angle -->|"updates angles"| node_target
node_tcp -->|"sets spawn angles"| node_target
node_arduino -->|"handles client traffic"| node_tcp
node_windows -->|"sends TCP packets"| node_tcp
node_tcp -->|"returns ACK or error"| node_windows
node_jetson -->|"sends TCP packets"| node_tcp
node_tcp -->|"returns ACK or error"| node_jetson
node_camera -->|"provides frames"| node_vision
node_windows -->|"controls detection"| node_vision
node_model -.->|"supports detection"| node_vision
node_vision -->|"sends detected angles"| node_tcp
node_target -->|"formats status"| node_serial
node_serial -->|"streams telemetry"| node_processing
node_operator -->|"configures and monitors"| node_windows
node_operator -->|"configures and sends"| node_jetson

click node_arduino "https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp"
click node_angle "https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp"
click node_target "https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp"
click node_tcp "https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp"
click node_serial "https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp"
click node_windows "https://github.com/ivnkarpenko/berdanka-test/blob/main/tools/windows_tcp_gui.py"
click node_jetson "https://github.com/ivnkarpenko/berdanka-test/blob/main/tools/jetson_tcp_gui.py"
click node_vision "https://github.com/ivnkarpenko/berdanka-test/blob/main/tools/windows_tcp_gui.py"
click node_model "https://github.com/ivnkarpenko/berdanka-test/blob/main/yolo11n.pt"
click node_processing "https://github.com/ivnkarpenko/berdanka-test/blob/main/processing/serial_animation/serial_animation.pde"

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_arduino,node_angle,node_target,node_tcp,node_serial toneBlue
class node_windows,node_jetson toneAmber
class node_vision,node_model toneMint
class node_processing toneRose
class node_operator,node_imu,node_camera toneIndigo
```

## Components

### Arduino firmware

- [Orientation controller](https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp): `src/main.cpp`
- [Angle processing](https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp): `src/main.cpp`
- [Spawn and target state](https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp): `src/main.cpp`
- [TCP server](https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp): `src/main.cpp`
- [Serial telemetry](https://github.com/ivnkarpenko/berdanka-test/blob/main/src/main.cpp): `src/main.cpp`

### TCP clients

- [Windows GUI](https://github.com/ivnkarpenko/berdanka-test/blob/main/tools/windows_tcp_gui.py): `tools/windows_tcp_gui.py`
- [Jetson GUI](https://github.com/ivnkarpenko/berdanka-test/blob/main/tools/jetson_tcp_gui.py): `tools/jetson_tcp_gui.py`

### Camera vision

- [Detection and angle conversion](https://github.com/ivnkarpenko/berdanka-test/blob/main/tools/windows_tcp_gui.py): `tools/windows_tcp_gui.py`
- [YOLO model](https://github.com/ivnkarpenko/berdanka-test/blob/main/yolo11n.pt): `yolo11n.pt`

### Serial display

- [Serial animation](https://github.com/ivnkarpenko/berdanka-test/blob/main/processing/serial_animation/serial_animation.pde): `processing/serial_animation/serial_animation.pde`

### Other components

- **Operator**
- **ICM-20948 IMU**
- **Camera**

## Connections

- ICM-20948 IMU → Orientation controller: provides sensor data
- Orientation controller → Angle processing: reads orientation
- Angle processing → Spawn and target state: updates angles
- TCP server → Spawn and target state: sets spawn angles
- Orientation controller → TCP server: handles client traffic
- Windows GUI → TCP server: sends TCP packets
- TCP server → Windows GUI: returns ACK or error
- Jetson GUI → TCP server: sends TCP packets
- TCP server → Jetson GUI: returns ACK or error
- Camera → Detection and angle conversion: provides frames
- Windows GUI → Detection and angle conversion: controls detection
- YOLO model → Detection and angle conversion: supports detection
- Detection and angle conversion → TCP server: sends detected angles
- Spawn and target state → Serial telemetry: formats status
- Serial telemetry → Serial animation: streams telemetry
- Operator → Windows GUI: configures and monitors
- Operator → Jetson GUI: configures and sends
