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 Name | Message Type | Direction | Description |
|---|---|---|---|
/motion/body_vel_cmd | BodyVelCmd.msg | Client → Walking Service | Send velocity control message |
Coordinate Frame Definition (right-handed coordinate frame, origin at the body center):
| Axis | Direction |
|---|---|
| X axis | Forward direction of the robot body |
| Y axis | Left direction of the robot body |
| Z axis | Upward direction of the robot body |
Message Fields:
| Field | Type | Unit | Description |
|---|---|---|---|
linear_velocity[0] | float64 | m/s | X-direction velocity; positive value moves forward, negative value moves backward |
linear_velocity[1] | float64 | m/s | Y-direction velocity; positive value moves left, negative value moves right |
yaw_velocity | float64 | rad/s | Yaw angular velocity; positive value is counterclockwise, negative value is clockwise |
header | std_msgs/Header | — | Timestamp and frame ID (frame_id set to "body") |
The velocity limits are shown in the following table:
| Parameter | Minimum | Maximum |
|---|---|---|
| X-axis linear velocity (forward/backward, unit m/s) | -1 | 1 |
| Y-axis linear velocity (left/right translation, unit m/s) | -1 | 1 |
| Yaw angular velocity (rotation, unit rad/s) | -1 | 1 |
3 Control Frequency and Velocity Limits
| Item | Requirement |
|---|---|
| Recommended frequency | 100 Hz (10 ms period) |
| Minimum frequency | 50 Hz; too low a frequency may cause discontinuous motion |
| Stop method | Explicitly send a zero-velocity command (set all fields to 0) |
| Timeout protection | The 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 Mode | Gamepad Buttons | Supported 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 |
Core Code:
Python |
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
