> For the complete documentation index, see [llms.txt](https://tk233.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tk233.gitbook.io/notes/ml-rl/rl-frameworks/case-study-setting-up-berkeley-humanoid.md).

# Case Study: Setting up Berkeley Humanoid

## System

Running with the following system configuration:

* Ubuntu 22.04
* NVIDIA Driver 535.183.06
* CUDA 12.2
* Python 3.10
* IsaacLab 4.2.0

### Install Dependencies

```bash
sudo apt install ninja-build
sudo apt install build-essential
```

```bash
sudo apt install \
  ros-humble-pinocchio \
  ros-humble-ros2-control \
  ros-humble-gazebo-ros2-control \
  ros-humble-joint-state-broadcaster \
  ros-humble-joint-state-publisher-gui \
  ros-humble-xacro
```

```bash
# pip install onnxruntime
```

```bash
cd /tmp
wget https://github.com/microsoft/onnxruntime/releases/download/v1.7.0/onnxruntime-linux-x64-1.7.0.tgz
tar xf onnxruntime-linux-x64-1.7.0.tgz
mkdir -p ~/.local/bin ~/.local/include/onnxruntime ~/.local/lib ~/.local/share/cmake/onnxruntime
rsync -a /tmp/onnxruntime-linux-x64-1.7.0/include/ ~/.local/include/onnxruntime
rsync -a /tmp/onnxruntime-linux-x64-1.7.0/lib/ ~/.local/lib
wget https://raw.githubusercontent.com/leggedrobotics/ocs2/refs/heads/main/ocs2_mpcnet/ocs2_mpcnet_core/misc/onnxruntime/cmake/onnxruntimeConfig.cmake -O ~/.local/share/cmake/onnxruntime/onnxruntimeConfig.cmake
wget https://raw.githubusercontent.com/leggedrobotics/ocs2/refs/heads/main/ocs2_mpcnet/ocs2_mpcnet_core/misc/onnxruntime/cmake/onnxruntimeVersion.cmake -O ~/.local/share/cmake/onnxruntime/onnxruntimeVersion.cmake
cd -
```

```bash
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
```

## Setting up environment

Create the project directory and clone the required repositories. In this example, we will be working in the `./berkeley-humanoid` folder.

```bash
mkdir ./berkeley-humanoid/
cd ./berkeley-humanoid/
git clone https://github.com/isaac-sim/IsaacLab.git
git clone https://github.com/HybridRobotics/isaac_berkeley_humanoid.git
```

Create conda environment

```bash
conda create -yn humanoid-isaaclab python=3.10
conda activate humanoid-isaaclab
```

Install Python package dependencies for IsaacSim

{% code overflow="wrap" %}

```bash
pip install isaacsim-rl isaacsim-replicator isaacsim-extscache-physics isaacsim-extscache-kit-sdk isaacsim-extscache-kit isaacsim-app --extra-index-url https://pypi.nvidia.com
```

{% endcode %}

Go to the IsaacLab directory and install RSL-RL along with IsaacLab

```bash
cd ./IsaacLab
./isaaclab.sh --install rsl_rl
cd ..
```

Accept the EULA when prompted.

Go to the Berkeley Humanoid extension and install this module

```bash
cd ./isaac_berkeley_humanoid/exts/berkeley_humanoid
pip install -e .
cd ../../..
```

## Training the policy

```bash
cd ./isaac_berkeley_humanoid/
```

```bash
python ./scripts/rsl_rl/train.py --task Velocity-Rough-Berkeley-Humanoid-v0
```

For first-time running the script, it might take a few minutes for IsaacLab to load all the configuration and compile the shaders.

Running in headless mode

```bash
python ./scripts/rsl_rl/train.py --task Velocity-Rough-Berkeley-Humanoid-v0 --headless
```

Test out the trained policy

```bash
python ./scripts/rsl_rl/play.py --task Velocity-Rough-Berkeley-Humanoid-Play-v0
```

### Sim2sim transfer

source ros dependencies

```bash
source /opt/ros/humble/setup.sh
source /usr/share/colcon_cd/function/colcon_cd.sh
```

```bash
mkdir -p ./ros2_ws/src/
cd ./ros2_ws/src/
```

```bash
# cd ./ros2_ws/src/
git clone git@github.com:qiayuanl/berkeley_humanoid_description.git
git clone git@github.com:qiayuanl/legged_control2.git

# cd ./ros2_ws/src/berkeley_humanoid_description
git checkout feature/ament_cmake
```

```bash
# cd ./ros2_ws/
colcon build --packages-select berkeley_humanoid_description
```

{% code overflow="wrap" %}

```bash
colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo --event-handlers console_direct+ --packages-up-to legged_rl_controllers
```

{% endcode %}

```bash
source ./install/setup.bash
```

```bash
ros2 launch berkeley_humanoid_description view_robot.launch.py
```

```bash
ros2 launch berkeley_humanoid_description gazebo.launch.py
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tk233.gitbook.io/notes/ml-rl/rl-frameworks/case-study-setting-up-berkeley-humanoid.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
