# Project Generation

Isaac Lab includes a project generator that creates a fully runnable example. In
this lesson, you’ll generate the default cartpole project, and then trace how its
files define and register a reinforcement learning task.

## Prerequisites

The module uses Newton and does not require a full Isaac Sim application
installation.

#### Compute and Software
- **GPU:** one NVIDIA GPU supported by the installed PyTorch, Warp, and Newton
  versions, with a CUDA 13-compatible driver. The module uses Newton GL for
  recording; optional RTX rendering also requires compatible ovrtx plugins.
- **Operating system and tools:** Ubuntu 22.04 or 24.04 x86-64 for the Bash
  commands as written, Python 3.12, Git, and `uv`. Isaac Lab also supports
  Windows 11, though you’ll need to adapt the shell commands. If your computer
  doesn’t have a compatible GPU, you can connect to a remote GPU host.
- **Storage:** writable space for dependencies, assets, caches, checkpoints, and
  recordings. Use persistent storage for outputs on a temporary remote machine.

## Choose Where to Run

Use a local workstation or connect to a remote GPU host. Install Git and
[uv](https://docs.astral.sh/uv/getting-started/installation/) on that machine.

In your terminal, check that the tools and GPU are available.

```bash
git --version
uv --version
nvidia-smi
```

Confirm the expected GPU and available memory. A working call to `nvidia-smi` confirms
driver access; the lesson’s simulation and training checks will verify the
installed runtime. See [Development Workflow for Isaac Lab](https://docs.nvidia.com/learning/physical-ai/getting-started-with-isaac-lab/2026-11.3/isaac-lab-basics/03-development-workflow.md)
for remote access, editor setup, and keeping experiment outputs.

## GPU Requirements

Check the [Isaac Lab installation requirements](https://isaac-sim.github.io/IsaacLab/v3.0.0/source/isaaclab/installation.html#system-requirements)
and [OVRTX driver requirements](https://nvidia-omniverse.github.io/ovrtx/driver_requirements.html)
for your GPU and operating system.

The short cartpole training run starts with 64 environments. The default
cartpole configuration uses 4,096 environments. If training runs out of memory,
try reducing `--num_envs` and repeating a short run. Keep a note of the change,
since it affects how much experience is collected per iteration.

## Prepare Isaac Lab

Create a workspace and install Isaac Lab from the `v3.0.0` release tag.

```bash
mkdir isaac-lab-workspace
cd isaac-lab-workspace
git clone --branch v3.0.0 --depth 1 https://github.com/isaac-sim/IsaacLab.git
cd IsaacLab
uv sync
```

Cloning and synchronizing can take several minutes. If setup fails on your
workstation, use the installation guide to check your host, driver, and
prerequisites before continuing.

## Generate a New Project

From the Isaac Lab directory, start the project generator:

```bash
uv run isaaclab --new
```

Respond to the prompts as follows. Press **Enter** to use a displayed default.

1. `Task type [External/Internal]:`  `external`

   An external project is an independent, installable Python project. Use an
   internal task only when contributing a task directly to the Isaac Lab source
   repository.
2. `Project path (...):`  `../`

   This places the generated project beside the Isaac Lab directory.
3. `Project name:`  `isaac_lab_tutorial`

   The name becomes both the project directory and the top-level Python package.
   It must be a valid Python identifier, so use letters, numbers, and underscores
   without spaces or hyphens.
4. `Author name(s), comma-separated:`  `YOUR NAME`

   The generator adds your name to the `pyproject.toml` metadata.
5. `Initial project content [Cartpole/Stubbed/Blank] (Cartpole):` Press **Enter**.

   The generator creates a runnable cartpole example with a default
   configuration. A blank project would contain only the package structure and
   no task code.
6. `Task family name (balance):` Press **Enter**.

   Keep the default `balance` task family. A task family holds behavior that can
   be shared by more than one robot configuration.
7. `Robot/config name (cartpole):` Press **Enter**.

   Keep the default `cartpole` configuration. This lesson uses the runnable
   cartpole example exactly as generated.
8. `Include Isaac Sim UI extension [No/Yes] (No):` Press **Enter**.

   The task does not need a custom panel in the Isaac Sim Extension Manager.
9. `Isaac Lab workflow: Enter comma-separated numbers:`  `1`

   Select **Manager-based | single-agent**. This workflow keeps actions,
   observations, reset events, rewards, and terminations in separate
   configuration sections.
10. `RL library: Enter comma-separated numbers:`  `1`

    The module uses [RSL-RL](https://leggedrobotics.github.io/rsl_rl/) for its
    training commands and agent configurations.
11. `RL algorithms for rsl_rl: Enter comma-separated numbers:`  `1`

    Select **PPO**. The generator creates the agent configuration used to train a
    policy later; no training is required in this lesson.

After the final response, the generator validates the specification, writes the
project, and initializes a Git repository:

```text
Validating specification...
Generating external project...
  |-- Copying repo files...
  |-- Copying utility scripts...
  |-- Generating tasks...
...
```

The generator creates `isaac_lab_tutorial` beside the Isaac Lab directory.

Create the generated project’s environment with the matching Isaac Lab
checkout.

```bash
cd ../isaac_lab_tutorial
uv sync
```

To generate the same project in one command, run this from the Isaac Lab
directory in place of the interactive generator. Replace `YOUR NAME` with
your name. If you already generated the project, continue to the simulation.

```bash
printf '%s\n' external ../ isaac_lab_tutorial 'YOUR NAME' '' '' '' '' 1 1 1 | uv run isaaclab --new
```

## Run Your First Simulation

Before touring the files, run a short check with zero actions from the
generated project root. Choose a viewer or run without one.

### GPU Workstation

```bash
uv run isaaclab zero_agent                 \
  --task IsaacLabTutorial-Balance-Cartpole \
  --num_envs 16                            \
  --max_steps 300                          \
  --visualizer newton
```

The Newton OpenGL viewer opens on your desktop.

### Headless

```bash
uv run isaaclab zero_agent                 \
  --task IsaacLabTutorial-Balance-Cartpole \
  --num_envs 16                            \
  --max_steps 300                          \
  --visualizer none
```

Use this command on a GPU host to check the simulation through terminal output.

### Browser Viewer

```bash
uv run isaaclab zero_agent                 \
  --task IsaacLabTutorial-Balance-Cartpole \
  --num_envs 16                            \
  --max_steps 300                          \
  --visualizer viser
```

Open the URL that Viser prints. If you run the simulation on a remote GPU
host, forward the printed port over SSH and open the forwarded address in your
local browser. See [Forward the Port Over SSH](https://docs.nvidia.com/learning/physical-ai/getting-started-with-isaac-lab/2026-11.3/isaac-lab-basics/03-development-workflow.md#forward-the-port-over-ssh).
If the simulation finishes before you open the viewer, rerun the command with
a larger `--max_steps` value. Refresh the viewer after starting a new simulation.

- `--task TASK` selects the generated cartpole environment by its registered task ID.
- `--num_envs 16` creates sixteen cartpole environments that step in parallel.
- `--max_steps 300` limits the run to 300 simulation steps, then exits.
- `--visualizer` selects the desktop viewer (`newton`), browser viewer
  (`viser`), or terminal-only run (`none`).

Expect the poles to fall or swing as the simulation applies zero actions. A
clean exit and printed action and observation spaces show that the simulation
can step.

## Tour the Generated Project

The default external cartpole project follows this structure. Some supporting
files are omitted so you can focus on the task package:

```text
isaac_lab_tutorial
├── pyproject.toml
└── src
    └── isaac_lab_tutorial
        ├── assets
        │   ├── __init__.py
        │   └── data
        └── tasks
            ├── __init__.py
            └── balance
                ├── config
                │   └── cartpole
                │       ├── __init__.py
                │       ├── agents
                │       │   └── rsl_rl_ppo_cfg.py
                │       └── env_cfg.py
                └── mdp
                    ├── __init__.py
                    └── rewards.py
```

#### NOTE
You don’t need to understand every file yet. Start with the three main
components described below. Many files contain only a small amount of code, and
you can return to the rest as you work through the lessons.

The folder names come from the generator: `isaac_lab_tutorial` is the project,
`balance` is the task family, and `cartpole` is the robot/config name.

The main components have distinct responsibilities:

- `pyproject.toml` defines the installable package, dependencies, optional
  backends, development tools, and the `isaaclab.tasks` entry point used for
  task discovery.
- `mdp/` holds the balance task behavior (the Markov decision process, or MDP,
  terms such as rewards) that can be shared by more than one configuration. The
  generated `rewards.py` contains the cartpole pole-angle reward function.
- `cartpole/` holds the task registration, environment configuration, and agent
  configuration for the cartpole system.

Open `pyproject.toml` and give it a quick read. Its `isaaclab.tasks` entry point
exposes `isaac_lab_tutorial.tasks` to Isaac Lab (when the task package is loaded,
`config/cartpole/__init__.py` registers `IsaacLabTutorial-Balance-Cartpole`).

Gymnasium registration connects three pieces (found in `env_cfg.py` and
`rsl_rl_ppo_cfg.py`) to the task ID:

1. `ManagerBasedRLEnv`, the Isaac Lab environment implementation.
2. `BalanceEnvCfg`, the task configuration.
3. `PPORunnerCfg`, the default RSL-RL agent configuration.

![The generated env_cfg.py separates the cartpole task into simulation configuration, agent inputs and outputs, and episode logic. BalanceEnvCfg assembles the physics, scene, actions, observations, events, rewards, and terminations and sets the environment count, episode length, simulation time step, and control decimation.](images/cartpole-template-code-flow.svg)

The `env_cfg.py` file defines the following *configuration* classes:

- `BalancePhysicsCfg` defines Newton MJWarp as the default physics backend.
- `BalanceSceneCfg` creates the ground plane, light, and cartpole articulation.
- `ActionsCfg` connects actions to the cart’s `slider_to_cart` joint.
- `ObservationsCfg` defines policy inputs from joint positions and velocities.
- `EventCfg` randomizes the cart and pole positions and velocities at reset.
- `RewardsCfg` defines reward-shaping components for the cartpole.
- `TerminationsCfg` ends an episode after a time limit or bounds violation.
- `BalanceEnvCfg` assembles everything into an environment.

Most reward functions used in `RewardsCfg` come from [Isaac Lab’s reusable MDP
library](https://isaac-sim.github.io/IsaacLab/v3.0.0/source/api/lab/isaaclab.envs.mdp.html#module-isaaclab.envs.mdp).
The generated project also includes one task-specific function in `rewards.py`,
`joint_pos_target_l2`, that reads a configured joint position, wraps angular
values to the interval from `-pi` to `pi`, and returns the squared distance from
a target.

Back in `RewardsCfg`, you can see how this function is applied to `cart_to_pole`
with a target of zero and a weight of `-1.0`. As the pole tilts farther from
upright, the penalty grows quadratically, which lowers the reward.

Finally, inspect the learning configuration in `rsl_rl_ppo_cfg.py`.
`PPORunnerCfg` is separate from the environment because the task dynamics and
the learning algorithm have different responsibilities. It defines the actor and
critic networks, rollout length, learning rate, discount factor, PPO clip
parameter, update schedule, checkpoint interval, and training budget. You can
keep a second learning configuration alongside the generated one.

## Making Changes

```text
src/isaac_lab_tutorial/tasks/balance/
├── mdp/             # Shared task behavior; reuse across configurations.
└── config/
    └── cartpole/    # Scene, environment, registration
        └── agents/  # Learning-library settings
```

You are free to manage your project as you like, but the generated structure is
designed to keep changes in the smallest scope that owns them. The task family
holds shared behavior, while each robot configuration holds its own environment
and agent settings.

When extending the template project (or creating your own project from scratch):

- Add a new robot for the same task as a sibling under `config/` so it can
  reuse the task-family logic.
- Add a different task as a new sibling under `tasks/` so it can own its own
  task terms.
- Put behavior shared by configurations in the task family’s `mdp/` package.
- Keep learning-library configuration in the robot/config `agents/` directory.
- Keep task registration and the assembled environment configuration in
  `config/cartpole/`.
- Update `pyproject.toml` only for project-wide dependencies, tooling, or task
  discovery.

An expanded project might look like this (`another_robot` and `another_task`
are placeholder names):

```text
src/isaac_lab_tutorial/tasks/
├── balance/
│   ├── mdp/                     # Behavior shared by balance configurations
│   └── config/
│       ├── cartpole/            # Existing robot configuration
│       │   └── agents/          # Learning-library settings
│       └── another_robot/       # New robot for the same task
│           └── agents/          # Learning-library settings for this robot
└── another_task/                # Different task family
    ├── mdp/                     # Behavior owned by this task family
    └── config/
        └── another_robot/       # Robot configuration for this task
            └── agents/          # Learning-library settings for this task
```

## Troubleshooting

- If the generator rejects a name, use a valid Python identifier with no spaces
  or hyphens.
- On a workstation, if dependency synchronization fails, confirm that you are
  in the generated project root and that the sibling Isaac Lab checkout
  completed `uv sync`.

## Review

### Check Your Understanding

Does discovering a registered task ID prove the environment can step?

### Answer

No. Discovery verifies that the task is registered. A simple agent can be used
to check that the environment can be constructed and stepped.

### Apply What You Learned

How would you determine whether a failed cartpole run has a registration problem
or an environment-configuration problem? Describe the checks you would make, the
files or outputs you would inspect, and what each check establishes.

### <svg version="1.1" width="1.0em" height="1.0em" class="sd-octicon sd-octicon-dependabot" viewBox="0 0 16 16" aria-hidden="true"><path d="M5.75 7.5a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0v-1.5a.75.75 0 0 1 .75-.75Zm5.25.75a.75.75 0 0 0-1.5 0v1.5a.75.75 0 0 0 1.5 0v-1.5Z"></path><path d="M6.25 0h2A.75.75 0 0 1 9 .75V3.5h3.25a2.25 2.25 0 0 1 2.25 2.25V8h.75a.75.75 0 0 1 0 1.5h-.75v2.75a2.25 2.25 0 0 1-2.25 2.25h-8.5a2.25 2.25 0 0 1-2.25-2.25V9.5H.75a.75.75 0 0 1 0-1.5h.75V5.75A2.25 2.25 0 0 1 3.75 3.5H7.5v-2H6.25a.75.75 0 0 1 0-1.5ZM3 5.75v6.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-6.5a.75.75 0 0 0-.75-.75h-8.5a.75.75 0 0 0-.75.75Z"></path></svg> Agent Tutor Prompt

Copy this prompt and include your answer:

> Review my answer to this question: How would you determine whether a failed cartpole run has a registration problem or an environment-configuration problem? Describe the checks you would make, the files or outputs you would inspect, and what each check establishes.

> My answer: [paste your answer here].

> Check my reasoning about task id, environment and agent entry points, relevant files, and what each diagnostic check establishes. Ask for missing context rather than assuming it. Identify what I explained well, point out one gap or misconception, and ask a follow-up question that helps me improve my answer. Let me revise it before supplying a complete answer.

### Key Takeaways

- The generated external project lives beside the Isaac Lab directory.
- A short zero-action run checks the simulation before you study the code.
- Registration connects a task ID to environment and learning configurations.

### Resources

- [Build Your Own Project or Task](https://isaac-sim.github.io/IsaacLab/v3.0.0/source/developer-tools/template_generator.html) — Instructions for using the template generator to create an external project or an internal Isaac Lab task.
