|
| 1 | +.. _own-project: |
| 2 | +.. _template-generator: |
| 3 | + |
| 4 | +Build your own project or task |
| 5 | +============================== |
| 6 | + |
| 7 | +The template generator bootstraps the package structure, task registration, and |
| 8 | +agent configurations needed to start developing an Isaac Lab task. Use it to |
| 9 | +create either a standalone project outside Isaac Lab or a task intended for |
| 10 | +contribution to the Isaac Lab repository. Both options include a working |
| 11 | +Cartpole example that you can replace with your own environment. |
| 12 | + |
| 13 | +Choose what to generate |
| 14 | +----------------------- |
| 15 | + |
| 16 | +The first prompt chooses where the new task will live. |
| 17 | + |
| 18 | +.. list-table:: |
| 19 | + :widths: 22 48 30 |
| 20 | + :header-rows: 1 |
| 21 | + |
| 22 | + * - Type |
| 23 | + - Use it when |
| 24 | + - Result |
| 25 | + * - External (recommended) |
| 26 | + - You are creating an application, experiment, or reusable project outside |
| 27 | + the Isaac Lab repository. |
| 28 | + - A standalone, installable uv project using a ``src`` layout. |
| 29 | + * - Internal |
| 30 | + - You intend to contribute the task to the Isaac Lab repository. |
| 31 | + - A task package under ``source/isaaclab_tasks``. |
| 32 | + |
| 33 | +Installed Isaac Lab wheels only offer external projects. The internal option is |
| 34 | +available from a source checkout because it writes directly into that checkout. |
| 35 | + |
| 36 | +Next, choose one or more task workflows. See :ref:`feature-workflows` for the |
| 37 | +complete comparison. |
| 38 | + |
| 39 | +.. list-table:: |
| 40 | + :widths: 30 70 |
| 41 | + :header-rows: 1 |
| 42 | + |
| 43 | + * - Workflow |
| 44 | + - Good fit |
| 45 | + * - Manager-based | single-agent |
| 46 | + - Most new tasks. Observations, actions, rewards, events, and terminations |
| 47 | + remain modular and easy to replace. |
| 48 | + * - Direct | single-agent |
| 49 | + - Tasks that need custom step and reset control or a compact environment |
| 50 | + implementation. |
| 51 | + * - Direct | multi-agent |
| 52 | + - Tasks with multiple policies or agent-specific observation and action |
| 53 | + spaces. |
| 54 | + |
| 55 | +Finally, choose the RL libraries and algorithms whose configuration files you |
| 56 | +want generated. The prompt adapts the available choices to the selected |
| 57 | +workflow. See :ref:`rl-frameworks` for the framework comparison. |
| 58 | + |
| 59 | +Create and run an external project |
| 60 | +---------------------------------- |
| 61 | + |
| 62 | +First, :ref:`install Isaac Lab <isaaclab-installation-root>`. Run the generator |
| 63 | +from the Isaac Lab source checkout or from a uv project that contains the |
| 64 | +installed Isaac Lab package: |
| 65 | + |
| 66 | +.. code-block:: bash |
| 67 | +
|
| 68 | + uv run isaaclab --new |
| 69 | +
|
| 70 | +The command uses the dependencies from the active Isaac Lab environment. It |
| 71 | +does not invoke ``pip`` or install another set of template dependencies, so it |
| 72 | +also works in the pip-less virtual environments created by ``uv``. |
| 73 | + |
| 74 | +The short form is equivalent: |
| 75 | + |
| 76 | +.. code-block:: bash |
| 77 | +
|
| 78 | + uv run isaaclab -n |
| 79 | +
|
| 80 | +Select the following options for a small first project: |
| 81 | + |
| 82 | +* **External** project |
| 83 | +* A parent directory outside the Isaac Lab repository |
| 84 | +* A Python-compatible project name, such as ``my_robot_project`` |
| 85 | +* A task family name, such as ``balance`` |
| 86 | +* A robot/config name, such as ``cartpole`` |
| 87 | +* **No** Isaac Sim UI extension for a headless task package |
| 88 | +* **Manager-based | single-agent** workflow |
| 89 | +* **rsl_rl** with **PPO** |
| 90 | + |
| 91 | +The prompts display the valid options and accept numbered, comma-separated |
| 92 | +selections when more than one choice is allowed. The generator creates the |
| 93 | +project under ``<parent-directory>/<project-name>`` and initializes a Git |
| 94 | +repository there. |
| 95 | + |
| 96 | +Enter the generated project and create its environment: |
| 97 | + |
| 98 | +.. code-block:: bash |
| 99 | +
|
| 100 | + cd <parent-directory>/my_robot_project |
| 101 | + uv sync |
| 102 | +
|
| 103 | +This default environment includes the selected RL library and the kit-less |
| 104 | +Newton backend. It does **not** install Isaac Sim. |
| 105 | + |
| 106 | +List the generated task name and its available presets: |
| 107 | + |
| 108 | +.. code-block:: bash |
| 109 | +
|
| 110 | + uv run python scripts/list_envs.py --show_presets |
| 111 | +
|
| 112 | +Copy the task name from the output, then run a quick smoke test: |
| 113 | + |
| 114 | +.. code-block:: bash |
| 115 | +
|
| 116 | + uv run isaaclab random_agent --task <TASK_NAME> --num_envs 16 --viz newton |
| 117 | +
|
| 118 | +If the environment launches and the cart moves, the project is ready to edit. |
| 119 | +You can then train and play a policy with the same command surface used by |
| 120 | +Isaac Lab itself: |
| 121 | + |
| 122 | +.. code-block:: bash |
| 123 | +
|
| 124 | + uv run isaaclab train --rl_library rsl_rl --task <TASK_NAME> |
| 125 | + uv run isaaclab play --rl_library rsl_rl --task <TASK_NAME> --checkpoint latest --viz newton |
| 126 | +
|
| 127 | +Choose a simulation backend |
| 128 | +--------------------------- |
| 129 | + |
| 130 | +The default ``uv sync`` installs the kit-less Newton backend without Isaac Sim. |
| 131 | +Use a generated ``isaacsim``, ``ov``, ``ovphysx``, or ``ovrtx`` extra when a |
| 132 | +command needs that optional runtime. For example: |
| 133 | + |
| 134 | +.. code-block:: bash |
| 135 | +
|
| 136 | + uv run --extra isaacsim isaaclab random_agent \ |
| 137 | + --task <TASK_NAME> physics=isaacsim_physx |
| 138 | +
|
| 139 | +Place ``--extra`` before ``isaaclab`` and keep it on every command that needs |
| 140 | +the optional runtime. See :ref:`backends-and-presets` for the backend and preset |
| 141 | +model and :ref:`isaac-lab-quickstart` for supported physics, renderer, and |
| 142 | +visualizer combinations. |
| 143 | + |
| 144 | +.. _project-structure: |
| 145 | + |
| 146 | +Understand the generated project |
| 147 | +-------------------------------- |
| 148 | + |
| 149 | +An external project is a single installable Python package with the same |
| 150 | +standard uv ``src`` layout used by maintained downstream examples. Its root |
| 151 | +``pyproject.toml`` declares the package, development tools, backend extras, and |
| 152 | +``isaaclab.tasks`` entry point. |
| 153 | + |
| 154 | +The project name identifies the repository and Python package. Task-wide MDP |
| 155 | +terms live under the separately named task family. Robot-specific scenes, |
| 156 | +registrations, and agent configurations live under ``config/<robot-name>``. |
| 157 | +This separation lets a project add another robot configuration without copying |
| 158 | +the task MDP, or add another task family without creating another repository. |
| 159 | + |
| 160 | +Code shared by several task families can live in a package such as |
| 161 | +``tasks/mdp``. The generated task importer skips packages named ``mdp`` while it |
| 162 | +searches for task registrations, so shared modules do not register as task |
| 163 | +families. |
| 164 | + |
| 165 | +A generated project resembles: |
| 166 | + |
| 167 | +.. code-block:: text |
| 168 | +
|
| 169 | + my_robot_project/ |
| 170 | + ├── LICENSE |
| 171 | + ├── pyproject.toml |
| 172 | + ├── README.md |
| 173 | + ├── scripts/ |
| 174 | + │ └── list_envs.py |
| 175 | + ├── src/ |
| 176 | + │ └── my_robot_project/ |
| 177 | + │ ├── __init__.py |
| 178 | + │ └── tasks/ |
| 179 | + │ ├── __init__.py |
| 180 | + │ └── balance/ |
| 181 | + │ ├── mdp/ |
| 182 | + │ └── config/ |
| 183 | + │ └── cartpole/ |
| 184 | + │ ├── agents/ |
| 185 | + │ └── env_cfg.py |
| 186 | + └── tests/ |
| 187 | + └── test_registration.py |
| 188 | +
|
| 189 | +The generated package ``__init__.py`` is intentionally passive. Installing the |
| 190 | +project exposes ``my_robot_project.tasks`` through the ``isaaclab.tasks`` entry |
| 191 | +point, so importing the package for utilities does not eagerly register tasks. |
| 192 | + |
| 193 | +If you opt into the Isaac Sim UI extension, the generator additionally creates |
| 194 | +``config/extension.toml`` and ``src/my_robot_project/ui_extension_example.py``. |
| 195 | +Launch Isaac Sim with the generated ``isaacsim`` extra when using it. The |
| 196 | +default is a headless task package and does not include these files. |
| 197 | + |
| 198 | +Run commands from the project root so ``uv`` can find the package and task entry |
| 199 | +point. Commit ``pyproject.toml`` and ``uv.lock`` to give collaborators the same |
| 200 | +dependency resolution. |
| 201 | + |
| 202 | +Develop the generated task |
| 203 | +-------------------------- |
| 204 | + |
| 205 | +Start with a dummy agent before training. A zero-action agent is useful for |
| 206 | +checking resets and passive dynamics, while a random-action agent also exercises |
| 207 | +the action and observation paths: |
| 208 | + |
| 209 | +.. code-block:: bash |
| 210 | +
|
| 211 | + uv run isaaclab zero_agent --task <TASK_NAME> --num_envs 16 |
| 212 | + uv run isaaclab random_agent --task <TASK_NAME> --num_envs 16 |
| 213 | +
|
| 214 | +Edit the generated environment configuration and task terms under |
| 215 | +``src/<project-name>/tasks``. The generated package is |
| 216 | +installed in editable mode, so you do not need to reinstall it after each |
| 217 | +change. |
| 218 | + |
| 219 | +Use the remaining project commands as the task matures: |
| 220 | + |
| 221 | +.. code-block:: bash |
| 222 | +
|
| 223 | + uv run isaaclab train_multigpu --rl_library <RL_LIBRARY> \ |
| 224 | + --task <TASK_NAME> --num_gpus 2 |
| 225 | + uv run isaaclab benchmark runtime --task <TASK_NAME> \ |
| 226 | + --num_envs 16 --num_steps 1000 |
| 227 | + uv run pre-commit run --all-files |
| 228 | +
|
| 229 | +The generator includes ``tests/test_registration.py`` to verify the task IDs, |
| 230 | +environment entry points, and default agent. Its ``pyproject.toml`` installs |
| 231 | +pytest for development and registers the ``unit``, ``integration``, ``smoke``, |
| 232 | +and ``kitless`` markers. Add project-owned behavioral tests under ``tests`` and |
| 233 | +run them with: |
| 234 | + |
| 235 | +.. code-block:: bash |
| 236 | +
|
| 237 | + uv run pytest tests |
| 238 | +
|
| 239 | +The reusable-looking helpers under ``source/isaaclab_tasks/test`` belong to the |
| 240 | +Isaac Lab repository test suite and are not installed with ``isaaclab_tasks``. |
| 241 | +External projects should build their environment harness from public APIs and |
| 242 | +maintain project-local fixtures. Copying ``env_test_utils.py`` into a project is |
| 243 | +vendoring it, so the project must track upstream changes to that copy. |
| 244 | + |
| 245 | +To configure VS Code, run the generated setup task or invoke it directly: |
| 246 | + |
| 247 | +.. code-block:: bash |
| 248 | +
|
| 249 | + uv run python .vscode/tools/setup_vscode.py |
| 250 | +
|
| 251 | +Create an internal task |
| 252 | +----------------------- |
| 253 | + |
| 254 | +Choose **Internal** only when working from an Isaac Lab source checkout. The |
| 255 | +generator writes the new task into ``source/isaaclab_tasks`` instead of creating |
| 256 | +a separate project. From the Isaac Lab repository root, list and test it with: |
| 257 | + |
| 258 | +.. code-block:: bash |
| 259 | +
|
| 260 | + uv run python scripts/environments/list_envs.py --show_presets |
| 261 | + uv run isaaclab random_agent --task <TASK_NAME> --num_envs 16 |
| 262 | + uv run isaaclab train --rl_library <RL_LIBRARY> --task <TASK_NAME> |
| 263 | +
|
| 264 | +Troubleshooting |
| 265 | +--------------- |
| 266 | + |
| 267 | +**The project path is rejected** |
| 268 | + External projects must live outside the Isaac Lab repository. Enter the |
| 269 | + parent directory; the generator appends the project name automatically. |
| 270 | + |
| 271 | +**The project name is rejected** |
| 272 | + Use a valid Python identifier containing letters, numbers, and underscores, |
| 273 | + without spaces or hyphens. The name cannot begin with a number. |
| 274 | + |
| 275 | +**The task family or robot/config name is rejected** |
| 276 | + Use a valid Python identifier for each name. These names become package |
| 277 | + directories under ``src/<project-name>/tasks``. |
| 278 | + |
| 279 | +**The CLI cannot find the generated task** |
| 280 | + Run ``uv sync`` and invoke the command from the generated project root. Then |
| 281 | + confirm the task appears in ``uv run python scripts/list_envs.py``. |
| 282 | + |
| 283 | +**An optional backend module is missing** |
| 284 | + Add its extra before the command, such as ``uv run --extra ovphysx |
| 285 | + isaaclab ...`` or ``uv run --extra isaacsim isaaclab ...``. |
| 286 | + |
| 287 | +**The generator reports a missing template dependency** |
| 288 | + Current versions obtain the renderer and prompts from the Isaac Lab |
| 289 | + environment; no manual ``pip install`` is required. Update the Isaac Lab |
| 290 | + checkout or installed package and run the generator again. |
| 291 | + |
| 292 | +The generated ``README.md`` contains the same project-local commands and should |
| 293 | +be kept up to date as the project evolves. |
0 commit comments