# fzi-forschungszentrum-informatik/ros2_ros_bt_py architecture

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

- Interactive diagram: https://gitdiagram.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py
- Repository: https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py

## Overview

##### Project Type and Purpose
- This is a ROS2-based Behavior Tree library designed to serve as an alternative to other BT tools (like BehaviorTree.cpp, SMACH, FlexBE).
- Its purpose is to provide a plug‐and‐play framework for mission control and task orchestration in robotics, leveraging ROS actions, services, and a configurable node system. It even includes a ReactJS-based web GUI to build and edit behavior trees without coding.

##### File Structure
- The top-level file tree indicates a multi-package project:
– The "ros_bt_py" directory contains the core library.
– "ros_bt_py_interfaces" defines ROS messages, services, and actions that support the communication needs of the core library.
– "ros_bt_py_web_gui" provides the standalone graphical web interface.
- Inside the core library (ros_bt_py/ros_bt_py) you see modules like node.py, node_config.py, various helper modules, and a directory of nodes (both generic and ROS-specific in the "nodes" and "ros_nodes" folders) that together form the building blocks of the behavior tree framework.
- Additional directories like "launch", "doc", "tests", and configuration files (package.xml, setup.py/pyproject.toml) help build, document, and verify the system.
- Continuous integration configurations (GitHub workflows, GitLab CI) and a manifest (LICENSE, CONTRIBUTING) indicate the project is built with modern software best practices.

##### Specific Elements
- ROS Communications Layer (with nodes for actions, services, messages, and parameters, pointing out ros_bt_py_interfaces).
- Web Interface (showing the web server, web socket/rosbridge connection, and the front-end application).
- The flow from the Web GUI launch (at ros_bt_py_web_gui) to initiating a Behavior Tree execution (ros_bt_py).
- Service and topic interactions defined by ros_bt_py_interfaces which are used by the core library.
- Configuration inputs from launch files and YAML configuration (from the launch and config directories) that modify behavior at runtime.
- Annotations on architectural patterns such as modularity, plug-in extensibility, and clear separation between behavior logic and I/O.

##### Final Steps
- Which component handles the behavior tree logic.
- How the system interfaces with ROS.
- How the user interacts with the system via the web GUI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Backend Components
    subgraph "Backend Components"
        CBL["Core Behavior Tree Library"]:::backend
        RI["ROS Interface Definitions"]:::ros

        subgraph "Core Library Details"
            NODE["node.py"]:::backend
            NODECFG["node_config.py"]:::backend
            HELP["helpers.py"]:::backend
            DEBUG["debug_manager.py"]:::backend
            GNODES["Generic Nodes"]:::backend
            ROSNODES["ROS Nodes"]:::backend
        end
    end

    %% Configuration, Documentation & Testing
    subgraph "Configuration, Documentation & Testing"
        BLF["Backend Launch File"]:::config
        CFG["Configuration File"]:::config
        DOC["Documentation"]:::docs
        TEST["Testing"]:::test
        CI["CI Configurations"]:::test
    end

    %% Web GUI
    subgraph "Web GUI"
        WGL["Web GUI Launch File"]:::gui
        RWA["ReactJS Web Assets"]:::gui
    end

    %% Relationships
    %% Internal flow within Core Library
    NODECFG -->|"configures"| NODE
    NODE -->|"updates_state"| DEBUG

    %% Core Library interacts with ROS Interfaces
    CBL -->|"ROS_communication"| RI

    %% Configuration influences Core Library
    CFG -->|"configures"| CBL
    BLF -->|"launches"| CBL

    %% Web GUI initiates behavior tree execution via Core Library
    WGL -->|"initiates_BT_execution"| CBL

    %% Styling Connections (optional supportive links)
    DOC ---|"documents"| CBL
    TEST ---|"validates"| CBL
    CI ---|"monitors"| CBL

    %% Click Events for Core Behavior Tree Library
    click NODE "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/blob/main/ros_bt_py/ros_bt_py/node.py"
    click NODECFG "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/blob/main/ros_bt_py/ros_bt_py/node_config.py"
    click HELP "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/blob/main/ros_bt_py/ros_bt_py/helpers.py"
    click DEBUG "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/blob/main/ros_bt_py/ros_bt_py/debug_manager.py"
    click GNODES "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/tree/main/ros_bt_py/ros_bt_py/nodes"
    click ROSNODES "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/tree/main/ros_bt_py/ros_bt_py/ros_nodes"

    %% Click Events for ROS Interface Definitions
    click RI "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/tree/main/ros_bt_py_interfaces"

    %% Click Events for Web GUI
    click RWA "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/tree/main/ros_bt_py_web_gui/html"
    click WGL "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/blob/main/ros_bt_py_web_gui/launch/ros_bt_py_web_gui.launch.py"

    %% Click Events for Configuration Files
    click CFG "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/blob/main/ros_bt_py/config/tree_node_parameters.yaml"
    click BLF "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/blob/main/ros_bt_py/launch/ros_bt_py.launch.py"

    %% Click Events for Documentation and Testing/CI
    click DOC "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/tree/main/ros_bt_py/doc"
    click TEST "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/tree/main/ros_bt_py/tests"
    click CI "https://github.com/fzi-forschungszentrum-informatik/ros2_ros_bt_py/tree/main/.github/workflows"

    %% Styles
    classDef backend fill:#FFD700,stroke:#8B8000,stroke-width:2px,color:#000;
    classDef ros fill:#FF9999,stroke:#CC3333,stroke-width:2px,color:#000;
    classDef gui fill:#98FB98,stroke:#228B22,stroke-width:2px,color:#000;
    classDef config fill:#ADD8E6,stroke:#00008B,stroke-width:2px,color:#000;
    classDef docs fill:#FFFF99,stroke:#CCCC00,stroke-width:2px,color:#000;
    classDef test fill:#E0E0E0,stroke:#808080,stroke-width:2px,color:#000;
```
