# flynneva/godot_ros architecture

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

- Interactive diagram: https://gitdiagram.com/flynneva/godot_ros
- Repository: https://github.com/flynneva/godot_ros

## Overview

##### Project type and purpose
- This is a C++ GDExtension plugin (“godot_ros”) whose purpose is to bridge the Godot game engine and ROS 2. It hooks into Godot’s MainLoop/SceneTree lifecycle, initializes a ROS 2 context, and lets Godot nodes act as ROS 2 nodes with publishers/subscribers and data‐type conversions.

##### File structure
- Top level
- SConstruct – build script for compiling the extension
- requirements.txt – Python deps (used by CI or build tooling)
- .github/workflows/build_test.yml – CI build/test pipeline
- /godot_ros
- node.hpp, scene_tree.hpp, register_types.hpp – C++ headers defining the extension’s core classes and registration hooks
- image.tpp, string.tpp, etc. – template implementations for converting Godot types to ROS messages
- src/
- scene_tree.cpp – overrides Godot’s SceneTree initialization/finalization to call rclcpp::init()/shutdown()
- node.cpp – wraps rclcpp::Node inside Godot::Node derivatives
- register_types.cpp – binds the new types to Godot via GDExtension registration
- demo/
- godot_ros.gdextension – GDExtension manifest listing the compiled library and its ROS dependencies
- *.gd, *.tscn, project.godot – example Godot project and scripts showcasing how to publish/subscribe

##### Key insights from the README
- Core concept: intercept SceneTree lifecycle, run ROS 2 init/shutdown
- Every Godot node can become a ROS 2 node by embedding a shared_ptr<rclcpp::Node>
- Type conversions between Godot types (String, Image, Array) and ROS messages (std_msgs::msg::String, sensor_msgs::msg::Image, PointCloud)
- Build process driven by SCons, CI workflow shows dependencies and platform targets

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Godot Engine Layer"
        GE["Godot Engine"]:::engine
    end

    subgraph "godot_ros Plugin (Extension Layer)"
        GExt["GDExtension Loader"]:::extension
        ST["SceneTree Extension"]:::extension
        NW["Node Wrapper"]:::extension
        RH["Registration Hook"]:::extension
    end

    subgraph "Conversion Library"
        TC1["String Converter"]:::conversion
        TC2["Image Converter"]:::conversion
        TC3["Other Converters"]:::conversion
    end

    subgraph "ROS 2 Middleware"
        RCLCPP["rclcpp (Client Lib)"]:::middleware
        ROSGraph["ROS Graph"]:::middleware
        DDS["DDS Transport (DDS)"]:::middleware
    end

    subgraph "Demo Project"
        TDG["talker.gd"]:::demo
        VDG["view.gd"]:::demo
        TSCN["talker.tscn"]:::demo
        PJT["project.godot"]:::demo
        GDEXT["godot_ros.gdextension"]:::demo
    end

    subgraph "Build & CI"
        SC["SConstruct"]:::build
        CI[".github/workflows/build_test.yml"]:::build
        REQ["requirements.txt"]:::build
        DOCS["README.md\nLICENSE\nCONTRIBUTING.md\n.gitignore"]:::build
    end

    %% Relationships
    GE -->|loads| GExt
    GExt -->|hooks into| ST
    GExt -->|registers| RH
    ST -->|init/shutdown| RCLCPP
    ST -->|dispatch frames| NW
    NW -->|publishes/subscribes| RCLCPP
    NW -->|uses| TC1
    NW -->|uses| TC2
    NW -->|uses| TC3
    TC1 -->|converts| RCLCPP
    TC2 -->|converts| RCLCPP
    RCLCPP -->|manages| ROSGraph
    ROSGraph -->|over| DDS
    TDG -->|calls| NW
    VDG -->|calls| NW
    TDG -->|scene| ST
    VDG -->|scene| ST
    PJT -->|loads| GDEXT

    SC -->|builds| GExt
    REQ -->|deps| SC
    CI -->|runs| SC
    DOCS --- SC

    %% Click Events
    click GExt "https://github.com/flynneva/godot_ros/blob/main/demo/bin/godot_ros.gdextension"
    click SC "https://github.com/flynneva/godot_ros/tree/main/SConstruct"
    click CI "https://github.com/flynneva/godot_ros/blob/main/.github/workflows/build_test.yml"
    click REQ "https://github.com/flynneva/godot_ros/blob/main/requirements.txt"
    click ST "https://github.com/flynneva/godot_ros/blob/main/include/godot_ros/scene_tree.hpp"
    click ST "https://github.com/flynneva/godot_ros/blob/main/src/scene_tree.cpp"
    click NW "https://github.com/flynneva/godot_ros/blob/main/include/godot_ros/node.hpp"
    click NW "https://github.com/flynneva/godot_ros/blob/main/src/node.cpp"
    click TC1 "https://github.com/flynneva/godot_ros/blob/main/include/godot_ros/string.tpp"
    click TC2 "https://github.com/flynneva/godot_ros/blob/main/include/godot_ros/image.tpp"
    click RH "https://github.com/flynneva/godot_ros/blob/main/include/godot_ros/register_types.hpp"
    click RH "https://github.com/flynneva/godot_ros/blob/main/src/register_types.cpp"
    click TDG "https://github.com/flynneva/godot_ros/blob/main/demo/talker.gd"
    click VDG "https://github.com/flynneva/godot_ros/blob/main/demo/view.gd"
    click TSCN "https://github.com/flynneva/godot_ros/blob/main/demo/talker.tscn"
    click PJT "https://github.com/flynneva/godot_ros/blob/main/demo/project.godot"

    %% Styles
    classDef engine fill:#ccffcc,stroke:#333
    classDef extension fill:#cce5ff,stroke:#333
    classDef conversion fill:#e5ccff,stroke:#333
    classDef middleware fill:#ffd699,stroke:#333
    classDef demo fill:#ffeecc,stroke:#333
    classDef build fill:#f2f2f2,stroke:#333,stroke-dasharray: 2 2
```
