# hanruihua/rda-planner architecture

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

- Interactive diagram: https://gitdiagram.com/hanruihua/rda-planner
- Repository: https://github.com/hanruihua/rda-planner

## Overview

##### Project type and purpose
- RDA Planner is an open-source, optimization-based Python library for MPC motion planning, not a web or full-stack app.
- Its goal is to compute collision-free trajectories in cluttered environments using ADMM-based decomposition for real-time performance.

##### File structure
- Top‐level package “RDA_planner/” contains core modules:
- mpc.py – defines the MPC formulation (prediction horizon, cost)
- rda_solver.py – implements the ADMM solver, subproblem decomposition
- setup.py – installation metadata
- example/ – scenario drivers, each with:
- A .py script invoking RDA_planner on a scenario (corridor, path_track, reverse, lidar_nav, dynamic_obs)
- Optional reference data (.npy) for path comparison
- No GUI; integration with ir-sim (external sim engine) and optional ROS wrapper.

##### README for additional insights
- Describes high-level workflow: load config → set up simulation → call RDA solver → output control sequence
- Highlights dependencies: Python ≥3.9, ir-sim for visualization, separate rda_ros package for ROS integration

a. Main components
1. Scenario Loader
– reads YAML, scenario scripts (example/*.py)
2. Simulation Interface
– ir-sim module or ROS wrapper (external)
3. RDA Planner Core
– MPC formulation (mpc.py)
– ADMM-based RDA solver (rda_solver.py)
4. Subproblem Modules
– Dynamics constraints
– Collision avoidance constraints (per obstacle, parallel)
5. Output Publisher
– Trajectory sequence → simulation or ROS topics
b. Relationships and data flow
- Scenario Loader → (config, initial state) → Simulation Interface → current state, obstacles → RDA Planner Core
- Planner Core → splits into subproblems → solves in parallel → aggregates updated trajectory
- Output Publisher → control commands → back to Simulation Interface or ROS
c. Architectural patterns
– Modular separation: I/O (scenario), core algorithm (MPC + solver), external interfaces
– Data-flow pipeline: config → state → solver → control
– Parallel subproblem execution (ADMM)
d. Key technologies and libraries
– Python 3.9+
– NumPy (for data arrays, .npy files)
– ir-sim (external sim engine)
– (Optional) ROS for real-robot interface via rda_ros

##### Final advice
- Every layer: from user scripts through solver internals to external interfaces

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "I/O & Examples"
        ScenarioLoader["Scenario Loader"]:::io
        Setup["setup.py"]:::io
        RefData(("Reference Data (.npy)")):::data
    end

    ScenarioLoader -->|"reads config & scripts"| YAML(("YAML Config (.yaml)")):::data
    ScenarioLoader --> Setup
    ScenarioLoader --> RefData

    YAML -->|"provides parameters"| Simulation
    ScenarioLoader --> Simulation

    Simulation["Simulation Interface<br/>(ir-sim)"]:::ext

    subgraph "RDA Planner Core"
        MPC["MPC Formulation"]:::core
        Solver["ADMM Solver & Subproblem Decomposition"]:::core
        MPC --> Solver

        subgraph "Subproblem Modules (parallel)"
            Dynamics["Dynamics Constraints"]:::core
            Collision["Collision Avoidance Constraints"]:::core
        end

        Solver --> Dynamics
        Solver --> Collision
        Dynamics --> Solver
        Collision --> Solver
    end

    Simulation -->|"current state & obstacles"| MPC
    Solver -->|"aggregates trajectories"| Output

    subgraph "Output Publisher"
        Output["Output Publisher"]:::io
    end

    Output --> Simulation
    Output --> ROS["ROS Wrapper"]:::ext

    classDef core fill:#bbdefb,stroke:#1e88e5;
    classDef io fill:#c8e6c9,stroke:#388e3c;
    classDef ext fill:#ffe0b2,stroke:#fb8c00;
    classDef data fill:#fff9c4,stroke:#fbc02d,stroke-width:2,shape:cylinder;

    click ScenarioLoader "https://github.com/hanruihua/rda-planner/tree/main/example/"
    click MPC "https://github.com/hanruihua/rda-planner/blob/main/RDA_planner/mpc.py"
    click Solver "https://github.com/hanruihua/rda-planner/blob/main/RDA_planner/rda_solver.py"
    click Setup "https://github.com/hanruihua/rda-planner/blob/main/setup.py"
    click RefData "https://github.com/hanruihua/rda-planner/tree/main/example/"
```
