# omritz/drl-crazyflie architecture

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

- Interactive diagram: https://gitdiagram.com/omritz/drl-crazyflie
- Repository: https://github.com/omritz/drl-crazyflie

## Overview

DRL-Crazyflie trains a DQN goal-seeking policy in an AirSim Gym environment, then can run a trained policy on a physical Crazyflie. Training turns simulator observations and rewards into replayed transitions and network updates; deployment instead loads a saved model and uses Crazyflie telemetry and motion commands. The map also retains the documented fixed-target-network and replay capabilities. Source excerpts support the core calls; checkpoint and model persistence are shown, but the saved artifacts are not inspected.

Main entry points: [`main_DRL.py`](https://github.com/omritz/drl-crazyflie/blob/master/main_DRL.py) (Training runner), [`DQN_agent.py`](https://github.com/omritz/drl-crazyflie/blob/master/DQN_agent.py) (DQN agent), [`main_crazyflie.py`](https://github.com/omritz/drl-crazyflie/blob/master/main_crazyflie.py) (Policy runner), [`gym_airsim/envs/AirGym.py`](https://github.com/omritz/drl-crazyflie/blob/master/gym_airsim/envs/AirGym.py) (Goal environment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training workflow"]
  node_train["Training runner<br/>[main_DRL.py]"]
  node_metrics["Training metrics<br/>[main_DRL.py]"]
  node_policy_files["Saved policy"]
  node_checkpoints["Weight checkpoints"]
end

subgraph group_environment["AirSim environment"]
  node_gym_entry["Gym registration<br/>[__init__.py]"]
  node_air_env["Goal environment<br/>[AirGym.py]"]
  node_sim_client["AirSim controls<br/>[myAirSimClient.py]"]
end

subgraph group_learning["DQN learning"]
  node_agent["DQN agent<br/>[DQN_agent.py]"]
  node_replay[("Experience replay<br/>[DQN_agent.py]")]
  node_q_networks["Q networks<br/>[DQN_agent.py]"]
end

subgraph group_deployment["Crazyflie deployment"]
  node_deployer["Policy runner<br/>[main_crazyflie.py]"]
  node_cf_client["Crazyflie controls"]
end

node_operator(("Project user"))
node_airsim{{"AirSim simulator"}}
node_crazyflie{{"Crazyflie drone"}}

node_operator -->|"starts training"| node_train
node_operator -->|"runs policy"| node_deployer
node_train -->|"creates environment"| node_gym_entry
node_gym_entry -->|"registers environment"| node_air_env
node_train -->|"trains"| node_agent
node_train -->|"records metrics"| node_metrics
node_train -->|"saves model"| node_policy_files
node_train -->|"saves weights"| node_checkpoints
node_air_env -->|"controls and observes"| node_sim_client
node_sim_client -->|"sends commands"| node_airsim
node_airsim -->|"returns telemetry"| node_sim_client
node_train -->|"steps environment"| node_air_env
node_agent -->|"stores and samples"| node_replay
node_agent -->|"predicts and updates"| node_q_networks
node_agent -->|"samples transitions"| node_replay
node_deployer -->|"loads model"| node_policy_files
node_deployer -->|"requests observations and actions"| node_cf_client
node_cf_client -->|"commands flight"| node_crazyflie
node_crazyflie -->|"provides telemetry"| node_cf_client

click node_train "https://github.com/omritz/drl-crazyflie/blob/master/main_DRL.py"
click node_metrics "https://github.com/omritz/drl-crazyflie/blob/master/main_DRL.py"
click node_policy_files "https://github.com/omritz/drl-crazyflie/tree/master/models"
click node_checkpoints "https://github.com/omritz/drl-crazyflie/tree/master/checkpoints"
click node_gym_entry "https://github.com/omritz/drl-crazyflie/blob/master/gym_airsim/__init__.py"
click node_air_env "https://github.com/omritz/drl-crazyflie/blob/master/gym_airsim/envs/AirGym.py"
click node_sim_client "https://github.com/omritz/drl-crazyflie/blob/master/gym_airsim/envs/myAirSimClient.py"
click node_agent "https://github.com/omritz/drl-crazyflie/blob/master/DQN_agent.py"
click node_replay "https://github.com/omritz/drl-crazyflie/blob/master/DQN_agent.py"
click node_q_networks "https://github.com/omritz/drl-crazyflie/blob/master/DQN_agent.py"
click node_deployer "https://github.com/omritz/drl-crazyflie/blob/master/main_crazyflie.py"
click node_cf_client "https://github.com/omritz/drl-crazyflie/blob/master/myCrazyFlieClient.py"

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_train,node_metrics,node_policy_files,node_checkpoints,node_operator toneBlue
class node_gym_entry,node_air_env,node_sim_client toneAmber
class node_agent,node_replay,node_q_networks toneMint
class node_deployer,node_cf_client toneRose
class node_airsim,node_crazyflie toneIndigo
```

## Components

### Training workflow

- [Training runner](https://github.com/omritz/drl-crazyflie/blob/master/main_DRL.py): `main_DRL.py`
- [Training metrics](https://github.com/omritz/drl-crazyflie/blob/master/main_DRL.py): `main_DRL.py`
- [Saved policy](https://github.com/omritz/drl-crazyflie/tree/master/models): `models`
- [Weight checkpoints](https://github.com/omritz/drl-crazyflie/tree/master/checkpoints): `checkpoints`

### AirSim environment

- [Gym registration](https://github.com/omritz/drl-crazyflie/blob/master/gym_airsim/__init__.py): `gym_airsim/__init__.py`
- [Goal environment](https://github.com/omritz/drl-crazyflie/blob/master/gym_airsim/envs/AirGym.py): `gym_airsim/envs/AirGym.py`
- [AirSim controls](https://github.com/omritz/drl-crazyflie/blob/master/gym_airsim/envs/myAirSimClient.py): `gym_airsim/envs/myAirSimClient.py`

### DQN learning

- [DQN agent](https://github.com/omritz/drl-crazyflie/blob/master/DQN_agent.py): `DQN_agent.py`
- [Experience replay](https://github.com/omritz/drl-crazyflie/blob/master/DQN_agent.py): `DQN_agent.py`
- [Q networks](https://github.com/omritz/drl-crazyflie/blob/master/DQN_agent.py): `DQN_agent.py`

### Crazyflie deployment

- [Policy runner](https://github.com/omritz/drl-crazyflie/blob/master/main_crazyflie.py): `main_crazyflie.py`
- [Crazyflie controls](https://github.com/omritz/drl-crazyflie/blob/master/myCrazyFlieClient.py): `myCrazyFlieClient.py`

### Other components

- **Project user**
- **AirSim simulator**
- **Crazyflie drone**

## Connections

- Project user → Training runner: starts training (evidence: `README.md`)
- Project user → Policy runner: runs policy (evidence: `README.md`)
- Training runner → Gym registration: creates environment (evidence: `main_DRL.py`)
- Gym registration → Goal environment: registers environment (evidence: `gym_airsim/__init__.py`)
- Training runner → DQN agent: trains (evidence: `main_DRL.py`)
- Training runner → Training metrics: records metrics (evidence: `main_DRL.py`)
- Training runner → Saved policy: saves model
- Training runner → Weight checkpoints: saves weights
- Goal environment → AirSim controls: controls and observes (evidence: `gym_airsim/envs/AirGym.py`)
- AirSim controls → AirSim simulator: sends commands (evidence: `gym_airsim/envs/myAirSimClient.py`)
- AirSim simulator → AirSim controls: returns telemetry (evidence: `gym_airsim/envs/myAirSimClient.py`)
- Training runner → Goal environment: steps environment (evidence: `main_DRL.py`)
- DQN agent → Experience replay: stores and samples (evidence: `DQN_agent.py`)
- DQN agent → Q networks: predicts and updates (evidence: `DQN_agent.py`)
- DQN agent → Experience replay: samples transitions (evidence: `DQN_agent.py`)
- Policy runner → Saved policy: loads model (evidence: `main_crazyflie.py`)
- Policy runner → Crazyflie controls: requests observations and actions (evidence: `main_crazyflie.py`)
- Crazyflie controls → Crazyflie drone: commands flight (evidence: `myCrazyFlieClient.py`)
- Crazyflie drone → Crazyflie controls: provides telemetry (evidence: `myCrazyFlieClient.py`)
