# ifra-cranfield/ros2_robotsimulation architecture

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

- Interactive diagram: https://gitdiagram.com/ifra-cranfield/ros2_robotsimulation
- Repository: https://github.com/ifra-cranfield/ros2_robotsimulation

## Overview

##### Main Components Identification
- ROS2 Core Environment – Representing the ROS2 Foxy runtime and core communication (topics, parameters, services, actions).
- Robot Simulation Packages – These are grouped by robot manufacturer and type. For each robot (e.g., ABB IRB120, ABB IRB1200, ABB IRB6640, UR3, UR5, UR10, Fanuc CR35iA, Kuka LBRiiwa, Panda), you have two main subpackages:
– Gazebo simulation package (often labeled xxx_ros2_gazebo) which contains configuration files, launch scripts, meshes, URDF/XACRO files, and world files used to simulate the physical robot.
– MoveIt2 control package (often labeled xxx_ros2_moveit2) which contains configuration and launch files relating to planning, kinematics, controller integration, and visualization.
- ROS2 Action & Data Infrastructure:
– ros2_data: Contains custom message and action specification files.
– ros2_actions: Contains action servers (written in C++ and Python) that translate external commands into robot movements.
– ros2_execution: Orchestrates the sequencing of commands across different action servers using input program (TXT files) and provides a higher-level control logic.
– ros2_grasping: Provides additional functionality related to grasping (attaching/detaching objects, spawning them in simulation).
- Supporting Components:
– “include” directory contains shared code (e.g., an improved move_group_interface) which likely wraps or adapts MoveIt2 APIs to support multiple robots.

##### Relationships and Interactions
- At the Heart: The ROS2 core manages communication between nodes spread across all packages.
- Simulation and Control:
– Each robot-specific simulation package (Gazebo) runs a ROS2 node that simulates physics and robot dynamics.
– The corresponding MoveIt2 package provides planning and motion execution functionalities which communicate with the Gazebo nodes (often via ROS2 controllers and ros2_control interfaces).
- Action Execution Flow:
– The ros2_execution package acts as an orchestrator that reads a sequence of actions from an input file.
– It sends requests (commands) to the various action servers defined in ros2_actions.
– These action servers use the definitions from ros2_data to trigger robot motions.
– Feedback from robot movement, simulation state, and any grasping events (facilitated by ros2_grasping) are circulated back to the orchestration level.

##### Architectural Patterns and Design Principles
- Modularity: The entire repository is modular—each robot simulation is self-contained and follows a similar structure, easing expansion.
- Separation of Concerns:
– Simulation is separated from planning/control.
– Execution sequencing, action servers, and custom data definitions are neatly split into separate packages.
- Reusability: The enhanced move_group_interface (in include) implies an effort toward creating common utilities that work across different robot simulations.
- Consistency: All packages follow common naming and directory conventions, making the system scalable and maintainable.

##### Technologies, Frameworks, and Libraries
- ROS2 Foxy: The underlying middleware that connects all nodes.
- Gazebo: For realistic physics simulation.
- MoveIt2: For motion planning and manipulation control.
- ROS2 Control and Controllers: For managing low-level actuation.
- xacro/URDF: For robot model description.
- C++ and Python: For action servers (ros2_actions) and execution scripts (ros2_execution).

