[GitHub Code for this Chapter: chapter4
branch](https://github.com/Lab-of-AI-and-Robotics/IsaacLab-Tutorial/tree/chapter4)
To transform our basic, template-generated Cartpole environment into a sophisticated locomotion environment for the Unitree Go2. In this chapter, we will learn a critical skill for any advanced Isaac Lab developer: how to read, understand, and adapt the official, high-performance environment configurations provided within Isaac Lab's source code to build our own custom tasks.
So far, we have built a project from a template. Now, to create a high-performance locomotion agent, we will not start from scratch. Instead, we will learn from the experts: the Isaac Lab developers themselves.
We will use the official Go2 configuration file, rough_env_cfg.py
, as our "golden reference." Our goal is to systematically modify our test_env_cfg.py
to mirror the structure and logic of this professional-grade configuration. This process of refactoring is fundamental to building complex environments efficiently.
The first step is to change the foundation of our environment. The default template inherits from a generic ManagerBasedRLEnvCfg
. For locomotion, we need a more specialized base class.
test_env_cfg.py
file.class TestEnvCfg(ManagerBasedRLEnvCfg):
LocomotionVelocityRoughEnvCfg
, which is the same base class used by the official Go2 config. You will also need to add the corresponding import statement.# .../test/test/tasks/manager_based/test/test_env_cfg.py
# Add this import at the top
from isaaclab_tasks.manager_based.locomotion.velocity.velocity_env_cfg import LocomotionVelocityRoughEnvCfg
# Modify the class definition
@configclass
class TestEnvCfg(LocomotionVelocityRoughEnvCfg):
# ... (rest of the class)
This base class provides pre-configured managers and settings specifically designed for velocity-controlled locomotion tasks, saving us a tremendous amount of setup.
Now, we will perform the main refactoring. We will replace all the Cartpole-specific configurations inside TestEnvCfg
with locomotion-specific ones, using rough_env_cfg.py
as our guide.
For this step, delete the existing SceneCfg
, ActionsCfg
, ObservationsCfg
, EventsCfg
, RewardsCfg
, and TerminationsCfg
classes from your test_env_cfg.py
. We will replace them within the __post_init__
method of our main TestEnvCfg
class, just like the official example.
Modify your TestEnvCfg
class to look like this: