Robot and DDS Interfaces
1. Overview
Section titled “1. Overview”The DR02 Pro SDK communicates with the robot through ROS 2 / DDS middleware, providing complete interfaces for joint control, state reading, IMU data, peripheral monitoring, and more.
Note: Before using ROS2 tools to receive topics, check frequencies, etc., you need to source the environment variables with
source /opt/robot/scripts/setup_ros2.sh.
2. Core ROS 2 Topics
Section titled “2. Core ROS 2 Topics”| Topic | Message Type | Description |
|---|---|---|
/JOINTS_CMD | drdds/msg/JointsCmd | Joint control command (SDK → Robot) |
/JOINTS_DATA | drdds/msg/Joints | Joint state feedback (Robot → SDK) |
/IMU_DATA_HEAD | sensor_msgs/msg/Imu | Head IMU data |
/IMU_DATA_BASE | sensor_msgs/msg/Imu | Base IMU data |
/STEER | drdds/msg/Steer | Normalized velocity command |
/REAL_STEER | drdds/msg/Steer | Actual velocity command |
/GAMEPAD_KEY | std_msgs/msg/String | Gamepad button events |
/BATTERY_DATA | drdds/msg/BatteryData | Battery data |
/MOTION_STATE | — | Motion state transition command |
/MOTION_INFO | — | Motion state information |
/GAIT | — | Gait switching command |
3. Robot Specifications
Section titled “3. Robot Specifications”3.1 Basic Information
Section titled “3.1 Basic Information”| Item | Value |
|---|---|
| Robot Name | DR2PRO (enumeration value 0) |
| Total DOF | 31 |
| Waist DOF | 3 (WaistX, WaistY, WaistZ) |
| Single Arm DOF | 7 (ShoulderY, ShoulderX, ShoulderZ, Elbow, WristZ, WristY, WristX) |
| Single Leg DOF | 6 (HipY, HipX, HipZ, Knee, AnkleY, AnkleX) |
| Neck DOF | 2 |
Joint Ordering: Waist(3) → Left Arm(7) → Right Arm(7) → Left Leg(6) → Right Leg(6) → Neck(2)
3.2 Joint Index Mapping Table
Section titled “3.2 Joint Index Mapping Table”Joint configurations vary across robot models. The following table defines the joint name corresponding to each index:
| Index | Region | DR02 STD Joint Name | DR02 Pro Joint Name |
|---|---|---|---|
| 0 | Waist | Waist Yaw | Waist Yaw |
| 1 | x | Waist Roll | |
| 2 | x | Waist Pitch | |
| 3 | Left Arm | Left Shoulder Pitch | Left Shoulder Pitch |
| 4 | Left Shoulder Roll | Left Shoulder Roll | |
| 5 | Left Shoulder Yaw | Left Shoulder Yaw | |
| 6 | Left Elbow | Left Elbow | |
| 7 | x | Left Wrist Yaw | |
| 8 | x | Left Wrist Pitch | |
| 9 | x | Left Wrist Roll | |
| 10 | Right Arm | Right Shoulder Pitch | Right Shoulder Pitch |
| 11 | Right Shoulder Roll | Right Shoulder Roll | |
| 12 | Right Shoulder Yaw | Right Shoulder Yaw | |
| 13 | Right Elbow | Right Elbow | |
| 14 | x | Right Wrist Yaw | |
| 15 | x | Right Wrist Pitch | |
| 16 | x | Right Wrist Roll | |
| 17 | Left Leg | Left Hip Pitch | Left Hip Pitch |
| 18 | Left Hip Roll | Left Hip Roll | |
| 19 | Left Hip Yaw | Left Hip Yaw | |
| 20 | Left Knee | Left Knee | |
| 21 | Left Ankle Pitch | Left Ankle Pitch | |
| 22 | Left Ankle Roll | Left Ankle Roll | |
| 23 | Right Leg | Right Hip Pitch | Right Hip Pitch |
| 24 | Right Hip Roll | Right Hip Roll | |
| 25 | Right Hip Yaw | Right Hip Yaw | |
| 26 | Right Knee | Right Knee | |
| 27 | Right Ankle Pitch | Right Ankle Pitch | |
| 28 | Right Ankle Roll | Right Ankle Roll | |
| 29 | Head | x | Head Yaw |
| 30 | x | Head Pitch |
Note: In the MotorStatus parameter group, due to the different number of joints between the STD and PRO versions, the array length is fixed at 31 for consistent display on the App side. A value of 10 indicates that the joint does not exist.
4. Robot Base Class Interface
Section titled “4. Robot Base Class Interface”4.1 Function Description
Section titled “4.1 Function Description”RobotInterface is the base class for robot access, responsible for:
- Creating ROS 2 publishers/subscribers
- Providing joint state reading (position, velocity, torque, temperature)
- Providing IMU data reading (head and base dual IMU)
- Publishing joint commands
4.2 Constructor Parameters
Section titled “4.2 Constructor Parameters”RobotInterface(robot_name, dof_num=31, leg_dof_num=6, arm_dof_num=7, waist_dof_num=3, neck_dof_num=2, node)4.3 Subscribed Topics
Section titled “4.3 Subscribed Topics”/JOINTS_CMD → Publish joint control commands/JOINTS_DATA ← Subscribe to joint state feedback/IMU_DATA_HEAD ← Subscribe to head IMU/IMU_DATA_BASE ← Subscribe to base IMU4.4 Joint Command Format
Section titled “4.4 Joint Command Format”Each joint has 5 parameters: kp, position, kd, velocity, torque
4.5 Joint Control Formula
Section titled “4.5 Joint Control Formula”
4.6 DOF Parameter Setting Interface
Section titled “4.6 DOF Parameter Setting Interface”DR2ProInterface inherits from RobotInterface and only sets the DOF parameters:
DR2ProInterface(node, "DR2PRO") : RobotInterface("DR2PRO", 31, 12, 14, 3, 2, node)No additional offset or direction mapping is applied; raw values are used directly.
5. Usage Examples
Section titled “5. Usage Examples”5.1 Subscribe to Joint Data
Section titled “5.1 Subscribe to Joint Data”// Subscribe to joint dataauto subscription = node->create_subscription<drdds::msg::Joints>( "/JOINTS_DATA", 10, [](const drdds::msg::Joints::SharedPtr msg) { // Process joint data for (size_t i = 0; i < msg->joint_position.size(); ++i) { RCLCPP_INFO(node->get_logger(), "Joint %zu: pos=%.4f vel=%.4f", i, msg->joint_position[i], msg->joint_velocity[i]); } });5.2 Publish Joint Commands
Section titled “5.2 Publish Joint Commands”// Create joint command publisherauto publisher = node->create_publisher<drdds::msg::JointsCmd>( "/JOINTS_CMD", 10);
// Construct joint commanddrdds::msg::JointsCmd cmd;for (int i = 0; i < 31; ++i) { cmd.kp.push_back(600); // PD gain Kp cmd.position.push_back(0.0); // Target position cmd.kd.push_back(6); // PD gain Kd cmd.velocity.push_back(0.0); // Target velocity cmd.torque.push_back(0.0); // Feedforward torque}
// Publish commandpublisher->publish(cmd);5.3 Subscribe to IMU Data
Section titled “5.3 Subscribe to IMU Data”// Subscribe to head IMUauto imu_sub = node->create_subscription<sensor_msgs::msg::Imu>( "/IMU_DATA_HEAD", 10, [](const sensor_msgs::msg::Imu::SharedPtr msg) { RCLCPP_INFO(node->get_logger(), "IMU: lin_acc=[%.2f %.2f %.2f] ang_vel=[%.2f %.2f %.2f]", msg->linear_acceleration.x, msg->linear_acceleration.y, msg->linear_acceleration.z, msg->angular_velocity.x, msg->angular_velocity.y, msg->angular_velocity.z); });6. Deployment Locations
Section titled “6. Deployment Locations”The SDK can run at the following locations as long as the ROS 2 / DDS network is interconnected:
| Location | IP | Description |
|---|---|---|
| Development Host | User-configured | Must be connected to the robot’s rear Ethernet port via cable |
| AOS Host | 10.21.33.103 | On-robot compute device |
| NOS Host | 10.21.33.106 | Pre-installed with message interface library |