AgiBot X1 Infer

repository·main·Indexed 23 days ago

https://github.com/agibottech/agibot_x1_infer

Software stack for the AgiBot X1 modular humanoid robot, built on AimRT middleware. It provides model inference, platform drivers, and simulation environments. The repository includes the DCU Driver Module for EtherCAT communication via the xyber_controller SDK, ROS2 Humble interfaces for joint control and IMU data, and support for the Logitech F710 joystick. Requires a PREEMPT_RT real-time kernel for real-robot operation.

Tokens
11.3K
Snippets
31
Records
64
Agent score
82%

What's inside agibot_x1_infer

  1. Introduction to the DCU Driver Module

    main

    The Domain Control Unit (DCU) Driver Module manages communication between the main controller and actuators via the EtherCAT bus. The DCU can throughput CANFD packet data with a refresh frequency of up to 1kHz.

    Key features:

    • Each DCU includes one external IMU and three CANFD buses.
    • Each CANFD bus can support up to 8 actuators in series.
    • The module is an abstraction over the xyber_controller SDK, integrated with the AimRT framework to include a transmission layer, data processing, IMU data publishing, and joint control interfaces.

    Critical Requirement: Because the SDK uses the EtherCAT protocol stack with hardware synchronization, you must install the PREEMPT_RT real-time kernel patch to run on real hardware.

  2. Understand the Transmission Layer (Joint vs. Actuator Space)

    main

    The module implements a transmission layer that maps data between Joint Space and Actuator Space.

    • Downlink Flow: Received data $\rightarrow$ Joint Space (indexed by name) $\rightarrow$ Transmission Conversion $\rightarrow$ Actuator Space $\rightarrow$ SDK $\rightarrow$ Hardware.
    • Uplink Flow: Hardware $\rightarrow$ SDK $\rightarrow$ Actuator Space $\rightarrow$ Transmission Conversion $\rightarrow$ Joint Space $\rightarrow$ ROS2 Topics.

    The binding relationship between joints and actuators is defined in the transmission field of the configuration file.

  3. Understand the DCU Driver Module transmission layer

    main

    The transmission layer acts as a bridge between joint space (used by high-level control) and actuator space (used by the low-level SDK).

    Data Flow:

    • Downstream (Control): Received data is cached in the joint space by joint name $\rightarrow$ converted by the transmission layer $\rightarrow$ cached in the actuator space $\rightarrow$ distributed via the SDK.
    • Upstream (Feedback): Data flows from the actuator space $\rightarrow$ converted by the transmission layer $\rightarrow$ cached in the joint space for high-level consumption.

    Binding relationships between joints and actuators are defined in the transmission field of the system configuration file.

  4. Choose the correct backend for Channel and RPC communication

    main

    AimRT supports multiple backends for Channels and RPCs. Choosing the right one depends on your communication scope:

    • Intra-process (Single-process): Use the Local RPC Backend or Local Channel Backend. These are optimized to automatically detect if the client and server are in the same package and will perform direct function calls to minimize overhead.
    • Inter-process (External communication): Use the ROS2 backend for communication between different processes.
  5. Choose the appropriate backend for Channel and RPC

    main

    Both Channel and RPC support multiple backends. Choosing the right one depends on your communication scope:

    • Intra-process (Single Process): Use the Local RPC or Local Channel backends. These are optimized for single-process scenarios; AimRT will automatically detect if the Client and Server are in the same Package and perform direct function calls.
    • Inter-process / External Communication: Use the ROS2 backend for communicating with external nodes or other processes.
  6. Install dependencies for AgiBot X1 software

    main

    Before building or running the software, you must install several system dependencies including GCC-13, CMake (3.26+), ONNX Runtime, ROS2 Humble, and simulation libraries.

    To install the core build tools and simulation dependencies, run:

    sudo apt update
    sudo apt install -y build-essential cmake git libprotobuf-dev protobuf-compiler jstest-gtk libglfw3-dev libdart-external-lodepng-dev

    Note: If you require real-robot debugging, you should also install the Linux realtime kernel patch.

  7. Verify PREEMPT_RT real-time kernel installation

    main

    To run the DCU SDK on a real robot, you must use a Linux kernel with the PREEMPT_RT patch. You can verify the installation using the following two methods:

    1. Check kernel version string: Run uname -a. The output must contain PREEMPT_RT (e.g., Linux Console 6.1.59-rt16 #2 SMP PREEMPT_RT ...).
    2. Check realtime sysfs: Run cat /sys/kernel/realtime. The path must exist and the value must be 1.
  8. Configure library paths for Real Robot launch

    main

    Before launching on a real robot, you must add the ROS2 library path and your project's build installation path to /etc/ld.so.conf so the system can locate the required shared libraries.

    1. Open the configuration file: sudo vi /etc/ld.so.conf

    2. Append the following paths to the end of the file:

      /opt/ros/humble/lib
      {YourProjectSource}/build/install/lib

      (Replace {YourProjectSource} with the actual absolute path to your repository)

    3. Refresh the system environment: sudo ldconfig

    # Open "/etc/ld.so.conf" as root
    sudo vi /etc/ld.so.conf
    
    # Add this path to the end of "/etc/ld.so.conf"
    /opt/ros/humble/lib
    {YourProjectSource}/build/install/lib
    
    # Refresh system env
    sudo ldconfig
  9. Install dependencies for Agibot X1

    main

    Before building or running the software, ensure the following dependencies are installed:

    • GCC-13
    • CMake (version 3.26 or higher)
    • ONNX Runtime
    • ROS2 Humble (with environment variables configured)
    • Simulation dependencies:
      sudo apt install jstest-gtk libglfw3-dev libdart-external-lodepng-dev
    • Real Robot requirement: Install Linux Real-time kernel patches for hardware debugging.

    To install ONNX Runtime from source:

    sudo apt update
    sudo apt install -y build-essential cmake git libprotobuf-dev protobuf-compiler
    
    git clone --recursive https://github.com/microsoft/onnxruntime
    
    cd onnxruntime
    ./build.sh --config Release --build_shared_lib --parallel
    
    cd build/Linux/Release/
    sudo make install