ROS2 Interface Development Documentation•Chapter 3: Body Velocity Control

Chapter 3: Body Velocity Control

Updated: October 14, 2026

1 Interface Overview

The body velocity control interface is used to control the motion velocity of the robot body, including the linear velocity in the forward/backward and left/right directions and the yaw angular velocity. This is a higher-level control interface than the joint command—developers do not need to worry about the position of each joint; they only need to specify the desired body motion velocity, and the robot's internal locomotion controller will automatically complete the joint-level motion planning.

This interface needs to continuously publish velocity commands at a fixed frequency to maintain motion; it is suitable for direction and velocity control during the robot's walking process.

2 Message Fields and Coordinate Frame

Communication Interface:

Topic NameMessage TypeDirectionDescription
/motion/body_vel_cmdBodyVelCmd.msgClient → Walking ServiceSend velocity control message

Coordinate Frame Definition (right-handed coordinate frame, origin at the body center):

AxisDirection
X axisForward direction of the robot body
Y axisLeft direction of the robot body
Z axisUpward direction of the robot body

Message Fields:

FieldTypeUnitDescription
linear_velocity[0]float64m/sX-direction velocity; positive value moves forward, negative value moves backward
linear_velocity[1]float64m/sY-direction velocity; positive value moves left, negative value moves right
yaw_velocityfloat64rad/sYaw angular velocity; positive value is counterclockwise, negative value is clockwise
headerstd_msgs/Header—Timestamp and frame ID (frame_id set to "body")

The velocity limits are shown in the following table:

ParameterMinimumMaximum
X-axis linear velocity (forward/backward, unit m/s)-11
Y-axis linear velocity (left/right translation, unit m/s)-11
Yaw angular velocity (rotation, unit rad/s)-11

3 Control Frequency and Velocity Limits

ItemRequirement
Recommended frequency100 Hz (10 ms period)
Minimum frequency50 Hz; too low a frequency may cause discontinuous motion
Stop methodExplicitly send a zero-velocity command (set all fields to 0)
Timeout protectionThe receiving end automatically stops after not receiving a message for 2 seconds

It is recommended to implement gradual velocity changes rather than abrupt changes; velocities exceeding the limits may be automatically clipped or cause errors.

4 Prerequisites

The body velocity control interface only takes effect when the robot enters a walking-type motion mode. Motion modes can be switched via the gamepad:

Motion ModeGamepad ButtonsSupported Models
Natural gait (rl_basic)[LB, B]PM01 / T800
Mechanical gait (rl_amp)[LB, X]PM01 only
Terrain gait (rl_terrain)[LB, Y]PM01 only
Lower-body balance gait (lower_body_balance)[LB, CROSS_X_DOWN]PM01 / T800

This interface may be disabled in some motion modes; before use, ensure the robot is in a state that can accept velocity commands.

5 Example: Velocity Control Flow

File Name: body_velocity_control_example.py

This example demonstrates how to control the robot's movement by periodically publishing BodyVelCmd messages, including forward motion, translation, and rotation.

Run Command:

Bash
python3 body_velocity_control_example.py

Core Code:

Python
import rclpy
from rclpy.node import Node
from std_msgs.msg import Header
from interface_protocol.msg import BodyVelCmd

class BodyVelocityPublisher(Node):
    def __init__(self):
        super().__init__("body_velocity_publisher")
        # Create publisher, publish periodically at 100 Hz
        self.pub = self.create_publisher(BodyVelCmd, "/motion/body_vel_cmd", 10)
        self.create_timer(0.01, self._tick)  # 100 Hz = 10 ms

    def _tick(self):
        msg = BodyVelCmd()
        msg.header = Header()
        msg.header.stamp = self.get_clock().now().to_msg()
        msg.header.frame_id = "body"
        msg.linear_velocity = [0.5, 0.0]  # [x, y] m/s, positive value forward/left
        msg.yaw_velocity = 0.0            # rad/s, positive value counterclockwise
        self.pub.publish(msg)

rclpy.init()
rclpy.spin(BodyVelocityPublisher())

Modify the values of linear_velocity and yaw_velocity to control the direction. When stopping, set all values to 0. The complete script includes keyboard interaction and graceful exit; see GitHub.

6 Notes

  • Ensure the motion controller node has started and is in an appropriate walking-type motion state
  • Velocity commands must be sent continuously to maintain motion (the robot does not remember the previous velocity)
  • An explicit zero-velocity command must be sent when stopping
  • Velocities exceeding the limits may be automatically clipped or cause errors
  • It is recommended to implement gradual velocity changes rather than abrupt changes
  • This example does not include obstacle avoidance; in actual use, it needs to be combined with sensors and obstacle avoidance algorithms
  • It is recommended to start testing from a small velocity and gradually increase to the desired velocity
  • Use high velocity with caution in confined spaces
  • Use Ctrl+C to safely exit the program; the robot will stop

📎 Source files in the open-source repository for this chapter (click file name to jump to GitHub): BodyVelCmd.msg · body_velocity_control_example.py