Train and deploy your own humanoid robot controller in 700 lines of Python
ksim_launch.mp4
You can use this repository as a GitHub template or as a Google Colab.
You can quickly try out the humanoid benchmark by running the training notebook in Google Colab.
- Read through the current leaderboard submissions and through the ksim examples
- Create a new repository from this template by clicking here
- Clone the new repository you create from this template:
git clone git@github.com:<YOUR USERNAME>/ksim-gym.git
cd ksim-gym
- Create a new Python environment (we require Python 3.11 or later and recommend using conda)
- Install the package with its dependencies:
pip install -r requirements.txt
pip install 'jax[cuda12]' # If using GPU machine, install JAX CUDA libraries
python -c "import jax; print(jax.default_backend())" # Should print "gpu"
- Train a policy:
- Your robot should be walking within ~80 training steps, which takes 30 minutes on an RTX 4090 GPU.
- Training runs indefinitely, unless you set the
max_steps
argument. You can also useCtrl+C
to stop it. - Click on the TensorBoard link in the terminal to visualize the current run's training logs and videos.
- List all the available arguments with
python -m train --help
.
python -m train
# You can override default arguments like this
python -m train max_steps=100
- To see the TensorBoard logs for all your runs:
tensorboard --logdir humanoid_walking_task
- To view your trained checkpoint in the interactive viewer:
- Use the mouse to move the camera around
- Hold
Ctrl
and double click to select a body on the robot, and then left or right click to apply forces to it.
python -m train run_mode=view load_from_ckpt_path=humanoid_walking_task/run_<number>/checkpoints/ckpt.bin
- Convert your trained checkpoint to a
kinfer
model, which can be deployed on a real robot:
python -m convert /path/to/ckpt.bin /path/to/model.kinfer
- Visualize the converted model in
kinfer-sim
:
kinfer-sim assets/model.kinfer kbot --start-height 1.2 --save-video video.mp4
- Commit the K-Infer model and the recorded video to this repository
- Push your code and model to your repository, and make sure the repository is public (you may need to use Git LFS)
- Write a message with a link to your repository on our Discord in the "【🧠】submissions" channel
- Wait for one of us to run it on the real robot - this should take about a day, but if we are dragging our feet, please message us on Discord
- Voila! Your name will now appear on our leaderboard
If you encounter issues, please consul 75AD t the ksim documentation or reach out to us on Discord.
To see all the available command line arguments, use the command:
python -m train --help
To visualize running your model without using kinfer-sim
, use the command:
python -m train run_mode=view
To see an example of a locomotion task with more complex reward tuning, see our kbot-joystick task which was generated from this template. It also contains a pretrained checkpoint that you can initialize training from by running
python -m train load_from_ckpt_path=assets/ckpt.bin
You can also visualize the pre-trained model by combining these two commands:
python -m train load_from_ckpt_path=assets/ckpt.bin run_mode=view
If you want to use the Jupyter notebook and don't want to commit your training logs, we suggest using pre-commit to clean the notebook before committing:
pip install pre-commit
pre-commit install