# doosanrobotics/doosan-robot architecture

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

- Interactive diagram: https://gitdiagram.com/doosanrobotics/doosan-robot
- Repository: https://github.com/doosanrobotics/doosan-robot

## Overview

##### Project Type & Purpose
- This is a ROS1‐Noetic multi‐package robotics framework for Doosan manipulators, combining real‐robot control, simulation (Gazebo), motion planning (MoveIt), and example/demo code.
- It’s structured as a catkin workspace with ROS packages for messages (`dsr_msgs`), low‐level control (`dsr_control` + `common`), simulation (`dsr_gazebo` + Docker‐based DRCF emulator), robot description (`dsr_description`), launch helpers (`dsr_launcher`), MoveIt configs, and examples (`dsr_example_py`).

##### File Structure Highlights
- Top‐level: `.devcontainer`, `CMakeLists.txt`, `README.md` – defines workspace-level config.
- `common`: C/C++ library + Python wrappers + DRCF emulator binaries & Docker setup.
- `dsr_msgs`: all custom ROS message & service definitions.
- `dsr_control`: ROS node implementing hardware interface (real or emulator) using `dsr_msgs`.
- `dsr_description`: URDF/XACRO robot models, meshes, and plugins for Gazebo.
- `dsr_gazebo`: Gazebo worlds and ROS‐control plugin, loads robot into sim.
- `moveit_config_*`: one package per robot model, providing SRDF, planning & controller YAMLs, MoveIt launch files.
- `dsr_launcher`: meta‐package with launch scripts tying all nodes together for single‐ or multi‐robot setups.
- `dsr_example_py`: Python demos showing how to call ROS services/topics.

##### Key README Insights
- Two operation modes: **virtual** (uses Docker‐based DRCF emulator) vs **real** (connects to physical robot over TCP).
- Typical launch flow:
- Start emulator (if virtual) → launch robot_description + Gazebo base → launch dsr_control node → (optionally) launch MoveIt (`move_group`) → open RViz.
- ROS namespace conventions for multi‐robot.

a. **ROS Master** (central coordination)
b. **drfc_emulator (Docker container)**
- Runs DRCF binary, exposes a TCP port (default 12345).
c. **dsr_control_node**
- Subscribes/publishes ROS topics (joint states, control commands)
- Connects via TCP to emulator or real controller (host/port)
- Uses `common` library for lower‐level comms
d. **dsr_description_node** (xacro/URDF loader)
- Publishes `robot_description` parameter & `tf` transforms
- Provides meshes & collision geometry to Gazebo and RViz
e. **gazebo_ros_control Plugin** (in `dsr_gazebo`)
- Bridges Gazebo joint updates ↔ ROS controller interfaces
- Loads robot model into simulation world
f. **MoveIt (move_group & PlanningScene)**
- Consumes `robot_description`/SRDF
- Issues trajectory commands to `dsr_control_node` via ROS controllers
g. **RViz**
- Visualizes `tf`, joint states, MoveIt planning & execution
h. **dsr_msgs**
- Defines all message/service APIs between nodes
i. **dsr_launcher**
- Composes the above components in launch files, manages namespaces, arguments
j. **dsr_example_py**
- User‐level demo scripts invoking ROS services/topics to drive the robot

