RL Control Example
DR02 Pro RL training video or Bilibili · DR02 video tutorials
Overview
Section titled “Overview”This example demonstrates how to perform RL control interaction with the DR02 robot via ROS2 topics.
RL training code: DeepRoboticsLab/rl_training
Motion State Transitions
Section titled “Motion State Transitions”Users can switch the robot’s RL control state via the /MOTION_STATE topic:
| Motion State | State Value |
|---|---|
| Idle | 0 |
| Joint Damping / Soft E-Stop | 2 |
| RL Control | 17 |
| Suspended Stand-up | 0x20006 |
Switch to RL Control Mode
Section titled “Switch to RL Control Mode”import rclpyfrom rclpy.node import Nodefrom 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')Velocity Command Dispatch
Section titled “Velocity Command Dispatch”Send normalized velocity commands via the /STEER topic to control robot movement:
| Field | Meaning | Range |
|---|---|---|
| x | Forward/backward velocity | [-1, 1] |
| y | Left/right velocity | [-1, 1] |
| z | Vertical velocity | [-1, 1] |
| roll | Roll angle | [-1, 1] |
| pitch | Pitch angle | [-1, 1] |
| yaw | Yaw angle | [-1, 1] |
Send Velocity Command Example
Section titled “Send Velocity Command Example”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)