How vsislab/robotamersdk4qmini works
Project type and purpose
• This is a C++-based robotics control SDK (RoboTamerSdk4Qmini) for real-time motion control of a biped robot (Unitree Qmini).
• It loads pre-trained reinforcement learning policies (exported as ONNX models) and interfaces with sensors (IMU, joystick) and actuators (Unitree motors, via serial and DDS).
File structure
• Top level:
• bin/: executables (run_interface, test_interface), configuration (config.yaml), policy.onnx, helper scripts.
• /: public headers, subdivided into modules (IOPort, crc, onnx runtime wrapper, serialPort, Unitree common & robot APIs, user-defined adapters, utils).
• lib/: prebuilt libraries (Unitree SDK, motor SDK, ONNX runtime).
• source/: C++ source files implementing the interface and controllers.
• thirdparty/: DDS middleware (CycloneDDS stacks) with headers and libs.
• Patterns and build:
• Uses CMake for multi-platform builds (ARM64, x86_64).
• Modular separation: hardware abstraction, sensor interfaces, inference, control loops, communication.
README for additional insights
• Confirms modular, thread-safe, real-time design with safety checks.
• Lists dependencies: Yaml-CPP, Eigen, ONNX Runtime, JSONCPP, Unitree SDKs, Python/pygame for joystick UI.
• Execution flow: configure → sensor init → ready mode → position mode → AI control mode.
Main components
a. Front-end execution layer (CLI)
– run_interface/test_interface executables
– Configuration loader (config.yaml via Yaml-CPP)
b. Sensor subsystems
– IMU interface (imu_receiver.py/C++ wrapper)
– Joystick input (pygame-based Python or C++ reader)
c. Inference engine
– ONNX Runtime session (policy.onnx)
– Inference module (onnx_inference.h/.cpp)
d. Control & safety logic
– RL controller (rl_controller.cpp)
– Mode switcher, data validation, emergency stop
– Threaded real-time control loop (Motor_thread.hpp)
e. Actuator & communication layer
– Unitree actuator SDK (libunitree_sdk2, unitreeMotor API)
– SerialPort abstraction
– DDS middleware for inter-module messaging (CycloneDDS stacks in thirdparty/)
f. Supporting libraries
– Eigen (linear algebra)
– JsonCpp (data serialization)
– CRC utilities, IOPort abstractions, utils for file I/O and orientation
Relationships and interactions
• The CLI executable reads config → spawns sensor threads → collects IMU & joystick data → passes to RL controller
• RL controller calls ONNX inference → produces motor commands
• Commands go through safety checks → handed to Unitree SDK via serial/DDS → robot actuators
• Feedback loop: actuator state (via DDS topics) → control loop → inference
Architectural patterns & principles
• Modular layering: separation of concerns (configuration, sensing, inference, control, actuation)
• Producer-consumer threads for real-time sensor and control loops
• Hardware abstraction layer for easy porting to different robot platforms
• Fail-safe design: emergency stop, sensor validation before sending commands
• Use of message-oriented middleware (DDS) for decoupled communication