# aravindustries/mavsim_public3 architecture

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

- Interactive diagram: https://gitdiagram.com/aravindustries/mavsim_public3
- Repository: https://github.com/aravindustries/mavsim_public3

## Overview

Based on our analysis of the provided file tree and README, the project is a simulation and demonstration framework built around the concepts presented in “Small Unmanned Aircraft: Theory and Practice.” It is used for education and research on unmanned aerial vehicle (UAV) modeling, control, state estimation, path planning, and visualization. The repository contains multiple implementations – primarily in Python (both “legacy” and a current “mavsim_python” version), MATLAB code (“mavsim_matlab”), and Simulink models (“mavsim_simulink”) – which are organized by chapters that align with the book’s progression.

##### Main Components
- Simulation Engines: There are multiple “engines” implemented in different languages. Indicate separate branches or layers for:
– Legacy Python simulation code (legacy_mavsim_python)
– Current Python simulation and supporting modules (mavsim_python)
– MATLAB simulation files (mavsim_matlab)
– Simulink models (mavsim_simulink)
- Subsystems within each simulation type:
– Dynamics/Physical Models: “mav_dynamics”, “wind_simulation”, “compute_models”, “model_coef”, etc.
– Control Modules: “controllers” (e.g., autopilot, LQR, PD, PI, PID, TECS) that compute control actions based on aircraft state.
– Estimators/Observers: “estimators” (various observer implementations and filtering algorithms) that process simulated sensor data.
– Planners and Path Managers: “planners” in Python and path management in legacy or MATLAB code (including RRT, Dubins paths, etc.).
– Visualization/Viewers: “viewers”, “state_plotter”, “data_viewer”, “video_writer” modules for plotting states, drawing maps, or rendering 3D models.
– Helper Tools & Message Types: “tools” and “message_types” for common utilities (rotations, signals, transfer functions) and for defining inter-module data structures.
– Parameters/configuration: “parameters” directories capture configuration constants for the aircraft, sensors, control gains, simulation settings, etc.
- Integration / Launch Files: “launch_files” in the Python version show how the different components are composed together for each chapter’s simulation run.

##### Relationships and Interactions
- For each simulation environment, illustrate a high-level data flow:
– A core “Dynamics/Model” unit receives control commands from the “Controllers” and uses “Parameters” to simulate aircraft physics.
– “Estimators/Observers” process sensor-simulated data from the dynamics model and forward state estimates back to the controllers (feedback loop).
– “Planners” provide guidance (for waypoint, path, or orbit following) that feeds into control modules.
– “Viewers” and “Plotters” subscribe to simulation outputs and estimator outputs to display results.
- The “message_types” modules serve as standardized data exchange formats between these layers.

##### Architectural Patterns and Design Principles
- A modular, loosely coupled architecture where:
– The “Model” (dynamics, physical simulation) is isolated from the “View” (visualizers, plotters).
– Controllers and estimators work as separate, plug-in modules that can be interchanged or updated (for example, different autopilot algorithms in “controllers”).
– A Model-View-Controller (MVC) or a layered design is evident, with clear separation between simulation, control logic, data processing, and visualization.
- That multiple “chapters” indicate simulation experiments or educational modules; these can be represented as distinct scenarios or nodes that integrate the common components in different configurations.

##### Relevant Technologies and Tools
- Python libraries and the organization of modules in “mavsim_python” (such as integration through launch_files, controllers, and viewers).
- MATLAB’s scripting and function-based model in “mavsim_matlab.”
- The “tools” directories that host common utilities (rotations, transfer function calculations) should be depicted as support modules used by the main simulation components.