##### Essential Elements
- “ROS2 Core / Middleware”
- “Robot Simulation (Gazebo)” with subcomponents per robot type.
- “Robot Motion Control (MoveIt2)” per simulation package.
- “ROS2 Data Definitions (ros2_data)”
- “Action Servers (ros2_actions)”
- “Execution Sequencer (ros2_execution)”
- “Grasping Module (ros2_grasping)”
- “Shared Utilities (include)”
- Feedback loops from simulation back to execution.
- Control signals from MoveIt2 to ROS2 Control that interact with Gazebo nodes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Core["ROS2 Core / Middleware"]:::core

    subgraph "Robot Vendors"
        subgraph "ABB Robots"
            ABBIRB120G["IRB120 Gazebo"]:::sim
            ABBIRB120M["IRB120 MoveIt2"]:::control
            ABBIRB1200G["IRB1200 Gazebo"]:::sim
            ABBIRB1200M["IRB1200 MoveIt2"]:::control
            ABBIRB6640G["IRB6640 Gazebo"]:::sim
            ABBIRB6640M["IRB6640 MoveIt2"]:::control
        end

        subgraph "Fanuc Robots"
            FanucG["CR35iA Gazebo"]:::sim
            FanucM["CR35iA MoveIt2"]:::control
        end

        subgraph "Kuka Robots"
            KukaG["LBRiiwa Gazebo"]:::sim
            KukaM["LBRiiwa MoveIt2"]:::control
        end

        subgraph "Panda Robots"
            PandaG["Panda Gazebo"]:::sim
            PandaM["Panda MoveIt2"]:::control
        end

        subgraph "Universal Robots"
            UR10G["UR10 Gazebo"]:::sim
            UR10M["UR10 MoveIt2"]:::control
            UR3G["UR3 Gazebo"]:::sim
            UR3M["UR3 MoveIt2"]:::control
            UR5G["UR5 Gazebo"]:::sim
            UR5M["UR5 MoveIt2"]:::control
        end
    end

    subgraph "ROS2 Infrastructure"
        Data["ros2_data"]:::infra
        Actions["ros2_actions"]:::infra
        Execution["ros2_execution"]:::infra
        Grasping["ros2_grasping"]:::infra
    end

    %% Core communication to all components
    Core --> ABBIRB120G
    Core --> ABBIRB120M
    Core --> ABBIRB1200G
    Core --> ABBIRB1200M
    Core --> ABBIRB6640G
    Core --> ABBIRB6640M
    Core --> FanucG
    Core --> FanucM
    Core --> KukaG
    Core --> KukaM
    Core --> PandaG
    Core --> PandaM
    Core --> UR10G
    Core --> UR10M
    Core --> UR3G
    Core --> UR3M
    Core --> UR5G
    Core --> UR5M
    Core --> Data
    Core --> Actions
    Core --> Execution
    Core --> Grasping

    %% Execution flow from infrastructure to vendor control modules
    Execution -->|"triggers"| Actions
    Actions -->|"uses"| Data
    Actions -->|"commands"| ABBIRB120M
    Actions -->|"commands"| ABBIRB1200M
    Actions -->|"commands"| ABBIRB6640M
    Actions -->|"commands"| FanucM
    Actions -->|"commands"| KukaM
    Actions -->|"commands"| PandaM
    Actions -->|"commands"| UR10M
    Actions -->|"commands"| UR3M
    Actions -->|"commands"| UR5M

    %% Control modules sending commands to simulation nodes
    ABBIRB120M -->|"controls"| ABBIRB120G
    ABBIRB1200M -->|"controls"| ABBIRB1200G
    ABBIRB6640M -->|"controls"| ABBIRB6640G
    FanucM -->|"controls"| FanucG
    KukaM -->|"controls"| KukaG
    PandaM -->|"controls"| PandaG
    UR10M -->|"controls"| UR10G
    UR3M -->|"controls"| UR3G
    UR5M -->|"controls"| UR5G

    %% Simulation nodes provide feedback to execution sequencer
    ABBIRB120G -->|"feedback"| Execution
    ABBIRB1200G -->|"feedback"| Execution
    ABBIRB6640G -->|"feedback"| Execution
    FanucG -->|"feedback"| Execution
    KukaG -->|"feedback"| Execution
    PandaG -->|"feedback"| Execution
    UR10G -->|"feedback"| Execution
    UR3G -->|"feedback"| Execution
    UR5G -->|"feedback"| Execution

    %% Grasping module interacts with simulation nodes
    Grasping -->|"manages"| ABBIRB120G
    Grasping -->|"manages"| ABBIRB1200G
    Grasping -->|"manages"| ABBIRB6640G
    Grasping -->|"manages"| FanucG
    Grasping -->|"manages"| KukaG
    Grasping -->|"manages"| PandaG
    Grasping -->|"manages"| UR10G
    Grasping -->|"manages"| UR3G
    Grasping -->|"manages"| UR5G

    %% Click Events
    click Core "https://github.com/ifra-cranfield/ros2_robotsimulation/blob/foxy/include/move_group_interface_improved.h"
    click ABBIRB120G "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ABBRobots/IRB120/irb120_ros2_gazebo"
    click ABBIRB120M "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ABBRobots/IRB120/irb120_ros2_moveit2"
    click ABBIRB1200G "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ABBRobots/IRB1200/irb120_ros2_gazebo"
    click ABBIRB1200M "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ABBRobots/IRB1200/irb120_ros2_moveit2"
    click ABBIRB6640G "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ABBRobots/IRB6640/irb6640_ros2_gazebo"
    click ABBIRB6640M "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ABBRobots/IRB6640/irb6640_ros2_moveit2"
    click FanucG "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/Fanuc/CR35iA/cr35ia_ros2_gazebo"
    click FanucM "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/Fanuc/CR35iA/cr35ia_ros2_moveit2"
    click KukaG "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/Kuka/LBRiiwa/iiwa_ros2_gazebo"
    click KukaM "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/Kuka/LBRiiwa/iiwa_ros2_moveit2"
    click PandaG "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/PandaRobot/panda_ros2_gazebo"
    click PandaM "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/PandaRobot/panda_ros2_moveit2"
    click UR10G "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/UniversalRobots/UR10/ur10_ros2_gazebo"
    click UR10M "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/UniversalRobots/UR10/ur10_ros2_moveit2"
    click UR3G "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/UniversalRobots/UR3/ur3_ros2_gazebo"
    click UR3M "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/UniversalRobots/UR3/ur3_ros2_moveit2"
    click UR5G "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/UniversalRobots/UR5/ur5_ros2_gazebo"
    click UR5M "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/UniversalRobots/UR5/ur5_ros2_moveit2"
    click Data "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ros2_data"
    click Actions "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ros2_actions"
    click Execution "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ros2_execution"
    click Grasping "https://github.com/ifra-cranfield/ros2_robotsimulation/tree/foxy/ros2_grasping"

    %% Styles
    classDef core fill:#FFE0B2,stroke:#FB8C00,stroke-width:2px;
    classDef sim fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef control fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef infra fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
```
