File size: 13,100 Bytes
da5a206 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# Pair Lab Simulation
[](https://www.python.org/downloads/)
[](https://docs.isaacsim.omniverse.nvidia.com/4.5.0/index.html)
[](https://isaac-sim.github.io/IsaacLab/v2.1.0/index.html)
This repository contains the simulation tooling for the PAIR (Physical AI and Robotics) Lab
## Table of Contents
* [Prerequisites](#prerequisites)
* [Setup](#setup)
* [Training a Policy](#training-a-policy)
* [Evaluating a Trained Policy](#evaluating-a-trained-policy)
* [Listing Available Tasks](#listing-available-tasks)
* [Troubleshooting](#troubleshooting)
* [Project Structure](#project-structure)
## Prerequisites
- **Python 3.10** - [Download](https://www.python.org/downloads/)
- **CUDA-capable, RTX-based GPU** - [NVIDIA Requirements](https://developer.nvidia.com/cuda-gpus)
## Repo Setup
**NOTE** Follow these steps regardless of whether you are using Docker or not.
### Install git and curl
```bash
sudo apt update
sudo apt install git curl
```
### Setup a Personal Access Token on Github (if you don't already have one)
FOllow [this guide](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), specifically creating a "classic" token.
Make sure to check at least `repo` in the checkboxes below `Description` field to ensure you will be able to clone the repo. (I checked all of them to avoid having to redo this step, but unsure of the security / permission implications).
### Clone the repository:
```bash
# Use your chewy Github account as username, and the PAT from previous step as your password
git clone git@github.com:Chewy-Inc/pair-lab-sim.git
cd pair-lab-sim
```
### Set Environment Variables to Access the Nucleus Server
Generate an API token from the Nucleus server (see [instructions here](https://docs.omniverse.nvidia.com/nucleus/latest/config-and-info/api_tokens.html#token-generation)).
It's recommended to add this to your shell profile (e.g. \~/.bashrc or \~/.zshrc), so you don't need to export the env var each terminal session.
Replace `YOUR_API_TOKEN` with the token you generated.
<details open>
<summary>For <code>~/.bashrc</code> users</summary>
```bash
echo 'export OMNI_USER="\$omni-api-token"' >> ~/.bashrc
echo 'export OMNI_PASS="YOUR_API_TOKEN"' >> ~/.bashrc
source ~/.bashrc
````
</details>
<details>
<summary>For <code>~/.zshrc</code> users</summary>
```bash
echo 'export OMNI_USER="\$omni-api-token"' >> ~/.zshrc
echo 'export OMNI_PASS="YOUR_API_TOKEN"' >> ~/.zshrc
source ~/.zshrc
```
</details>
### Install pipx and add it to path
```bash
sudo apt install pipx
pipx ensurepath
```
### Setup pre-commit
[pre-commit](https://pre-commit.com/) runs all of our code checking tooling automatically when you run a `git commit`, helping maintain a clean, consistent codebase.
First install pre-commit:
```bash
pipx install pre-commit
```
In order to activate it for this repo, you need to run (from within this repo's top-level):
```bash
pre-commit install
```
## Docker Setup (recommended)
### Install Docker and Docker compose
Follow [this guide](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository) to install `docker` and `docker-compose` using apt.
**NOTE** Make sure you add your user to the docker group (instructions to do so are [here](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user) - you only need to do up until the `Configure Docker to start on boot with systemd` section).
### Install gitman and clone repos
```bash
pipx install gitman
gitman update
```
### Install NVIDIA Container Toolkit
Follow instructions [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#with-apt-ubuntu-debian) to install NVIDIA Container toolkit via `apt`.
Make sure to follow the steps in `Configuring Docker` section [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#configuring-docker) - configuring the runtime and restarting the docker daemon (`sudo systemctl restart docker`). Optionally set up Rootless mode in the next section [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#rootless-mode).
### Start docker container
You now have all the prerequisites needed to start and enter the Docker container.
```bash
./docker/container.py start pair
```
### Enter docker container
```bash
./docker/container.py enter pair
```
Now you're all set up and can start developing. Skip along to first steps section below.
### [Optional] VSCode Support for IsaacLab Python Language Features (outside container):
**NOTE**: This step is only needed if you want the Python language server features (e.g. syntax highlighting, go to definition functionality and other ease-of-use tools found [here](https://code.visualstudio.com/docs/editing/editingevolved)) specifically for Isaac Lab code, *outside* of the docker container. This step happens automatically as part of the docker build process, so these features will work when attaching to the docker container via DevContainers
without any manual user input.
1. Use VSCode or Cursor's `Tasks: Run Tasks` (Ctrl+Shift+P to open command palette) command and select `setup_python_env_with_path`.
2. Use VSCode or Cursor's `Developer: Reload Window`, (Ctrl+Shift+P to open command palette) and you should see that your IDE's Go To Definition feature now works for Isaac Lab imports.
## Manual Setup (not recommended)
**NOTE** The following manual installation is not recommended, as Docker installation above is easier / guaranteed to have all users on the same setup
### [Optional] Create virtual environment
**NOTE** If you already have a venv for setting up Isaac Sim / Lab, source that here and skip ahead to clone section below.
```bash
# Create and activate a virtual environment (recommended)
python -m venv pair_lab_venv
source pair_lab_venv/bin/activate
```
### Setup Isaac Sim and Isaac Lab
Follow the official installation guides, preferring pip-based installation over installing from source:
* **Isaac Sim**: [Installation Documentation](https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_workstation.html)
* **Isaac Lab**: [Setup Instructions](https://isaac-sim.github.io/IsaacLab/main/source/setup/installation/index.html)
### Clone the SO100 repo to get URDFs and meshes of SO-101
```bash
git clone https://github.com/TheRobotStudio/SO-ARM100
export SO_REPO_PATH="$(realpath SO-ARM100)"
```
It's recommended to add this to your shell profile (e.g. \~/.bashrc or \~/.zshrc), so you don't need to export the env var each terminal session.
<details open>
<summary>For <code>~/.bashrc</code> users</summary>
```bash
echo "export SO_REPO_PATH=\"$(realpath SO-ARM100)\"" >> ~/.bashrc
source ~/.bashrc
````
</details>
<details>
<summary>For <code>~/.zshrc</code> users</summary>
```bash
echo "export SO_REPO_PATH=\"$(realpath SO-ARM100)\"" >> ~/.zshrc
source ~/.zshrc
````
</details>
### Install the `pair_lab` python package
From within your virtual env, use pip to install `pair_lab`:
```bash
cd pair_lab/source/pair_lab
pip install -e .
```
To verify installation, `pip list | grep pair_lab` should print `pair_lab` followed by the current version of the package, and its installation directory:
```bash
(env_isaaclab) $ pip list | grep pair_lab
pair_lab 0.1.0 /home/ubuntu/pair/repos/pair-lab-sim/pair_lab/source/pair_lab
```
## Training a Policy
Now that everything is properly setup, we can start training an RL policy!
To run training for the box-push with SO-101, from the top-level directory, from inside the `pair_lab` docker container, run:
```bash
python scripts/rsl_rl/train.py --task Pair-Push-Cube-SO101-v0 --num_envs 4096
```
**NOTE:** I recommend starting with `--num_envs 1` to quickly check that things are running (as increasing `num_envs` increases start-up and iteration time.)
### Training Parameters
* `--task Pair-Push-Cube-SO101-v0`: Specifies the training task/environment
* `--num_envs [NUM_ENVS]`: Number of parallel environments (adjust based on your hardware)
### Additional Options
You can customize training with additional parameters:
* `--headless`: Run training headlessly (no GUI). This is most likely what you want when you run a longer training job, as it reduces the overhead of rendering the GUI, speeding up cycle time.
* `--max_iterations`: Maximum training iterations
* `--checkpoint_interval`: How often to save checkpoints
* `--log_dir`: Directory to save logs and checkpoints
Use `--help` to get info on the other CLI args.
### Monitoring Training
Training metrics are automatically logged via the `--logger` arg:
* **[Weights & Biases (WandB)](https://wandb.ai/)** - `--logger wandb` For experiment tracking and visualization
* **[TensorBoard](https://www.tensorflow.org/tensorboard)** - For real-time monitoring
* \*\*\[Neptune]
## Evaluating a Trained Policy
To run a "play" (inference/demo) session for the box-push with SO-101:
From the top-level directory, run:
```bash
python scripts/rsl_rl/play.py --task Pair-Push-Cube-SO101-v0 --num_envs 1 --checkpoint logs/rsl_rl/so101_push_cube/[DATE_OF_TRAINING_RUN]/[SELECTED_CHECKPOINT]
```
**NOTE:** Fill in `[DATE_OF_TRAINING_RUN]` and `[SELECTED_CHECKPOINT]` as follows:
```bash
python scripts/rsl_rl/play.py --task Pair-Push-Cube-SO101-v0 --num_envs 1 --checkpoint logs/rsl_rl/so101_push_cube/2025-07-16_21-29-32/model_9999.pt
```
In the above example, the 9999th checkpoint is the final one in a 10,000 iteration training run. You can select the checkpoint with the optimal performance via [WandB](https://wandb.ai/), [Tensorboard](https://www.tensorflow.org/tensorboard) or [MLFlow](https://mlflow.org/).
## Listing Available Tasks
To quickly see **all tasks/environments** that have been registered by the **PAIR Lab** extension (those beginning with `Pair-`), run the helper script from the repository **root**:
```bash
python scripts/list_envs.py
```
The script launches Isaac Sim headlessly, queries the Gymnasium registry, and prints a pretty‑table that shows:
| S. No. | Task Name | Entry Point | Config |
| ------ | ----------------------- | ---------------- | ---------------------------- |
| … | Pair‑Push‑Cube‑SO101‑v0 | pair\_lab.tasks… | pair\_lab.tasks…/config.yaml |
This is handy for discovering new tasks or double‑checking the exact string to pass to `--task` in training or evaluation commands.
## Troubleshooting
### Common Issues
- **CUDA out of memory**
Reduce the `--num_envs` parameter.
- **SO_REPO_PATH not found**
Ensure the environment variable is properly set and the SO-ARM100 repository is cloned.
- **Import errors**
Verify that `pair_lab` is properly installed:
```bash
pip list | grep pair_lab
```
- **Isaac Sim crashes**
Check the [Isaac Sim System Requirements](https://docs.omniverse.nvidia.com/isaacsim/latest/installation/requirements.html).
- **Slow training**
Enable `--headless` mode and ensure your GPU is being utilized.
- **NVMLError** or
**Error response from daemon: could not select device driver "nvidia" with capabilities: [[gpu]]**
Ensure Docker's `no-cgroups` setting is set to `false` and make sure you have NVIDIA container toolkit is installed, and you've either rebooted or run `sudo systemctl reload docker` after installation.
[See troubleshooting steps here.](https://forums.developer.nvidia.com/t/nvida-container-toolkit-failed-to-initialize-nvml-unknown-error/286219/3)
### Getting Help
* **Isaac Sim Documentation**: [Official Docs](https://docs.omniverse.nvidia.com/isaacsim/latest/)
* **Isaac Lab Documentation**: [Official Docs](https://isaac-sim.github.io/IsaacLab/)
* **NVIDIA Omniverse Forums**: [Community Support](https://forums.developer.nvidia.com/c/omniverse/)
## Project Structure
```
pair-lab-sim/
├── docker/ # Dockerfiles and container setup script
├── IsaacLab/ # Isaac Lab (cloned by gitman into this directory)
├── pair_lab/ # Main package source
│ └── source/pair_lab/ # Core simulation components
├── scripts/ # Training and evaluation scripts
│ └── rsl_rl/ # RSL-RL specific scripts
├── gitman.yml # Repository and submodule management configuration
└── README.md # This file
```
## Related Projects
* **[Isaac Sim](https://developer.nvidia.com/isaac-sim)** - NVIDIA's robotics simulation platform
* **[Isaac Lab](https://isaac-sim.github.io/IsaacLab/)** - Unified framework for robot learning
* **[RSL-RL](https://github.com/leggedrobotics/rsl_rl)** - Reinforcement learning library
* **[SO-ARM100](https://github.com/TheRobotStudio/SO-ARM100)** - Robot hardware specifications
|