Full-Body Tai Chi Motion Example
- Full-Body Tai Chi Motion Example
1. Description
This example is a ROS node that plays back predefined robot motion sequences. The motion sequences are stored in a JSON file and include gait control (foot motion) 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 to perform full-body robot joint calibration first to ensure the robot is in good condition. Run this example with the robot suspended by the safety rope (gantry) first, and consider running it without the rope only after it is sufficiently stable. In addition, because the robot squats slightly, the hoist needs to be lowered until the suspension frame is about 1 cm above the robot's head. When running this example, the robot takes a step to the left, so be careful not to hit obstacles. If you need to run this example repeatedly, add the parameter <joystick_type:=h12> after starting the lower-level controller program (if the robot is started with the remote controller, the lower-level program does not need to be started again), and every 2 to 3 repetitions of the Tai Chi motion, use the remote controller to make the robot step in place for a while to correct its posture.
-
The example code is located at:
/home/lab/kuavo-ros-opensource/src/demo/taiji/action_player -
Main files:
-
action_player.py: Main program of the action player -
taiji.json: Predefined Tai Chi motion sequence file
2. File Structure
taiji/
├── action_player.py # 动作播放器主程序
└── taiji.json # 预定义的太极动作序列
3. Running Steps
- Terminal 1: start the lower-level controller program (running on the real robot; skip this step if the robot has already been started with the controller):
cd ~/kuavo-ros-opensource && sudo su
source devel/setup.bash
roslaunch humanoid_controllers load_kuavo_real.launch
- Terminal 1: start the lower-level controller program (simulation):
cd ~/kuavo-ros-opensource && sudo su
source devel/setup.bash
roslaunch humanoid_controllers load_kuavo_mujoco_sim.launch
- Terminal 2: run the action player node:
cd ~/kuavo-ros-opensource && sudo su
source devel/setup.bash
python3 src/demo/taiji/actions_player.py
Note: Before running, make sure the taiji.json file is in the same directory, or modify the path in the code.
- Running result
- Running the full-body Tai Chi motion example with the H12 remote controller
- Modify the lower-level controller configuration file:
/home/lab/kuavo-ros-opensource/src/humanoid-control/h12pro_controller_node/config/customize_config.json. - Enter the remote controller button combination you want to use, for example:
"customize_action_LL_A": {
"type": "shell",
"command": "python3 /home/lab/kuavo-ros-opensource/src/demo/taiji/actions_player.py > /home/lab/taiji_output.txt 2>&1"
},- After the modification, power off and restart the robot.
4. ROS Interfaces
4.1 Published Topics
/humanoid_mpc_foot_pose_target_trajectories
-
Message type:
kuavo_msgs/footPoseTargetTrajectories -
Description: Publishes foot target trajectories, which the MPC controller uses to control the robot's gait.
/kuavo_arm_target_poses
-
Message type:
kuavo_msgs/armTargetPoses -
Description: Publishes target arm poses to control the arm joint angles.
4.2 Subscribed Topics
/humanoid_mpc_observation
-
Message type:
ocs2_msgs/mpc_observation -
Description: Subscribes to the MPC observation information to obtain the current MPC time.
/humanoid_mpc_gait_time_name
-
Message type:
kuavo_msgs/gaitTimeName -
Description: Subscribes to gait time information to obtain the gait start time.
4.3 Services
/humanoid_change_arm_ctrl_mode
-
Service type:
kuavo_msgs/changeArmCtrlMode -
Description: Call this service to set the arm control mode to external control (mode 2).
5. Usage Guide
5.1 Motion File Format
The motion file is in JSON format and contains two main parts: step_control (gait control) and arm_motion (arm motion).
5.1.1 Gait Control Data
step_control is an array, and each element represents a gait control point:
-
time: Duration of this gait (<= 1 second) -
comment: Comment -
mode: Gait mode (SS: double support, FS: left foot single support, SF: right foot single support) -
torso_pose: Torso pose [x, y, z, roll, pitch, yaw] (units: meters and degrees) -
foot_positions: Foot positions [x, y, z, yaw] (units: meters and degrees)
5.1.2 Arm Motion Data
arm_motion is an array, and each element represents an arm motion point:
-
time: Duration of this motion point (seconds) -
comment: Comment -
angles: Angle values of the 14 arm joints (degrees), ordered as the 7 joints of the left arm followed by the 7 joints of the right arm.
5.2 Motion Execution Flow
-
Load the JSON motion file.
-
Initialize the ROS node and create publishers and subscribers.
-
Set the arms to external control mode (via a service call).
-
Generate foot trajectories and publish them to
/humanoid_mpc_foot_pose_target_trajectories. -
Wait until the gait start time is received.
-
Generate arm trajectories and publish them to
/kuavo_arm_target_poses(timing is based on the gait start time). -
Wait for the motion execution to complete.
6. Additional Notes
-
The motion file
taiji.jsonin this example contains a complete Tai Chi motion sequence, including torso movement, foot movement, and arm motion. -
In actual operation, make sure the MPC controller and the arm controller are running properly and that the robot is in a suitable initial state.
-
During motion execution, the node monitors the MPC observation information and gait time in real time to keep the motions synchronized.