# ingjae/xarm_ros architecture

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

- Interactive diagram: https://gitdiagram.com/ingjae/xarm_ros
- Repository: https://github.com/ingjae/xarm_ros

## Overview

##### Main areas of functionality
- Robot Descriptions & Models: Packages like “xarm_description” contain URDF files, mesh files, inertial parameters, and configuration for different robot models.
- Simulation: “xarm_gazebo” provides Gazebo worlds, launch files, and simulation support. It integrates physics simulation and additional models such as grippers and camera modules.
- Low-Level Control & Bringup: “xarm_controller” and “xarm_bringup” provide the hardware interfaces, driver launch files, configuration for controllers (position, joint trajectory, velocity), and bringup of the real robot through ROS services.
- Motion Planning & MoveIt Integration: “xarm7_moveit_config”, “xarm_planner”, “xarm_moveit_servo”, etc. offer MoveIt configuration for planning, visualization on RViz, and real-time servo control (including online replanning modes). These packages restrict joint ranges and support custom TCP/tool models.
- API & Service Wrappers: “xarm_api” together with “xarm_msgs” expose the underlying SDK functions as ROS services. They cover joint/cartoesian motions, velocity control, error handling, I/O operations, and even tool (gripper/vacuum) control.
- External Modules & Vision Integration: The “xarm_vision” package and associated examples integrate external modules such as RealSense D435i, hand–eye calibration, and grasping demos. This part supports both sensor data streams and vision-guided robot control.

##### Relationships and Interactions
- At the bottom level, the xArm’s hardware is interfaced and controlled by the “xarm_controller” and “xarm_bringup” packages. They communicate directly with the robot’s driver board via low-level controllers.
- The “xarm_description” package is the foundation for both simulation and real operations; its URDF defines the robot’s kinematic and collision properties which are consumed by MoveIt! and Gazebo.
- Simulation components (“xarm_gazebo”) interact with the real world environment in Gazebo and receive motion commands from planning nodes.
- Motion planning and control components (“xarm7_moveit_config”, “xarm_planner”, “xarm_moveit_servo”) serve as the high‐level interface between a user or autonomous planner (for example using MoveIt!’s planning interface) and the low-level commands sent via the API.
- The “xarm_api” and “xarm_msgs” packages are middleware that convert user‐or higher-level commands into the specific SDK calls that operate the hardware which are then invoked via ROS service calls.
- Additional modules like “xarm_gripper” and vision packages add specialized functionality (end effector control and sensor feedback) that cross-connect with the main control and planning loops.
- Data and state feedback flows from the robot via topics (for example, “xarm/xarm_states”, “joint_states”, “controller_gpio_states”) to monitor status and errors. The “report_type” argument in launches further customizes the feedback frequency and richness.

##### Architectural Patterns and Design Principles
- MODULARITY: The system is split into clear packages – each with a dedicated purpose (robot description, simulation, hardware interfacing, planning, API messaging). This promotes ease of maintenance and allows users to swap simulation with real hardware.
- LAYERING: There is a clear separation between low-level hardware control (bringup, controller packages), high-level motion planning (MoveIt configurations, planner packages), and additional functionalities (vision, gripper control).
- CLIENT-SERVER & SERVICE ORIENTATION: ROS services (e.g., for motion commands, error clearing, I/O operations) and topics for state feedback provide a decoupled communication mechanism.
- EXTENSIBILITY: With numerous configuration files, launch scripts, and submodules (e.g., for different models and moveit setups), the system is designed to support numerous robot variants and functionalities (including dual robot configurations).

