Imported from yongkanghui75-a11y/LeggedGym-Ex (
legged_gym/AGENTS.md). Install upstream withnpx skills add yongkanghui75-a11y/LeggedGym-Ex --skill legged_gym. Copyright stays with the author.
LEGGED_GYM CORE FRAMEWORK
Core legged robot RL framework with multi-simulator support (Genesis, IsaacGym, IsaacLab).
STRUCTURE
| Directory | Purpose |
|---|---|
envs/ |
Robot environments extending LeggedRobot |
scripts/ |
Training and inference entry points |
utils/ |
Terrain generation, task registry, math utilities |
simulator/ |
Simulator abstraction layer |
KEY FILES
| Purpose | File |
|---|---|
| Training entry | scripts/train.py |
| Inference | scripts/play.py |
| Base environment | envs/base/legged_robot.py |
| Config system | envs/base/legged_robot_config.py |
| Task registry | utils/task_registry.py |
| Terrain generation | utils/terrain.py |
| Math utilities | utils/math_utils.py |
| Simulator ABC | simulator/simulator.py |
CONVENTIONS
Config Pattern: Nested classes with class env, class rewards, class commands, etc.
class MyRobotCfg(LeggedRobotCfg):
class env:
num_observations = 48
class rewards:
class scales:
tracking_lin_vel = 1.0
Task Registration: Add to envs/__init__.py:
task_registry.register("robot_name", RobotClass, Cfg, CfgPPO)
Simulator Selection: export SIMULATOR=genesis|isaacgym|isaaclab
ANTI-PATTERNS
- Observation Changes: Modifying
obs_bufrequires updating ALL_reward_*methods - IsaacGym Reset Bug: After
reset(), callself.simulator.forward()before reading rigid body states - IsaacLab CPU Tensors: Domain randomization tensors must be on CPU (
set_material_properties,set_masses,set_coms) - Genesis XML: Must provide XML file path when using Genesis simulator
- Terrain Flags: Cannot use
curriculum=Truewithselected=Truesimultaneously - IsaacLab Heightfield: Heightfield terrain not implemented for IsaacLabSimulator
PATTERNS
Type Aliases: ObsBuf = Tensor, Action = Tensor, Reward = Tensor in base classes
Config Validation: Extensive assertions in LeggedRobot.__init__() catch config errors early
Debug Flags: cfg.env.debug* enable visualization (height points, depth images, etc.)
