# wisarutlt01-commits/duck-delivery-drone architecture

> Architecture diagram of the GitHub repository wisarutlt01-commits/duck-delivery-drone, 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/wisarutlt01-commits/duck-delivery-drone
- Repository: https://github.com/wisarutlt01-commits/duck-delivery-drone

## Overview

This repository implements a DJI payload app for dynamic return-to-home landing, plus a Ground Pi-to-Drone Pi target-location link. The main workflow publishes target coordinates, transfers and validates them, then lets an operator trigger a flight-control state machine that updates the home point and go-home altitude, starts RTH, and monitors landing. The state-machine stages are represented separately to make that domain flow clear. The source excerpts are partial and there is no README content, so link wiring beyond the documented publisher/bridge flow is omitted where uncertain.

Main entry points: [`main.cpp`](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp) (RTH State Machine), [`tools/location_link/publisher.py`](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/publisher.py) (Location Publisher), [`tools/location_link/bridge.py`](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/bridge.py) (Location Bridge), [`rth_log.cpp`](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/rth_log.cpp) (RTH Logging)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flight["RTH Flight App"]
  node_rth["RTH State Machine<br/>[main.cpp]"]
  node_trigger["Widget Trigger<br/>[main.cpp]"]
  node_location["Fetch Target<br/>[main.cpp]"]
  node_sethome["Set Home<br/>[main.cpp]"]
  node_altitude["Set Altitude<br/>[main.cpp]"]
  node_gohome["Start Go-Home<br/>[main.cpp]"]
  node_monitor["Monitor RTH<br/>[main.cpp]"]
  node_landing["Wait Landing<br/>[main.cpp]"]
  node_telemetry["Flight Telemetry<br/>[main.cpp]"]
end

subgraph group_link["Location Link"]
  node_publisher["Location Publisher<br/>[publisher.py]"]
  node_config["Config Loader<br/>[config.py]"]
  node_packet["Packet Codec<br/>[packet.py]"]
  node_transport["Transport Adapters<br/>[transport.py]"]
  node_bridge["Location Bridge<br/>[bridge.py]"]
end

subgraph group_platform["DJI Platform Services"]
  node_widget["DJI Pilot Widget"]
  node_logging["RTH Logging<br/>[rth_log.cpp]"]
end

node_operator(("Pilot"))
node_ground(("Ground Location Source"))
node_targetfile[("Target Location File")]
node_fc["DJI Flight Controller"]
node_hms["DJI HMS Alerts"]
node_pilotview["Pilot Notifications"]

node_ground -->|"provides coordinates"| node_publisher
node_publisher -->|"loads settings"| node_config
node_publisher -->|"encodes coordinates"| node_packet
node_publisher -->|"sends packets"| node_transport
node_transport -->|"delivers packets"| node_bridge
node_bridge -->|"loads settings"| node_config
node_bridge -->|"decodes packets"| node_packet
node_bridge -->|"writes latest location"| node_targetfile
node_operator -->|"presses"| node_trigger
node_trigger -->|"signals trigger"| node_rth
node_rth -->|"dispatches"| node_location
node_location -->|"reads coordinates"| node_targetfile
node_rth -->|"dispatches"| node_sethome
node_rth -->|"dispatches"| node_altitude
node_rth -->|"dispatches"| node_gohome
node_rth -->|"dispatches"| node_monitor
node_rth -->|"dispatches"| node_landing
node_rth -->|"subscribes to"| node_telemetry
node_sethome -->|"sets home point"| node_fc
node_altitude -->|"sets go-home altitude"| node_fc
node_gohome -->|"starts RTH"| node_fc
node_monitor -->|"checks flight state"| node_fc
node_telemetry -->|"subscribes topics"| node_fc
node_rth -->|"reports events"| node_logging
node_logging -->|"shows messages"| node_widget
node_logging -->|"injects alerts"| node_hms
node_hms -->|"notifies pilot"| node_pilotview
node_widget -->|"displays status"| node_pilotview

click node_publisher "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/publisher.py"
click node_config "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/config.py"
click node_packet "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/packet.py"
click node_transport "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/transport.py"
click node_bridge "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/bridge.py"
click node_rth "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp"
click node_trigger "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp"
click node_location "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp"
click node_sethome "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp"
click node_altitude "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp"
click node_gohome "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp"
click node_monitor "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp"
click node_landing "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp"
click node_telemetry "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp"
click node_logging "https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/rth_log.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_rth,node_trigger,node_location,node_sethome,node_altitude,node_gohome,node_monitor,node_landing,node_telemetry toneBlue
class node_publisher,node_config,node_packet,node_transport,node_bridge,node_targetfile toneAmber
class node_widget,node_logging toneMint
class node_operator,node_ground,node_fc,node_hms,node_pilotview toneIndigo
```

## Components

### RTH Flight App

- [RTH State Machine](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp): `main.cpp`
- [Widget Trigger](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp): `main.cpp`
- [Fetch Target](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp): `main.cpp`
- [Set Home](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp): `main.cpp`
- [Set Altitude](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp): `main.cpp`
- [Start Go-Home](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp): `main.cpp`
- [Monitor RTH](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp): `main.cpp`
- [Wait Landing](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp): `main.cpp`
- [Flight Telemetry](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/main.cpp): `main.cpp`

### Location Link

- [Location Publisher](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/publisher.py): `tools/location_link/publisher.py`
- [Config Loader](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/config.py): `tools/location_link/config.py`
- [Packet Codec](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/packet.py): `tools/location_link/packet.py`
- [Transport Adapters](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/transport.py): `tools/location_link/transport.py`
- [Location Bridge](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/tools/location_link/bridge.py): `tools/location_link/bridge.py`

### DJI Platform Services

- **DJI Pilot Widget**
- [RTH Logging](https://github.com/wisarutlt01-commits/duck-delivery-drone/blob/main/rth_log.cpp): `rth_log.cpp`

### Other components

- **Pilot**
- **Ground Location Source**
- **Target Location File**
- **DJI Flight Controller**
- **DJI HMS Alerts**
- **Pilot Notifications**

## Connections

- Ground Location Source → Location Publisher: provides coordinates
- Location Publisher → Config Loader: loads settings
- Location Publisher → Packet Codec: encodes coordinates
- Location Publisher → Transport Adapters: sends packets
- Transport Adapters → Location Bridge: delivers packets
- Location Bridge → Config Loader: loads settings
- Location Bridge → Packet Codec: decodes packets
- Location Bridge → Target Location File: writes latest location
- Pilot → Widget Trigger: presses
- Widget Trigger → RTH State Machine: signals trigger
- RTH State Machine → Fetch Target: dispatches
- Fetch Target → Target Location File: reads coordinates
- RTH State Machine → Set Home: dispatches
- RTH State Machine → Set Altitude: dispatches
- RTH State Machine → Start Go-Home: dispatches
- RTH State Machine → Monitor RTH: dispatches
- RTH State Machine → Wait Landing: dispatches
- RTH State Machine → Flight Telemetry: subscribes to
- Set Home → DJI Flight Controller: sets home point
- Set Altitude → DJI Flight Controller: sets go-home altitude
- Start Go-Home → DJI Flight Controller: starts RTH
- Monitor RTH → DJI Flight Controller: checks flight state
- Flight Telemetry → DJI Flight Controller: subscribes topics
- RTH State Machine → RTH Logging: reports events
- RTH Logging → DJI Pilot Widget: shows messages
- RTH Logging → DJI HMS Alerts: injects alerts
- DJI HMS Alerts → Pilot Notifications: notifies pilot
- DJI Pilot Widget → Pilot Notifications: displays status
