Kuavo Docs
Feature ExamplesResearch FrameworksImitation Learning Examples

▶️ Using the Simulation Environment

Case Overview

This case describes how to implement a dual-arm object pick-and-place task for the Leju Kuavo robot based on the Kuavo_data_challenge repository and the corresponding dataset. The case provides a simulation deployment of dual-arm manipulation for the Leju Kuavo robot based on Diffusion Policy, and explains how to use the Kuavo_data_challenge repository to configure the environment, train models, and deploy them in MuJoCo simulation.

Demonstration

Usage Tutorial

1. Download the Code Repositories + Environment Setup

This case requires setting up two code repositories and starting two processes (simulation side and inference side) that work together. The inference side is used for model inference (starting the imitation learning model), and the simulation side is used to receive the inference results, interact with the environment, and score them (starting the MuJoCo simulation node to receive the model inference results).

A video tutorial is also provided: Installation and Training Guide — Competition Manual Documentation.

Please configure the corresponding environments according to the documentation. The following tutorial assumes the environment has been set up successfully.

PS: The kuavo_data_challenge (inference side) environment setup is missing some packages, which will affect the startup of the model inference script. The solution is as follows; install as needed

conda activate kdc

# If an error reports that the kuavo_humanoid_sdk module is missing, downgrade the version, as the latest version may be incompatible
pip install kuavo_humanoid_sdk==1.2.1
# If an error reports that deprecated is missing, install it.
pip install deprecated 
# If an error reports that apriltag_ros is missing, install it. If you use ROS Noetic + python3, you can install it as follows
sudo apt update
sudo apt install ros-noetic-apriltag-ros

2. Running the Simulation

⚠️ Note: This case requires starting two processes at the same time (two terminals). The inference side is used to start the imitation learning model, and the simulation side is used to start the MuJoCo node.

(1) Start the simulation-side process

In the first terminal, start the kuavo-ros-opensource simulation environment and run the script to launch the node:

cd kuavo-ros-opensource
./docker/run_with_gpu.sh kuavo_opensource_mpc_wbc_img:0.6.1 # Start the container
# Go to the kuavo_ws path inside the container
export ROBOT_VERSION=45
source devel/setup.zsh
# Start the simulation-side MuJoCo process and select Task 1
python3 src/data_challenge_simulator/examples/deploy/deploy.py

(2) Configure the model config file on the inference side

  • Step 1: Download the demo model

This case provides a simple Diffusion Policy imitation learning model. The model files are large and must be downloaded separately and placed in the specified path. Model file downloads: Model file 1, Model file 2. The two model files together form one imitation learning model. Place them in kuavo_data_challenge/outputs/train/task1_demo/diffusion/run_demo/epochdemo (you need to create the folder yourself).

  • Step 2: Download the trajectory data

Inference requires the full path of a bag file, for example the one for reaching the pre-grasp pose; you can directly copy a training rosbag for control. The case provides one data file: Task 1 grasping task rosbag data download. Place it in kuavo_data_challenge/rosbag_data/TASK1-TargetPlacement (you need to create the folder yourself).

  • Step 3: Modify the simulation configuration file

Modify the model interface in lines 65-78 of kuavo_data_challenge/configs/deploy/kuavo_sim_env.yaml to use the demo model and the 50-episode open-source rosbag dataset provided by the case. As shown below:

go_bag_path: /rosbag_data/TASK1-TargetPlacement/task1_0001.bag  # The full path of the bag file is required during inference.

policy_type: "diffusion"  # The demo model is a diffusion policy
eval_episodes: 10  # Number of inference evaluation episodes, used for scoring
task: "task1_demo"  # Custom task name of the trained model
method: "diffusion"
timestamp: "run_demo"
epoch: demo  

Config file modification

(3) Start the inference-side process

Open a new terminal and start it with the following commands.

cd kuavo_data_challenge
conda activate kdc
# Method 1: Run the automated test script directly (recommended)
python kuavo_deploy/examples/scripts/script_auto_test.py --task auto_test --config configs/deploy/kuavo_sim_env.yaml

# Method 2: Run the main script as described in the tutorial, then select a command
bash kuavo_deploy/eval_kuavo.sh
# After running, select 3, then select the example. The config file path is configs/deploy/kuavo_sim_env.yaml (simulation), and then select the script you need. For the function of each command, see the kdc repository documentation.

Method 2 launches an interactive page with more features. You can refer to the kdc interactive page overview to explore it yourself. This case only covers the function of starting the simulation, so Method 1 is recommended.

PS: If a program running on the simulation side reports an error, the error log will be saved in Kuavo_data_challenge/log; you can check it and debug on your own.

(4) Start rqt_image_view to view the camera topics

# After roscore starts, open a new terminal and enter this; select the corresponding camera topic to view
rqt_image_view
Simulation environment topic nameDescription
/cam_h/color/image_raw/compressedUpper camera RGB color image
/cam_h/depth/image_raw/compressedDepthUpper camera depth image
/cam_l/color/image_raw/compressedLeft camera RGB color image
/cam_l/depth/image_rect_raw/compressedDepthLeft camera depth image
/cam_r/color/image_raw/compressedRight camera RGB color image
/cam_r/depth/image_rect_raw/compressedDepthRight camera depth image
/gripper/commandSimulation rq2f85 gripper control command
/gripper/stateCurrent state of the simulation rq2f85 gripper
/joint_cmdControl commands for all joints (including legs)
/kuavo_arm_trajRobot arm trajectory control
/sensors_data_rawRaw data from all sensors

3. Imitation Learning Model Training Workflow (Optional)

The documentation in the kuavo_data_challenage repository describes the detailed training process: kdc imitation learning model training workflow. You can train models yourself. The simulation data required for training can be downloaded from the Leju Tianchi Competition open-source dataset.

About Downloading Huggingface Datasets

Method 1: Download with the hf tool

Refer to the official documentation to configure hf, and download with hf download xxx/xxx --repo_type dataset. A token must be configured before downloading; refer to the official documentation to define a token.

If you want to download individual files or folders from the dataset, you can use the --include parameter:

# Download the TASK1 data from our kdc dataset; --include specifies the path, * means all files in the directory, --local-dir specifies where to save it
hf download LejuRobotics/kuavo_data_challenge \
  --repo-type dataset \
  --include "sim/TASK1-TargetPlacement/*" \
  --local-dir "replace with save path"

Method 2: Download with the hfd tool (recommended for users in China)

Downloading Hugging Face models or datasets with the hf tool is relatively slow in China because it depends on proxy speed. We recommend the dedicated multi-threaded downloader hfd; you can refer to this tutorial for configuration. After downloading the hfd.sh script, run the following code:

./hfd.sh LejuRobotics/kuavo_data_challenge  \
  --include "sim/TASK1-TargetPlacement/*"  \
  --local-dir "replace with save path" \
  --tool aria2c \
  --dataset

# If it prompts that you do not have permission to download and need a token, refer to the hf token configuration above and export your token to the environment variables
export HF_USERNAME="your huggingface username"
export HF_TOKEN="your token"