# gingineer95/multi-robot-exploration-and-map-merging architecture

> Architecture diagram of the GitHub repository gingineer95/multi-robot-exploration-and-map-merging, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gingineer95/multi-robot-exploration-and-map-merging
- Repository: https://github.com/gingineer95/multi-robot-exploration-and-map-merging

## Overview

##### Project Type & Purpose
- A ROS-based multi-robot exploration and map‐merging package written in C++/XML/YAML.
- Enables two (or more) Turtlebot3 robots to autonomously explore an environment (Gazebo or real world), build individual occupancy grids via slam_toolbox, then merge them into a single global map using map_expansion + multirobot_map_merge.

##### Top-Level Components
- ROS Master: central orchestrator.
- Gazebo Simulation:
- bookstore.world (worlds/)
- Robot definitions (urdf/tb3_0*.xacro, tb3_1*.xacro)
- ROS Nodes (src/):
- frontier_exploration: single_tb_FE, tb3_0_FE, tb3_1_FE (frontier goal generation & cmd_vel)
- map_expansion: aligns and pads individual maps
- multirobot_map_merge (external package, modified)
- slam_toolbox (external)
- Config (config/): global/local costmap YAMLs, mapper_params, RViz configs
- Launch Files (launch/): robot spawn, simulation setups, SLAM, exploration, merging
- Services (srv/): /tb3_0_start, /tb3_1_start for triggering exploration

##### Relationships & Data Flow
- Gazebo → (sensor data) → frontier_exploration & slam_toolbox
- slam_toolbox → publishes → /tb3_i/map
- frontier_exploration → waits on → /tb3_i_start service → publishes → /tb3_i/cmd_vel → Gazebo
- map_expansion node → subscribes → /tb3_i/map → publishes → expanded map topics
- multirobot_map_merge → subscribes → expanded map topics → publishes → /map (merged)
- RViz → visualizes → /tb3_0/map, /tb3_1/map, /map

##### Architectural Patterns & Principles
- Publish/Subscribe: decoupling via ROS topics
- Service invocation: synchronized start commands
- Namespaces for modular multi-robot support
- Configuration-driven via YAML for costmaps & SLAM parameters
- Launch orchestration for swapping between simulation and real hardware
- Pipeline design: SLAM → map expansion → map merging