##### Architectural Patterns & Design Principles
- **Modular ROS package structure**: separation of msgs, description, control, simulation, planning, examples.
- **Plugin architecture**: Gazebo plugins for robot control, xacro macros for reusable URDF components.
- **Client‐server over TCP**: dsr_control ↔ emulator/real controller.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core
    ROSMaster["ROS Master"]:::core

    %% Low-Level Layer
    subgraph "Low-Level" 
        direction TB
        subgraph "Emulator / Hardware" 
            direction TB
            DRFC64["DRCF64 (Docker Emulator)"]:::sim
            RunDRCF["run_drcf.sh"]:::sim
            InstallEmu["install_emulator.sh"]:::sim
        end
        subgraph "common lib" 
            direction TB
            DSR_Robot_CPP["dsr_robot.cpp"]:::control
            DSR_Serial_CPP["dsr_serial.cpp"]:::control
            DSR_Robot_H["dsr_robot.h"]:::control
            DSR_Serial_H["dsr_serial.h"]:::control
            DR_TCP_Client["DR_tcp_client.py"]:::control
            DR_TCP_Server["DR_tcp_server.py"]:::control
        end
        DSRCtrlNode["dsr_control_node"]:::control
    end

    %% Description & Simulation
    subgraph "Simulation" 
        direction TB
        subgraph "Description"
            direction TB
            URDF_Xacro["*.urdf.xacro"]:::desc
            URDF["*.urdf"]:::desc
            DescLaunch["dsr_description.launch"]:::desc
        end
        subgraph "Gazebo"
            direction TB
            GazeboPlugin["gazebo_ros_control_params.yaml"]:::sim
            GazeboLaunch["dsr_base.launch"]:::sim
        end
    end

    %% Planning & Visualization
    subgraph "High-Level" 
        direction TB
        subgraph "MoveIt Planning"
            direction TB
            MoveGroupLaunch["move_group.launch"]:::plan
            SRDF["a0509.srdf"]:::plan
        end
        subgraph "Visualization"
            direction TB
            RVizDesc["default.rviz (description)"]:::vis
            RVizLaunch["default.rviz (launcher)"]:::vis
        end
        subgraph "Examples"
            direction TB
            ExampleDemo["demo scripts"]:::example
            ExampleSimple["simple scripts"]:::example
            ExampleGripper["gripper scripts"]:::example
        end
    end

    %% Messaging and Orchestration
    DSRMsgs["dsr_msgs (msg/srv)"]:::msg
    DSRLauncher["dsr_launcher"]:::launch

    %% Connections
    ROSMaster -.->|ROS graph| DSRCtrlNode
    ROSMaster -.->|ROS graph| URDF_Xacro
    ROSMaster -.->|ROS graph| MoveGroupLaunch
    ROSMaster -.->|ROS graph| RVizDesc
    ROSMaster -.->|ROS graph| DSRMsgs
    ROSMaster -.->|ROS graph| DSRLauncher

    %% TCP link
    DRFC64 <-->|TCP| DSRCtrlNode
    RunDRCF --> DRFC64
    InstallEmu --> DRFC64

    %% Control uses common lib
    DSRCtrlNode -->|uses| DSR_Robot_CPP
    DSRCtrlNode -->|uses| DSR_Serial_CPP
    DSR_Robot_CPP -->|includes| DSR_Robot_H
    DSR_Serial_CPP -->|includes| DSR_Serial_H
    DSR_Robot_CPP --> DR_TCP_Client
    DSR_Robot_CPP --> DR_TCP_Server

    %% Simulation flows
    URDF_Xacro --> URDF
    URDF --> GazeboPlugin
    URDF --> DSRCtrlNode
    GazeboPlugin --> DSRCtrlNode
    GazeboLaunch --> GazeboPlugin

    %% Planning & execution
    MoveGroupLaunch -->|consumes SRDF| SRDF
    MoveGroupLaunch -->|sends trajectory| DSRCtrlNode
    DSRCtrlNode -->|publishes joint_states| RVizDesc
    DSRCtrlNode -->|publishes tf| RVizDesc

    %% Examples & Orchestration
    DSRLauncher --> DSRCtrlNode
    DSRLauncher --> URDF_Xacro
    DSRLauncher --> GazeboLaunch
    DSRLauncher --> MoveGroupLaunch
    DSRLauncher --> RVizLaunch
    ExampleDemo --> DSRCtrlNode
    ExampleSimple --> DSRCtrlNode
    ExampleGripper --> DSRCtrlNode

    %% Click Events
    click DRFC64 "https://github.com/doosanrobotics/doosan-robot/tree/main/common/bin/DRCF/DRCF64"
    click RunDRCF "https://github.com/doosanrobotics/doosan-robot/blob/main/common/bin/DRCF/run_drcf.sh"
    click InstallEmu "https://github.com/doosanrobotics/doosan-robot/blob/main/doosan_robot/install_emulator.sh"

    click DSR_Robot_CPP "https://github.com/doosanrobotics/doosan-robot/blob/main/common/src/dsr_robot.cpp"
    click DSR_Serial_CPP "https://github.com/doosanrobotics/doosan-robot/blob/main/common/src/dsr_serial.cpp"
    click DSR_Robot_H "https://github.com/doosanrobotics/doosan-robot/blob/main/common/include/dsr_robot.h"
    click DSR_Serial_H "https://github.com/doosanrobotics/doosan-robot/blob/main/common/include/dsr_serial.h"
    click DR_TCP_Client "https://github.com/doosanrobotics/doosan-robot/blob/main/common/imp/DR_tcp_client.py"
    click DR_TCP_Server "https://github.com/doosanrobotics/doosan-robot/blob/main/common/imp/DR_tcp_server.py"

    click DSRMsgs "https://github.com/doosanrobotics/doosan-robot/tree/main/dsr_msgs/msg"
    click DSRMsgs "https://github.com/doosanrobotics/doosan-robot/tree/main/dsr_msgs/srv"

    click DSRCtrlNode "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_control/src/dsr_control_node.cpp"
    click DSRCtrlNode "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_control/include/dsr_control/dsr_hw_interface.h"
    click DSRCtrlNode "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_control/launch/dsr_control.launch"

    click URDF_Xacro "https://github.com/doosanrobotics/doosan-robot/tree/main/dsr_description/xacro"
    click URDF "https://github.com/doosanrobotics/doosan-robot/tree/main/dsr_description/urdf"
    click DescLaunch "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_description/launch/dsr_description.launch"

    click GazeboPlugin "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_gazebo/config/gazebo_ros_control_params.yaml"
    click GazeboLaunch "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_gazebo/launch/dsr_base.launch"

    click MoveGroupLaunch "https://github.com/doosanrobotics/doosan-robot/blob/main/moveit_config_a0509/launch/move_group.launch"
    click SRDF "https://github.com/doosanrobotics/doosan-robot/blob/main/moveit_config_a0509/config/a0509.srdf"

    click RVizDesc "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_description/rviz/default.rviz"
    click RVizLaunch "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_launcher/rviz/default.rviz"

    click DSRLauncher "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_launcher/launch/single_robot.launch"
    click DSRLauncher "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_launcher/launch/dsr_moveit.launch"
    click DSRLauncher "https://github.com/doosanrobotics/doosan-robot/blob/main/dsr_launcher/scripts/dmodel.py"

    click ExampleDemo "https://github.com/doosanrobotics/doosan-robot/tree/main/dsr_example/py/scripts/demo"
    click ExampleSimple "https://github.com/doosanrobotics/doosan-robot/tree/main/dsr_example/py/scripts/simple"
    click ExampleGripper "https://github.com/doosanrobotics/doosan-robot/tree/main/dsr_example/py/scripts/gripper"

    %% Styles
    classDef sim fill:#cfe2f3,stroke:#036fa1,color:#036fa1
    classDef control fill:#d9ead3,stroke:#38761d,color:#38761d
    classDef plan fill:#fce5cd,stroke:#e69138,color:#e69138
    classDef vis fill:#fff2cc,stroke:#bf9000,color:#bf9000
    classDef example fill:#f4cccc,stroke:#cc0000,color:#cc0000
    classDef msg fill:#d9d9d9,stroke:#7f7f7f,color:#7f7f7f
    classDef launch fill:#fff2cc,stroke:#b59f00,color:#b59f00
    classDef desc fill:#ecebe4,stroke:#8a817c,color:#8a817c
    classDef core fill:#ffffff,stroke:#000000,color:#000000,stroke-width:2px
```
