Roban2 (ROS1) Legacy VersionsFeature ExamplesGeneral Examples
Full-Body Tai Chi Motion Example
- Full-Body Tai Chi Motion Example

Description
This example is a ROS node that plays back a predefined sequence of robot motions. The motion sequence is stored in a CSV file and includes gait control (foot movement) and arm motions. The node communicates with the MPC controller and the arm controller through ROS topics and services to execute the motions in sequence.
- It is recommended that you calibrate the full-body robot joints first to ensure the robot is in good condition. Run this example with the robot suspended by a harness first, and only consider running it without the harness once it is sufficiently stable.
- The example code is located at:
~/kuavo-ros-opensource/src/demo/csv2body_demo - Main files:
- Motion player main program:
step_player_csv_ocs2.py - Predefined Tai Chi motion sequence file:
taiji_step_roban_stable.csv
- Motion player main program:
File Structure
csv2body_demo/
├── step_player_csv_ocs2.py # 动作播放器主程序
└── actions
└── taiji_step_roban_stable.csv # 预定义的太极动作序列Running Steps
- Build the controller
cd ~/kuavo-ros-opensource && sudo su
catkin build humanoid_controllers
source devel/setup.bash- Terminal 1: start the low-level control program (running on the real robot):
cd ~/kuavo-ros-opensource && sudo su
source devel/setup.bash
roslaunch humanoid_controllers load_kuavo_real.launch- Terminal 1: start the low-level control program (simulation):
cd ~/kuavo-ros-opensource && sudo su
source devel/setup.bash
roslaunch humanoid_controllers load_kuavo_mujoco_sim.launch- Terminal 2: run the motion player node:
cd ~/kuavo-ros-opensource
source devel/setup.bash
python3 ./src/demo/csv2body_demo/step_player_csv_ocs2.pyROS Interfaces
Published Topics
/humanoid_mpc_foot_pose_target_trajectories
- Message type:
kuavo_msgs/footPoseTargetTrajectories - Function: Publishes the robot's target foot trajectories. This includes the timing of each step, the stance foot index (left foot/right foot/both feet), the swing height, and the poses of the torso and the swing foot. This topic is mainly used by the MPC (Model Predictive Controller) to plan the robot's gait.
/kuavo_arm_target_poses
- Message type:
kuavo_msgs/armTargetPoses - Function: Publishes the robot's target arm pose sequence. This includes an array of timestamps and a corresponding array of arm joint angle values, used to control coordinated arm motion.
Subscribed Topics
/humanoid_mpc_observation
- Message type:
ocs2_msgs/mpc_observation - Function: Subscribes to the MPC observation data, mainly to obtain the MPC controller's current precise internal time (
mpc_time). This is the basis for synchronizing the timing of all motions.
/humanoid_mpc_gait_time_name
- Message type:
kuavo_msgs/gaitTimeName - Function: Subscribes to the information published by the gait scheduler. When the gait named
custom_gaitactually begins execution, this topic publishes a precise start time. The node uses this time to synchronize the publishing of arm trajectories, ensuring that the arm motions are perfectly coordinated with the gait.
Services
/arm_traj_change_mode
- Service type:
kuavo_msgs/changeArmCtrlMode - Function: Call this service to switch the arm control mode. Before executing a motion, the script calls this service with the parameter
2to switch the arms to "external control mode", so that this node can take over control of the arms by publishing topics.
Gait and Arm Motion Data (CSV File Format)
- All motion data is defined in a single CSV file. Each row of the file represents the robot's full-body pose at one point in time. The columns of the file are defined as follows:
| Column Index | Data Name | Data Type | Description |
|---|---|---|---|
| 0 | time | float | Timestamp (seconds) |
| 1 | mode | int | Gait mode. 0: double support, 1: right foot swing, 2: left foot swing, 3: special three-step adjustment |
| 2-5 | torso_pose | float[4] | Torso pose [x, y, z, yaw] |
| 6-8 | left_foot_pose | float[3] | Left foot pose [x, y, yaw] |
| 9-11 | right_foot_pose | float[3] | Right foot pose [x, y, yaw] |
| 12-25 | arm_actions | float[14] | Angle values of the 14 arm joints. Note: the unit should be radians. |
Motion Execution Flow
- Initialization and loading:
- Start the
action_playerROS node. - Parse the command-line arguments and load the specified CSV motion file into memory.
- Start the
- Switch the arm mode:
- Call the
/arm_traj_change_modeservice to request switching the arms to external control mode, preparing for the subsequent motion control.
- Call the
- Obtain the MPC time:
- By subscribing to the
/humanoid_mpc_observationtopic, wait for and obtain the MPC's current time, which serves as the reference for all subsequent time calculations.
- By subscribing to the
- Publish the foot trajectory (trigger the gait):
- The script generates the complete target foot trajectory (a
footPoseTargetTrajectoriesmessage) based on the data in the CSV file. - If the user sets
--time-offset, ROS parameters/mpc/schedule/...are set to delay the start of the gait. - The foot trajectory is published all at once to the
/humanoid_mpc_foot_pose_target_trajectoriestopic. After receiving this message, the MPC begins planning and executing the gait.
- The script generates the complete target foot trajectory (a
- Wait for the synchronization signal:
- After publishing the foot trajectory, the script enters a waiting state and listens to the
/humanoid_mpc_gait_time_nametopic. - When the MPC actually starts executing
custom_gait, it publishes a precise gait start time. Receiving this time is the key synchronization signal for executing the subsequent arm motions.
- After publishing the foot trajectory, the script enters a waiting state and listens to the
- Publish the arm trajectory:
- After receiving the gait start time, the script continues to wait until the MPC's current time reaches or exceeds that gait start time.
- Once the times are synchronized, the script generates the complete arm trajectory (an
armTargetPosesmessage) based on the CSV data and publishes it all at once to the/kuavo_arm_target_posestopic.
- Wait for completion:
- After all trajectories have been published, the script calculates the duration of the motion based on the total time in the CSV file and enters a waiting state until playback is complete. When execution finishes, the script exits.