##### Final Reporting of Essential Architectural Elements
- That each component is clearly identified with its function and that interdependencies (e.g., the feedback loops in the simulation) are drawn with clear directional labels.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Legacy Python Simulation Engine
    subgraph "Legacy Python Simulation Engine"
        LP_Engine["Legacy Python Engine"]:::legacy_engine
        LP_Dynamics["Dynamics Model"]:::legacy_engine
        LP_Compute["Compute Models"]:::legacy_engine
        LP_Controllers["Controllers"]:::legacy_engine
        LP_Planners["Planners/Path Managers"]:::legacy_engine
        LP_Visualization["Visualization/Viewers"]:::legacy_engine
        LP_Message["Message Types"]:::legacy_engine
        LP_Parameters["Parameters/Configuration"]:::legacy_engine
        LP_Tools["Helper Tools"]:::legacy_engine

        LP_Engine --> LP_Dynamics
        LP_Engine --> LP_Compute
        LP_Engine --> LP_Controllers
        LP_Engine --> LP_Planners
        LP_Engine --> LP_Visualization
        LP_Engine --> LP_Message
        LP_Engine --> LP_Parameters
        LP_Engine --> LP_Tools
    end

    %% Relationships within Legacy Simulation
    LP_Dynamics -->|"sensorData"| LP_Controllers
    LP_Controllers -->|"controlCmds"| LP_Dynamics
    LP_Compute -->|"modelCoeff"| LP_Dynamics
    LP_Dynamics -->|"output"| LP_Visualization

    %% Current Python Simulation Engine
    subgraph "Current Python Simulation Engine"
        CP_Engine["Current Python Engine"]:::current_engine
        CP_Dynamics["Dynamics Model"]:::current_engine
        CP_Controllers["Controllers"]:::current_engine
        CP_Estimators["Estimators/Observers"]:::current_engine
        CP_Planners["Planners/Path Managers"]:::current_engine
        CP_Visualization["Visualization/Viewers"]:::current_engine
        CP_Launch["Integration/Launch Files"]:::current_engine
        CP_Message["Message Types"]:::current_engine
        CP_Parameters["Parameters/Configuration"]:::current_engine
        CP_Tools["Helper Tools"]:::current_engine
        CP_Plotter["Plotting Tools"]:::current_engine

        CP_Engine --> CP_Dynamics
        CP_Engine --> CP_Controllers
        CP_Engine --> CP_Estimators
        CP_Engine --> CP_Planners
        CP_Engine --> CP_Visualization
        CP_Engine --> CP_Launch
        CP_Engine --> CP_Message
        CP_Engine --> CP_Parameters
        CP_Engine --> CP_Tools
        CP_Engine --> CP_Plotter
    end

    %% Relationships within Current Simulation
    CP_Dynamics -->|"sensorData"| CP_Estimators
    CP_Estimators -->|"stateEst"| CP_Controllers
    CP_Planners -->|"guidance"| CP_Controllers
    CP_Controllers -->|"controlCmds"| CP_Dynamics
    CP_Dynamics -->|"output"| CP_Visualization

    %% MATLAB Simulation
    subgraph "MATLAB Simulation"
        ML_Engine["MATLAB Simulation Engine"]:::matlab_engine
        ML_Message["Message Types"]:::matlab_engine
        ML_Parameters["Parameters/Configuration"]:::matlab_engine
        ML_Tools["Tools"]:::matlab_engine

        ML_Engine --> ML_Message
        ML_Engine --> ML_Parameters
        ML_Engine --> ML_Tools
    end

    %% Simulink Models
    subgraph "Simulink Models"
        SL_Engine["Simulink Simulation Engine"]:::simulink_engine
        SL_Models["Simulink Models"]:::simulink_engine
        SL_Tools["Tools and Parameters"]:::simulink_engine

        SL_Engine -->|"includes"| SL_Models
        SL_Engine -->|"uses"| SL_Tools
    end

    %% Click Events for Legacy Python Simulation
    click LP_Engine "https://github.com/aravindustries/mavsim_public3/tree/main/legacy_mavsim_python"
    click LP_Dynamics "https://github.com/aravindustries/mavsim_public3/blob/main/legacy_mavsim_python/chap3/mav_dynamics.py"
    click LP_Compute "https://github.com/aravindustries/mavsim_public3/blob/main/legacy_mavsim_python/chap5/compute_models.py"
    click LP_Controllers "https://github.com/aravindustries/mavsim_public3/blob/main/legacy_mavsim_python/chap6/autopilot.py"
    click LP_Planners "https://github.com/aravindustries/mavsim_public3/blob/main/legacy_mavsim_python/chap10/path_follower.py"
    click LP_Visualization "https://github.com/aravindustries/mavsim_public3/blob/main/legacy_mavsim_python/chap2/mav_viewer.py"
    click LP_Message "https://github.com/aravindustries/mavsim_public3/tree/main/legacy_mavsim_python/message_types/"
    click LP_Parameters "https://github.com/aravindustries/mavsim_public3/tree/main/legacy_mavsim_python/parameters/"
    click LP_Tools "https://github.com/aravindustries/mavsim_public3/tree/main/legacy_mavsim_python/tools/"

    %% Click Events for Current Python Simulation
    click CP_Engine "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python"
    click CP_Dynamics "https://github.com/aravindustries/mavsim_public3/blob/main/mavsim_python/models/mav_dynamics.py"
    click CP_Controllers "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python/controllers/"
    click CP_Estimators "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python/estimators/"
    click CP_Planners "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python/planners/"
    click CP_Visualization "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python/viewers/"
    click CP_Launch "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python/launch_files/"
    click CP_Message "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python/message_types/"
    click CP_Parameters "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python/parameters/"
    click CP_Tools "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python/tools/"
    click CP_Plotter "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_python/plotter/"

    %% Click Events for MATLAB Simulation
    click ML_Engine "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_matlab"
    click ML_Message "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_matlab/message_types/"
    click ML_Parameters "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_matlab/parameters/"
    click ML_Tools "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_matlab/tools/"

    %% Click Events for Simulink Models
    click SL_Engine "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_simulink"
    click SL_Models "https://github.com/aravindustries/mavsim_public3/blob/main/mavsim_simulink/chap6/mavsim_chap6.slx"
    click SL_Tools "https://github.com/aravindustries/mavsim_public3/tree/main/mavsim_simulink/tools/"

    %% Style Definitions
    classDef legacy_engine fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef current_engine fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef matlab_engine fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef simulink_engine fill:#FFB6C1,stroke:#000,stroke-width:2px;
```