##### Relevant Technologies, Frameworks, and Libraries
- ROS (Robot Operating System) is the primary middleware.
- MoveIt! for motion planning, kinematic computation, and collision checking.
- Gazebo for simulation.
- CMake and catkin for building and dependency management.
- Custom SDK (xarm_ros C++/Python SDK) abstracted through the xarm_api.
- Additional sensor integration with RealSense and vision libraries (like aruco_ros and easy_handeye).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Global ROS Master
    RM["ROS Master"]:::ros

    %% Hardware & Low-Level Interface Layer
    subgraph "Hardware & Low-Level Interface Layer"
        HC["xarm_controller"]:::hardware
        HB["xarm_bringup"]:::hardware
    end

    %% Robot Description & Simulation Layer
    subgraph "Robot Description & Simulation Layer"
        XD["xarm_description"]:::simulation
        XG["xarm_gazebo"]:::simulation
    end

    %% High-Level Planning & Control Layer
    subgraph "High-Level Planning & Control Layer"
        XC["xarm7_moveit_config"]:::planning
        XP["xarm_planner"]:::planning
        XS["xarm_moveit_servo"]:::planning
    end

    %% Middleware / API Layer
    subgraph "Middleware / API Layer"
        XA["xarm_api"]:::api
        XM["xarm_msgs"]:::api
    end

    %% Peripheral & Extension Layer
    subgraph "Peripheral & Extension Layer"
        XGri["xarm_gripper"]:::peripheral
        XV["xarm_vision"]:::peripheral
    end

    %% Connections between layers
    %% Robot description provides models to hardware and simulation
    XD -->|"defines_kinematics"| HC
    XD -->|"provides_model"| XG

    %% Hardware connection within low-level layer
    HC -->|"interfaces_with"| HB

    %% Planning pipeline connections
    XC -->|"configures"| XP
    XP -->|"sends_command"| XS

    %% Planning to Middleware connection via ROS Services
    XS -->|"via_ROS_Services"| XA

    %% Middleware interaction internally
    XA <-->|"service_calls"| XM

    %% Middleware commanding hardware interface
    XA -->|"executes_commands"| HB

    %% Peripheral modules integration from Middleware
    XA -->|"integrates_with"| XGri
    XA -->|"integrates_with"| XV

    %% ROS Master connections
    RM -->|"orchestrates"| XD
    RM -->|"orchestrates"| XG
    RM -->|"orchestrates"| HC
    RM -->|"orchestrates"| HB
    RM -->|"orchestrates"| XC
    RM -->|"orchestrates"| XP
    RM -->|"orchestrates"| XS
    RM -->|"orchestrates"| XA
    RM -->|"orchestrates"| XM
    RM -->|"orchestrates"| XGri
    RM -->|"orchestrates"| XV

    %% Feedback loops from Hardware to Planning
    HC -->|"state_feedback"| XS

    %% Click Events
    click XD "https://github.com/ingjae/xarm_ros/tree/master/xarm_description"
    click XG "https://github.com/ingjae/xarm_ros/tree/master/xarm_gazebo"
    click HC "https://github.com/ingjae/xarm_ros/tree/master/xarm_controller"
    click HB "https://github.com/ingjae/xarm_ros/tree/master/xarm_bringup"
    click XC "https://github.com/ingjae/xarm_ros/tree/master/xarm7_moveit_config"
    click XP "https://github.com/ingjae/xarm_ros/tree/master/xarm_planner"
    click XS "https://github.com/ingjae/xarm_ros/tree/master/xarm_moveit_servo"
    click XA "https://github.com/ingjae/xarm_ros/tree/master/xarm_api"
    click XM "https://github.com/ingjae/xarm_ros/tree/master/xarm_msgs"
    click XGri "https://github.com/ingjae/xarm_ros/tree/master/xarm_gripper"
    click XV "https://github.com/ingjae/xarm_ros/tree/master/xarm_vision"

    %% Styles
    classDef hardware fill:#F2A900,stroke:#333,stroke-width:2px;
    classDef simulation fill:#89CFF0,stroke:#333,stroke-width:2px;
    classDef planning fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef api fill:#C1FFC1,stroke:#333,stroke-width:2px;
    classDef peripheral fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef ros fill:#FFD700,stroke:#333,stroke-width:2px;
```
