# tsrour/aionr6-mpc-ros architecture

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

- Interactive diagram: https://gitdiagram.com/tsrour/aionr6-mpc-ros
- Repository: https://github.com/tsrour/aionr6-mpc-ros

## Overview

##### Project type and purpose
- This is a ROS (Robot Operating System)-based simulation and control system for autonomous race cars.
- It implements an optimization-based (MPC) controller, a Gazebo simulation environment, custom messages/services, and a plotting toolchain.

##### File structure
- Top-level: CMakeLists.txt, README.md, and six catkin packages:
- ltvcmpc_controller – the MPC controller node (C++/Python, launch files in launch/).
- ltvcmpc_gazebo_env – Gazebo world, robot model, and launch file.
- ltvcmpc_impl_env – ROS plugins, configuration for the rover implementation.
- ltvcmpc_msgs – custom ROS messages (Constraints, Params, Weights) and services (GetTrack, InitPosition).
- ltvcmpc_plotter – Python plotting scripts and output folders.
- ltvcmpc_services – Python service nodes that serve path-planning data files.
- Each package has its own CMakeLists.txt and package.xml (standard catkin layout).
- Launch directories hold .launch and .yaml configuration files.
- scripts/ folders contain Python nodes and utilities (interpolation, plotting, service servers).

##### README
- Describes the purpose: simulate an Aion R6 Rover with MPC controller in Gazebo, run mpcc_controller_sim, log and plot results.
- Lists dependencies: Ubuntu 16.04, ROS Kinetic, MAVROS, Python libs (rospkg, pyyaml, matplotlib, osqp).
- Provides high-level run steps.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Master
    ROSMaster["ROS Master"]:::master

    %% Simulation Subsystem
    subgraph "Simulation" 
        GazeboLaunch["rover_gazebo.launch"]:::sim
        GazeboWorld["aionr1.world"]:::sim
        GazeboModel["rover_racetrack/model.sdf"]:::sim
        ImplLaunch["rover_implementation.launch"]:::sim
        ConfigYAML["rover_config.yaml"]:::sim
        PluginList["rover_pluginlists.yaml"]:::sim
        GetStates["get_states"]:::sim
    end

    %% Controller Subsystem
    subgraph "MPC Controller" 
        MPCCNode["mpcc_control_node"]:::ctrl
        LTVNode["ltv_contouring_mpc.py"]:::ctrl
        Interp["interpolate.py"]:::ctrl
        LaunchSim["mpcc_controller_sim.launch"]:::ctrl
        LaunchImpl["mpcc_controller_impl.launch"]:::ctrl
    end

    %% Messages & Services Types
    subgraph "Custom Msgs/Srvs" 
        Constraints["Constraints.msg"]:::msg
        ParamsMsg["Params.msg"]:::msg
        Weights["Weights.msg"]:::msg
        GetTrackSrv["GetTrack.srv"]:::msg
        InitPosSrv["InitPosition.srv"]:::msg
    end

    %% Service Servers
    subgraph "Path-Planning Services"
        TrackServer["track_server"]:::svc
        InitServer["init_poisition_server"]:::svc
        DataMAT["*.mat"]:::svc
    end

    %% Plotting
    subgraph "Plotter"
        DataPlotter["data_plotter"]:::plot
        ParamsFile["ltvcmpc_params.txt"]:::plot
    end

    %% Data Flows
    GazeboLaunch -->|"/odom,/joint_states"| MPCCNode
    MPCCNode -->|"/cmd_vel"| GazeboLaunch

    %% Service Calls
    MPCCNode -.->|GetTrack| TrackServer
    MPCCNode -.->|InitPosition| InitServer

    %% Plotting Flow
    MPCCNode -->|logs/params| DataPlotter

    %% Dependencies
    MPCCNode -->|uses OSQP solver| LTVNode
    MPCCNode -->|uses MAVROS| LaunchSim

    %% Click Events
    click GazeboLaunch "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_gazebo_env/launch/rover_gazebo.launch"
    click GazeboWorld "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_gazebo_env/worlds/aionr1.world"
    click GazeboModel "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_gazebo_env/models/rover_racetrack/model.sdf"
    click ImplLaunch "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_impl_env/launch/rover_implementation.launch"
    click ConfigYAML "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_impl_env/launch/rover_config.yaml"
    click PluginList "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_impl_env/launch/rover_pluginlists.yaml"
    click GetStates "https://github.com/tsrour/aionr6-mpc-ros/tree/master/ltvcmpc_impl_env/scripts/get_states"
    click MPCCNode "https://github.com/tsrour/aionr6-mpc-ros/tree/master/ltvcmpc_controller/scripts/mpcc_control_node"
    click LTVNode "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_controller/scripts/ltv_contouring_mpc.py"
    click Interp "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_controller/scripts/interpolate.py"
    click LaunchSim "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_controller/launch/mpcc_controller_sim.launch"
    click LaunchImpl "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_controller/launch/mpcc_controller_impl.launch"
    click Constraints "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_msgs/msg/Constraints.msg"
    click ParamsMsg "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_msgs/msg/Params.msg"
    click Weights "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_msgs/msg/Weights.msg"
    click GetTrackSrv "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_msgs/srv/GetTrack.srv"
    click InitPosSrv "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_msgs/srv/InitPosition.srv"
    click TrackServer "https://github.com/tsrour/aionr6-mpc-ros/tree/master/ltvcmpc_services/scripts/track_server"
    click InitServer "https://github.com/tsrour/aionr6-mpc-ros/tree/master/ltvcmpc_services/scripts/init_poisition_server"
    click DataMAT "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_services/scripts/data/*.mat"
    click DataPlotter "https://github.com/tsrour/aionr6-mpc-ros/tree/master/ltvcmpc_plotter/scripts/data_plotter"
    click ParamsFile "https://github.com/tsrour/aionr6-mpc-ros/blob/master/ltvcmpc_plotter/plots/simulation/*/ltvcmpc_params.txt"

    %% Styles
    classDef sim fill:#cce5ff,stroke:#2196F3,color:#000;
    classDef ctrl fill:#d4edda,stroke:#4CAF50,color:#000;
    classDef svc fill:#fff3cd,stroke:#FF9800,color:#000;
    classDef msg fill:#f8d7da,stroke:#F44336,color:#000;
    classDef plot fill:#e1bee7,stroke:#9C27B0,color:#000;
    classDef master fill:#e0e0e0,stroke:#9E9E9E,color:#000;
```
