Skip to content

RL Control Example

DR02 Pro RL training video or Bilibili · DR02 video tutorials

This example demonstrates how to perform RL control interaction with the DR02 robot via ROS2 topics.

RL training code: DeepRoboticsLab/rl_training

Users can switch the robot’s RL control state via the /MOTION_STATE topic:

Motion StateState Value
Idle0
Joint Damping / Soft E-Stop2
RL Control17
Suspended Stand-up0x20006
import rclpy
from rclpy.node import Node
from drdds.msg import MotionState
class RLControlNode(Node):
def __init__(self):
super().__init__('rl_control_node')
self.publisher = self.create_publisher(
MotionState, '/MOTION_STATE', 10)
def enable_rl_control(self):
msg = MotionState()
msg.header.frame_id = 0
msg.data.state = 17 # RL control state
self.publisher.publish(msg)
self.get_logger().info('Switched to RL control mode')

Send normalized velocity commands via the /STEER topic to control robot movement:

FieldMeaningRange
xForward/backward velocity[-1, 1]
yLeft/right velocity[-1, 1]
zVertical velocity[-1, 1]
rollRoll angle[-1, 1]
pitchPitch angle[-1, 1]
yawYaw angle[-1, 1]
from drdds.msg import Steer
def send_velocity_cmd(node, vx, vy, vyaw):
msg = Steer()
msg.header.frame_id = 0
msg.x = vx # Forward/backward (1.0 = max speed forward)
msg.y = vy # Left/right (1.0 = max speed left)
msg.z = 0.0 # Height
msg.roll = 0.0
msg.pitch = 0.0
msg.yaw = vyaw # Yaw (rotation)
node.publisher.publish(msg)