# unitree-go2-robot/go2_robot architecture

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

- Interactive diagram: https://gitdiagram.com/unitree-go2-robot/go2_robot
- Repository: https://github.com/unitree-go2-robot/go2_robot

## Overview

##### Project type and purpose
- This is a ROS 2 “bringup” integration package for the Unitree GO2 quadruped robot. It provides the robot description, sensor drivers (LiDAR, RealSense), control interfaces (cmd_vel, go2_interfaces services), visualization in RViz, SLAM and Nav2 stubs, and mode/configuration services.

##### File structure
- Top-level CMakeLists.txt & package.xml define a standard ROS 2 package built with colcon/CMake.
- dependencies.repos lists third-party ROS 2 driver repositories (e.g., Hesai Lidar ROS 2, realsense2_camera).
- .github contains CI workflows (build/test on ROS 2 Humble).
- README.md documents installation, sensor setup, launch files, topics, and services.
- (Not shown but assumed) src/ contains ROS 2 node implementations and config/ contains YAML for sensor parameters.

##### README for additional insights
- Main launch: go2_bringup/go2.launch.py brings up robot_description, sensor drivers, joint_state_publisher, and optionally RViz.
- Topics published:
- /joint_states (robot joint angles)
- /odom (odometry)
- /cmd_vel (Twist messages from controllers or teleop)
- Services provided by go2_interfaces: /mode, /body_height, /continuous_gait, etc.
- Future work: SLAM & Nav2 integration.

##### Capturing essential architectural elements
- ROS 2 nodes in the go2_robot package (bringup, interfaces).
-Inter-node topic and service connectivity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Layer
    subgraph "Hardware Layer"
        direction TB
        GO2["GO2 Robot Base"]:::hardware
        LiDAR["Hesai LiDAR Sensor"]:::hardware
        RS["RealSense D435i Camera"]:::hardware
    end

    %% ROS 2 Middleware Layer
    subgraph "ROS 2 Middleware"
        direction TB

        subgraph Sensing
            direction TB
            HesaiNode["hesai_lidar_node"]:::sensor
            RSNode["realsense_node"]:::sensor
        end

        subgraph StateEst
            direction TB
            RSPub["robot_state_publisher"]:::state
            URDF["go2_description (URDF/Xacro)"]:::state
        end

        subgraph Control
            direction TB
            CmdVelIface["/cmd_vel Interface"]:::state
            Bringup["go2_bringup Node"]:::state
        end

        subgraph Interfaces
            direction TB
            ModeSvc["/mode Service"]:::state
            BodyHeightSvc["/body_height Service"]:::state
            GaitSvc["/continuous_gait Service"]:::state
            InterfacesNode["go2_interfaces Nodes"]:::state
        end

        subgraph Autonomy
            direction TB
            SLAM["slam_toolbox (Placeholder)"]:::autonomy
            Nav2["Nav2 Stack (Placeholder)"]:::autonomy
        end

        %% Topics and Services as data stores
        LidarPoints[(/lidar_points)]:::topic
        CamPoints[(/camera/depth/color/points)]:::topic
        JointStates[(/joint_states)]:::topic
        Odom[(/odom)]:::topic
        Map[(/map)]:::topic
        CmdVelTopic[(/cmd_vel)]:::topic
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        RViz["RViz Visualization"]:::ui
        CLI["ros2 CLI / Custom UIs"]:::ui
    end

    %% Repo Files Layer
    subgraph "Repository Files"
        direction TB
        CMake["CMakeLists.txt"]:::doc
        PackageXML["package.xml"]:::doc
        Deps["dependencies.repos"]:::doc
        CI1[".github/workflows/humble.yaml"]:::doc
        CI2[".github/workflows/humble_devel.yaml"]:::doc
        Contrib["CONTRIBUTING.md"]:::doc
        Readme["README.md"]:::doc
        Issues[".github/ISSUE_TEMPLATE/"]:::doc
        PRTemplate[".github/pull_request_template.md"]:::doc
        License["LICENSE"]:::doc
    end

    %% Connections: Hardware to Middleware
    LiDAR -->|"/lidar_packets"| HesaiNode
    RS -->|"/camera/depth/color/points raw"| RSNode

    %% Sensors to topics
    HesaiNode -->|publishes| LidarPoints
    RSNode -->|publishes| CamPoints

    %% State Estimation
    GO2 -->|joint states| RSPub
    URDF -->|model| RSPub
    RSPub -->|publishes| JointStates

    %% Odometry flow (assumed from base)
    GO2 -->|odometry| Odom

    %% Autonomy subscriptions
    SLAM -->|subscribes to| LidarPoints
    SLAM -->|subscribes to| CamPoints
    SLAM -->|publishes| Map
    Nav2 -->|subscribes to| Map
    Nav2 -->|publishes| CmdVelTopic

    %% Control flow
    CmdVelTopic -->|subscribes| CmdVelIface
    CmdVelIface -->|commands| Bringup
    Bringup -->|motor commands| GO2

    %% Interfaces Services
    InterfacesNode -->|offers| ModeSvc
    InterfacesNode -->|offers| BodyHeightSvc
    InterfacesNode -->|offers| GaitSvc
    ModeSvc -->|calls| Bringup
    BodyHeightSvc -->|calls| Bringup
    GaitSvc -->|calls| Bringup

    %% Application subscriptions
    RViz -->|subscribes| JointStates
    RViz -->|subscribes| Map
    RViz -->|subscribes| LidarPoints
    RViz -->|subscribes| CamPoints
    RViz -->|subscribes| Odom

    CLI -->|uses| ModeSvc
    CLI -->|uses| BodyHeightSvc
    CLI -->|uses| GaitSvc

    %% Click Events
    click CMake "https://github.com/unitree-go2-robot/go2_robot/blob/humble/CMakeLists.txt"
    click PackageXML "https://github.com/unitree-go2-robot/go2_robot/blob/humble/package.xml"
    click Deps "https://github.com/unitree-go2-robot/go2_robot/blob/humble/dependencies.repos"
    click CI1 "https://github.com/unitree-go2-robot/go2_robot/blob/humble/.github/workflows/humble.yaml"
    click CI2 "https://github.com/unitree-go2-robot/go2_robot/blob/humble/.github/workflows/humble_devel.yaml"
    click Contrib "https://github.com/unitree-go2-robot/go2_robot/blob/humble/CONTRIBUTING.md"
    click Readme "https://github.com/unitree-go2-robot/go2_robot/blob/humble/README.md"
    click Issues "https://github.com/unitree-go2-robot/go2_robot/tree/humble/.github/ISSUE_TEMPLATE/"
    click PRTemplate "https://github.com/unitree-go2-robot/go2_robot/blob/humble/.github/pull_request_template.md"
    click License "https://github.com/unitree-go2-robot/go2_robot/tree/humble/LICENSE"

    %% Styles
    classDef hardware fill:#FDE68A,stroke:#DAA520,stroke-width:1px
    classDef sensor fill:#BFDBFE,stroke:#0C4A6E,stroke-width:1px
    classDef state fill:#BBF7D0,stroke:#047857,stroke-width:1px
    classDef autonomy fill:#FED7AA,stroke:#C2410C,stroke-width:1px
    classDef ui fill:#E9D5FF,stroke:#6B21A8,stroke-width:1px
    classDef topic fill:#F3F4F6,stroke:#374151,stroke-width:1px,shape: cylinder
    classDef doc fill:#E5E7EB,stroke:#6B7280,stroke-width:1px,stroke-dasharray: 5 5
```
