Skip to content

Robot and DDS Interfaces

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.

TopicMessage TypeDescription
/JOINTS_CMDdrdds/msg/JointsCmdJoint control command (SDK → Robot)
/JOINTS_DATAdrdds/msg/JointsJoint state feedback (Robot → SDK)
/IMU_DATA_HEADsensor_msgs/msg/ImuHead IMU data
/IMU_DATA_BASEsensor_msgs/msg/ImuBase IMU data
/STEERdrdds/msg/SteerNormalized velocity command
/REAL_STEERdrdds/msg/SteerActual velocity command
/GAMEPAD_KEYstd_msgs/msg/StringGamepad button events
/BATTERY_DATAdrdds/msg/BatteryDataBattery data
/MOTION_STATE—Motion state transition command
/MOTION_INFO—Motion state information
/GAIT—Gait switching command
ItemValue
Robot NameDR2PRO (enumeration value 0)
Total DOF31
Waist DOF3 (WaistX, WaistY, WaistZ)
Single Arm DOF7 (ShoulderY, ShoulderX, ShoulderZ, Elbow, WristZ, WristY, WristX)
Single Leg DOF6 (HipY, HipX, HipZ, Knee, AnkleY, AnkleX)
Neck DOF2

Joint Ordering: Waist(3) → Left Arm(7) → Right Arm(7) → Left Leg(6) → Right Leg(6) → Neck(2)

Joint configurations vary across robot models. The following table defines the joint name corresponding to each index:

IndexRegionDR02 STD Joint NameDR02 Pro Joint Name
0WaistWaist YawWaist Yaw
1xWaist Roll
2xWaist Pitch
3Left ArmLeft Shoulder PitchLeft Shoulder Pitch
4Left Shoulder RollLeft Shoulder Roll
5Left Shoulder YawLeft Shoulder Yaw
6Left ElbowLeft Elbow
7xLeft Wrist Yaw
8xLeft Wrist Pitch
9xLeft Wrist Roll
10Right ArmRight Shoulder PitchRight Shoulder Pitch
11Right Shoulder RollRight Shoulder Roll
12Right Shoulder YawRight Shoulder Yaw
13Right ElbowRight Elbow
14xRight Wrist Yaw
15xRight Wrist Pitch
16xRight Wrist Roll
17Left LegLeft Hip PitchLeft Hip Pitch
18Left Hip RollLeft Hip Roll
19Left Hip YawLeft Hip Yaw
20Left KneeLeft Knee
21Left Ankle PitchLeft Ankle Pitch
22Left Ankle RollLeft Ankle Roll
23Right LegRight Hip PitchRight Hip Pitch
24Right Hip RollRight Hip Roll
25Right Hip YawRight Hip Yaw
26Right KneeRight Knee
27Right Ankle PitchRight Ankle Pitch
28Right Ankle RollRight Ankle Roll
29HeadxHead Yaw
30xHead 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.

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
RobotInterface(robot_name, dof_num=31, leg_dof_num=6, arm_dof_num=7, waist_dof_num=3, neck_dof_num=2, node)
/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 IMU

Each joint has 5 parameters: kp, position, kd, velocity, torque

T=kp×(posgoal−posreal)+kd×(velgoal−velreal)+tffT = kp \times (pos_{goal} - pos_{real}) + kd \times (vel_{goal} - vel_{real}) + t_{ff}

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.

// Subscribe to joint data
auto 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]);
}
});
// Create joint command publisher
auto publisher = node->create_publisher<drdds::msg::JointsCmd>(
"/JOINTS_CMD", 10);
// Construct joint command
drdds::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 command
publisher->publish(cmd);
// Subscribe to head IMU
auto 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);
});

The SDK can run at the following locations as long as the ROS 2 / DDS network is interconnected:

LocationIPDescription
Development HostUser-configuredMust be connected to the robot’s rear Ethernet port via cable
AOS Host10.21.33.103On-robot compute device
NOS Host10.21.33.106Pre-installed with message interface library