# iwishiwasaneagle/jdrones architecture

> Architecture diagram of the GitHub repository iwishiwasaneagle/jdrones, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iwishiwasaneagle/jdrones
- Repository: https://github.com/iwishiwasaneagle/jdrones

## Overview

##### Main Components
- Environment Layer: Represent the different drone simulation environments. From the README, list out the available environments (e.g., PyBulletDroneEnv-v0, NonLinearDynamicModelDroneEnv-v0, etc.) and note that these are implemented under src/jdrones/envs and the related “base” abstractions.
- Simulation Engine Integration: Highlight the integration with pybullet (the physics simulation engine). This includes components that interface with pybullet (likely within the environment’s execution, including the .dae and .urdf files and related simulation models).
- Controllers and Dynamics Models: Identify the modules that implement the drone’s control logic (e.g., controllers.py, lqr.py for LQR controller, and drone environment dynamics in the base directory).
- Data Models & Transformations: Include components that handle drone states, trajectories, data representations, and transforms (data_models.py, trajectory.py, transforms.py).
- Utility and Helper Functions: Capture plotting utilities (plotting.py), mathematical operations (maths.py), solver routines (solvers.py), and energy modeling (energy_model.py).
- External Interfaces and Examples: Represent the example notebooks and scripts meant for demonstrating usage (found in docs/examples and the example directories in docs) and how they integrate with the simulation.
- Testing Infrastructure: Include the “tests” directory to show how different components are validated. This is important to illustrate that the design supports integration and unit testing.

##### Establish Relationships and Interactions
- Modular Structure: Emphasize the separation between environment definitions (in src/jdrones/envs) and controllers (in src/jdrones/controllers.py) with additional support from data models and mathematical transformations.
- External Dependencies: Indicate the connection to external libraries (pybullet, gymnasium) that are the backbone of the simulation and interface.

##### Architectural Patterns and Design Principles
- Modularity & Separation of Concerns: The file structure clearly separates simulation environment implementations, controller logic, data modeling, and utility routines.
- Extensibility: The use of a Gymnasium-style API ensures that additional environments or extension to controllers can be seamlessly integrated.
- Testability: Show that robust tests (with a dedicated directory and specific test modules) play a key role in validating each component.

##### Final Advice
- Be very detailed—don’t shy away from breaking the project into as many functional components as possible.
- Component is represented with a clear label showing its responsibility.
- Keep the interactions between the simulation, control algorithms, and data/model utilities explicit: show how data flows through the system and which parts depend on external libraries and frameworks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Environment / Simulation Layer
    subgraph "Environment / Simulation Layer"
        E1["Drone Simulation Environments"]:::env
        E2["Base Abstractions"]:::env
        E3["PyBullet Model: drone.dae"]:::env
        E4["PyBullet Model: droneplus.urdf"]:::env
    end

    %% Logic / Control Layer
    subgraph "Logic / Control Layer"
        C1["Controllers (Control Logic)"]:::ctrl
        C2["LQR Controller Module"]:::ctrl
    end

    %% Data & Utility Layer
    subgraph "Data & Utility Layer"
        D1["Data Models"]:::util
        D2["Trajectory Computation"]:::util
        D3["Transforms"]:::util
        U1["Plotting Utility"]:::util
        U2["Maths Utility"]:::util
        U3["Solver Routines"]:::util
        U4["Energy Model"]:::util
    end

    %% External Interfaces & Examples
    subgraph "External Interfaces & Examples"
        X1["Example Scripts/Notebooks"]:::ext
    end

    %% Testing Infrastructure
    subgraph "Testing Infrastructure"
        T1["Testing Suite"]:::test
    end

    %% Connections between Environment and Control Layers
    E1 -->|"sensor_data"| C1
    C1 -->|"control_command"| E1

    %% Internal Environment connections
    E2 --> E1
    E3 --> E1
    E4 --> E1

    %% Controllers dependency
    C1 -->|"uses"| C2

    %% Data Models & Transforms shared between Environment and Controllers
    D1 --- C1
    D1 --- E1
    D2 --- C1
    D2 --- E1
    D3 --- C1
    D3 --- E1

    %% Utilities supporting Data Models
    U1 -.-> D1
    U2 -.-> D1
    U3 -.-> D1
    U4 -.-> D1

    %% External Interfaces feeding into Environment and Controllers
    X1 --> E1
    X1 --> C1

    %% Testing connects to core components
    T1 --- E1
    T1 --- C1
    T1 --- D1
    T1 --- U1

    %% Click Events for Environment Layer
    click E1 "https://github.com/iwishiwasaneagle/jdrones/tree/master/src/jdrones/envs"
    click E2 "https://github.com/iwishiwasaneagle/jdrones/tree/master/src/jdrones/envs/base"
    click E3 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/envs/drone.dae"
    click E4 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/envs/droneplus.urdf"

    %% Click Events for Controllers and Dynamics Models
    click C1 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/controllers.py"
    click C2 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/envs/lqr.py"

    %% Click Events for Data Models & Transforms
    click D1 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/data_models.py"
    click D2 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/trajectory.py"
    click D3 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/transforms.py"

    %% Click Events for Utility Functions
    click U1 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/plotting.py"
    click U2 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/maths.py"
    click U3 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/solvers.py"
    click U4 "https://github.com/iwishiwasaneagle/jdrones/blob/master/src/jdrones/energy_model.py"

    %% Click Event for External Interfaces
    click X1 "https://github.com/iwishiwasaneagle/jdrones/tree/master/docs/examples"

    %% Click Event for Testing Infrastructure
    click T1 "https://github.com/iwishiwasaneagle/jdrones/tree/master/tests"

    %% Styles
    classDef env fill:#C9E3FF,stroke:#333,stroke-width:2px,color:#000;
    classDef ctrl fill:#FFC9E3,stroke:#333,stroke-width:2px,color:#000;
    classDef util fill:#C9FFC9,stroke:#333,stroke-width:2px,color:#000;
    classDef ext fill:#F3F3C9,stroke:#333,stroke-width:2px,color:#000;
    classDef test fill:#F3C9FF,stroke:#333,stroke-width:2px,color:#000;
```
