# Creating Custom Training Environment in IsaacLab via Extensions

As mentioned in the "Dive Into IsaacLab" article, the codebase of IsaacLab is significantly larger than other RL frameworks.

{% content-ref url="/pages/9HDHm9escyJWdVFJ7mYl" %}
[Case Study: A Dive Into IsaacLab](/notes/ml-rl/rl-frameworks/case-study-a-dive-into-isaaclab.md)
{% endcontent-ref %}

It provides a nice abstraction of configuration fragments using the Config class and the notion of Managers. However, this makes editing the environment and implementing custom training logic harder. Jumping across directory structures to access config fragments is common and annoying.

Fortunately, IsaacLab also supports [Extensions](https://isaac-sim.github.io/IsaacLab/source/overview/developer-guide/template.html), which allows us to isolate out the custom scripts into a separate repository. In this article, we will go over how to create such extension and achieve custom training logic.

## Cloning the extension template

```bash
git clone https://github.com/isaac-sim/IsaacLabExtensionTemplate.git
cd ./IsaacLabExtensionTemplate/
```

## Rename the template

We can rename the template to a custom extension name. Here, we will use `g1_demo` as an example:

```bash
python scripts/rename_template.py g1_demo
```

<figure><img src="/files/BkEMqBojPMK3oP7o0OPZ" alt=""><figcaption></figcaption></figure>

After executing this command, all the `ext_template` text inside this repo should be replace to `g1_demo`.

## Configure the tasks

We start off by copying the scripts directly from upstream IsaacLab

There's a few difference between the scripts used in IsaacLab versus in the Extension.

{% code title="velocity\_env\_cfg.py" %}

```python
# IsaacLab
import omni.isaac.lab_tasks.manager_based.locomotion.velocity.mdp as mdp

# Extension
import g1_demo.tasks.locomotion.velocity.mdp as mdp
```

{% endcode %}

{% code title="train.py & play.py" %}

```bash
# IsaacLab
import omni.isaac.lab_tasks  # noqa: F401

# Extension
import g1_demo.tasks  # noqa: F401
```

{% endcode %}


---

# Agent Instructions: 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:

```
GET https://tk233.gitbook.io/notes/ml-rl/setting-up-nvidia-tools/creating-custom-training-environment-in-isaaclab-via-extensions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
