# mogi-ros/week-1-2-introduction-to-ros2 architecture

> Architecture diagram of the GitHub repository mogi-ros/week-1-2-introduction-to-ros2, 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/mogi-ros/week-1-2-introduction-to-ros2
- Repository: https://github.com/mogi-ros/week-1-2-introduction-to-ros2

## Overview

- “bme_ros2_tutorials_py” – contains Python nodes such as simple “hello_world”, publishers (both procedural and OOP), subscribers (again both simple and OOP), and service client/server examples.
- “bme_ros2_tutorials_cpp” – contains C++ examples for publisher and subscriber nodes.
- “bme_ros2_tutorials_interfaces” – defines custom ROS2 service messages (e.g., CustomCalc.srv) to be used by the service examples.
- “bme_ros2_tutorials_bringup” – holds your launch files (written in Python) that bundle several nodes together with options such as topic remapping and parameter initialization.

##### Main Components
- ROS2 package as a separate module:
- A module for “bme_ros2_tutorials_py” that contains multiple Python nodes:
– “py_hello_world” (a basic node)
– “py_publisher” and “py_publisher_oop”
– “py_subscriber” and “py_subscriber_oop”
– “python_publisher_with_parameter” (illustrating dynamic parameter change)
– Service server and service client nodes.
- A module for “bme_ros2_tutorials_cpp” with nodes such as “publisher_cpp” and “subscriber_cpp.”
- A module for “bme_ros2_tutorials_interfaces” that defines custom service interfaces.
- A module for “bme_ros2_tutorials_bringup” which contains the launch files used to drive many nodes together, perform remappings, and set parameters.
- Optionally, show the “assets” folder representing documentation resources and example images like rqt_graph screenshots and turtlesim display images, which support visualization and demonstration of node connectivity.

##### Relationships and Interactions
- In the launch module, show that it orchestrates multiple nodes (both Python and C++) together and applies remapping (for example, remapping “topic” to “another_topic” in some cases). You might encapsulate the launch file “publisher_subscriber.launch.py” as a container that spawns these nodes.

##### Architectural Patterns and Design Principles
- Modularity: each package is self-contained and developed independently yet communicates via standard ROS2 topics and services.
- Point out the language agnostic design: C++ and Python nodes coexist and interact seamlessly through ROS2 topics and services.
- Use of launch files to encapsulate node startup, parameter assignment, and topic remapping—a key architectural pattern in larger robotics systems.

##### Technologies and Frameworks
- Optionally, include external tools such as rqt_graph, turtlesim, and terminal environments that are discussed in the README.

## Diagram (Mermaid)

```mermaid
graph TD
    %% ROS2 Middleware
    M["ROS2 Middleware (Jazzy)"]:::middleware

    %% Topic Node for Publisher/Subscriber Communication
    T["/topic(remapped:/another_topic)"]:::topic

    %% Parameter Settings Annotation
    P["Parameter Settings"]:::setting

    %% bme_ros2_tutorials_py Package Nodes
    subgraph "bme_ros2_tutorials_py"
        A1["py_hello_world"]:::python
        A2["py_publisher"]:::python
        A3["py_publisher_oop"]:::python
        A4["python_publisher_with_parameter"]:::python
        A5["py_subscriber"]:::python
        A6["py_subscriber_oop"]:::python
        A7["service_client"]:::python
        A8["service_server"]:::python
    end

    %% bme_ros2_tutorials_cpp Package Nodes
    subgraph "bme_ros2_tutorials_cpp"
        B1["cpp_publisher"]:::cpp
        B2["cpp_subscriber"]:::cpp
    end

    %% bme_ros2_tutorials_interfaces Package (Custom Service Interface)
    subgraph "bme_ros2_tutorials_interfaces"
        C1["CustomCalc"]:::interface
    end

    %% bme_ros2_tutorials_bringup Package (Launch Files)
    subgraph "bme_ros2_tutorials_bringup"
        D1["publisher_param.launch.py"]:::launch
        D2["publisher_subscriber.launch.py"]:::launch
    end

    %% Assets Package for Documentation and Visualizations
    subgraph "Assets"
        E1["Assets"]:::assets
    end

    %% Publishers -> Topic (Publish/Subscribe Flow)
    A2 -->|"publishes"| T
    A3 -->|"publishes"| T
    A4 -->|"publishes"| T
    B1 -->|"publishes"| T

    %% Topic -> Subscribers
    T -->|"subscribes"| A5
    T -->|"subscribes"| A6
    T -->|"subscribes"| B2

    %% Service Communication between Service Client and Server
    A7 <-->|"CustomCalc service"| A8
    A7 -->|"uses"| C1
    A8 -->|"implements"| C1

    %% Launch File Orchestration
    D2 -->|"launches"| A2
    D2 -->|"launches"| A3
    D2 -->|"launches"| A5
    D2 -->|"launches"| A6
    D2 -->|"launches"| B1
    D2 -->|"launches"| B2
    D2 -->|"launches"| A7
    D2 -->|"launches"| A8
    D1 -->|"launches"| A4

    %% Parameter Injection
    P -->|"configures"| A4

    %% Middleware Communication (for visual reference)
    M --- T
    M --- C1

    %% Click Events for bme_ros2_tutorials_py Nodes
    click A1 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_py/bme_ros2_tutorials_py/hello_world.py"
    click A2 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_py/bme_ros2_tutorials_py/publisher.py"
    click A3 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_py/bme_ros2_tutorials_py/publisher_oop.py"
    click A4 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_py/bme_ros2_tutorials_py/publisher_with_parameter.py"
    click A5 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_py/bme_ros2_tutorials_py/subscriber.py"
    click A6 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_py/bme_ros2_tutorials_py/subscriber_oop.py"
    click A7 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_py/bme_ros2_tutorials_py/service_client.py"
    click A8 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_py/bme_ros2_tutorials_py/service_server.py"

    %% Click Events for bme_ros2_tutorials_cpp Nodes
    click B1 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_cpp/src/publisher.cpp"
    click B2 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_cpp/src/subscriber.cpp"

    %% Click Event for bme_ros2_tutorials_interfaces
    click C1 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_interfaces/srv/CustomCalc.srv"

    %% Click Events for bme_ros2_tutorials_bringup Launch Files
    click D1 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_bringup/launch/publisher_param.launch.py"
    click D2 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/blob/main/bme_ros2_tutorials_bringup/launch/publisher_subscriber.launch.py"

    %% Click Event for Assets
    click E1 "https://github.com/mogi-ros/week-1-2-introduction-to-ros2/tree/main/assets"

    %% Styling
    classDef python fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef cpp fill:#ffa07a,stroke:#000,stroke-width:1px;
    classDef interface fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef launch fill:#f0e68c,stroke:#000,stroke-width:1px;
    classDef assets fill:#ffb6c1,stroke:#000,stroke-width:1px;
    classDef middleware fill:#d3d3d3,stroke:#000,stroke-width:1px;
    classDef topic fill:#e6e6fa,stroke:#000,stroke-width:1px;
    classDef setting fill:#f5deb3,stroke:#000,stroke-width:1px;
```