- sensor → SLAM → /tb3_i/map → map_expansion → expanded_map_i
- expanded_map_i → multirobot_map_merge → /map
- frontier_exploration → /cmd_vel → Gazebo
c. Service calls: frontier_exploration client → /tb3_i_start server.
e. URDF/XACRO processing feeding Gazebo spawn.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Launch Orchestration
    subgraph "Launch Orchestration"
        LAUNCH1["spawn_robots.launch"]:::doc
        LAUNCH2["two_tb_exploration.launch"]:::doc
        LAUNCH3["single_tb_FE.launch"]:::doc
        LAUNCH4["tb3_0.launch"]:::doc
        LAUNCH5["tb3_1.launch"]:::doc
        LAUNCH6["modified_move_base.launch"]:::doc
    end

    %% Gazebo Simulation
    subgraph "Gazebo Simulation"
        URDF0["tb3_0.gazebo.xacro"]:::urdf
        URDF1["tb3_1.gazebo.xacro"]:::urdf
        URDF2["tb3_0.urdf.xacro"]:::urdf
        URDF3["tb3_1.urdf.xacro"]:::urdf
        WORLD["bookstore.world"]:::doc
        Gazebo("Gazebo"):::cloud
        URDF0 --> Gazebo
        URDF1 --> Gazebo
        URDF2 --> Gazebo
        URDF3 --> Gazebo
        WORLD --> Gazebo
    end

    LAUNCH1 --> Gazebo
    LAUNCH2 --> Gazebo

    %% Namespace tb3_0
    subgraph "Namespace tb3_0" 
        FE0["tb3_0_FE"]:::nodeBlue
        SLAM0["slam_toolbox"]:::nodeBlue
        S0["/tb3_0_start"]:::serv
        MAP0["/tb3_0/map"]:::cyl
        CMD0["/tb3_0/cmd_vel"]:::cyl
    end

    Gazebo -->|"sensor data"| FE0
    Gazebo -->|"sensor data"| SLAM0
    FE0 -->|"request"| S0
    S0 -.->|"response"| FE0
    SLAM0 -->|"publishes"| MAP0
    FE0 -->|"publishes"| CMD0
    CMD0 --> Gazebo

    %% Namespace tb3_1
    subgraph "Namespace tb3_1"
        FE1["tb3_1_FE"]:::nodeGreen
        SLAM1["slam_toolbox"]:::nodeGreen
        S1["/tb3_1_start"]:::serv
        MAP1["/tb3_1/map"]:::cyl
        CMD1["/tb3_1/cmd_vel"]:::cyl
    end

    Gazebo -->|"sensor data"| FE1
    Gazebo -->|"sensor data"| SLAM1
    FE1 -->|"request"| S1
    S1 -.->|"response"| FE1
    SLAM1 -->|"publishes"| MAP1
    FE1 -->|"publishes"| CMD1
    CMD1 --> Gazebo

    %% Map Expansion
    subgraph "Map Expansion" 
        EXP0["map_expansion (tb3_0)"]:::purple
        EXP1["map_expansion (tb3_1)"]:::purple
        OUT0["/expanded_map_0"]:::cyl
        OUT1["/expanded_map_1"]:::cyl
    end

    MAP0 -->|"subscribes"| EXP0
    EXP0 -->|"publishes"| OUT0
    MAP1 -->|"subscribes"| EXP1
    EXP1 -->|"publishes"| OUT1

    %% Merge Pipeline
    subgraph "Merge Pipeline"
        MERGE["multirobot_map_merge"]:::purple
        MAP["/map"]:::cyl
    end

    OUT0 --> MERGE
    OUT1 --> MERGE
    MERGE -->|"publishes"| MAP

    %% Visualization
    RViz("RViz"):::cloud
    MAP0 --> RViz
    MAP1 --> RViz
    MAP --> RViz

    %% Configuration Files
    subgraph "Configuration"
        C1["global_costmap_params_tb3_0.yaml"]:::doc
        C2["global_costmap_params_tb3_1.yaml"]:::doc
        C3["local_costmap_params_tb3_0.yaml"]:::doc
        C4["local_costmap_params_tb3_1.yaml"]:::doc
        C5["mapper_params_online_sync.yaml"]:::doc
        C6["single_tb_FE.rviz"]:::doc
        C7["two_tb.rviz"]:::doc
    end

    C1 --> FE0
    C3 --> FE0
    C2 --> FE1
    C4 --> FE1
    C5 --> SLAM0
    C5 --> SLAM1
    C6 --> RViz
    C7 --> RViz

    %% Click Events
    click WORLD "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/worlds/bookstore.world"
    click URDF0 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/urdf/tb3_0.gazebo.xacro"
    click URDF1 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/urdf/tb3_1.gazebo.xacro"
    click URDF2 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/urdf/tb3_0.urdf.xacro"
    click URDF3 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/urdf/tb3_1.urdf.xacro"
    click FE0 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/src/tb3_0_FE.cpp"
    click FE1 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/src/tb3_1_FE.cpp"
    click S0 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/srv/tb3_0_start.srv"
    click S1 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/srv/tb3_1_start.srv"
    click EXP0 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/src/map_expansion.cpp"
    click LAUNCH6 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/launch/multi_robot_map_merge.launch"
    click LAUNCH7 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/launch/slam_online_synch.launch"
    click C1 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/config/global_costmap_params_tb3_0.yaml"
    click C2 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/config/global_costmap_params_tb3_1.yaml"
    click C3 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/config/local_costmap_params_tb3_0.yaml"
    click C4 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/config/local_costmap_params_tb3_1.yaml"
    click C5 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/config/mapper_params_online_sync.yaml"
    click C6 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/config/single_tb_FE.rviz"
    click C7 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/config/two_tb.rviz"
    click LAUNCH1 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/launch/spawn_robots.launch"
    click LAUNCH2 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/launch/two_tb_exploration.launch"
    click LAUNCH3 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/launch/single_tb_FE.launch"
    click LAUNCH4 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/launch/tb3_0.launch"
    click LAUNCH5 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/launch/tb3_1.launch"
    click LAUNCH6 "https://github.com/gingineer95/multi-robot-exploration-and-map-merging/blob/main/launch/modified_move_base.launch"

    %% Styles
    classDef nodeBlue fill:#ADD8E6,stroke:#000;
    classDef nodeGreen fill:#90EE90,stroke:#000;
    classDef purple fill:#DDA0DD,stroke:#000;
    classDef cyl fill:#FFFACD,stroke:#000,shape:circle;
    classDef serv fill:#FFB6C1,stroke:#000,shape:circle;
    classDef doc fill:#F5F5F5,stroke:#000;
    classDef urdf fill:#FFE4E1,stroke:#000;
    classDef cloud fill:#E0E0E0,stroke:#000,shape:cloud;
```
