Extending UniLab: New Terrain¶
Terrain generation is a cold-path scene feature. Keep generation and asset
materialization out of step(), reset(), and hot domain-randomization loops.
Implementation Checklist¶
Add a
SubTerrainCfgimplementation insrc/unilab/terrains/heightfield_terrains.pyif the terrain needs new heightfield geometry.Add a preset in
src/unilab/terrains/config.pywith@terrain_presetif the terrain should be selectable by name.Wire terrain into a
TerrainGeneratorCfg, either through an existing named set such asROUGH_TERRAINS_CFGor through an owner YAML underconf/.Expose terrain to scenes through
SceneCfg.terrainandTerrainSceneCfginsrc/unilab/base/scene.py.If an env needs height observations, create the backend scanner on init via
create_hfield_scanner(...); read samples through the returnedBackendHeightScanner.Keep terrain spawn, curriculum, and observation dimensions reflected in the owning env config and
obs_groups_spec.
Validation Near Risk¶
Terrain generator shape and numerical behavior:
tests/terrains/test_terrain_generator.pyRough locomotion height-scan and spawn behavior:
tests/envs/locomotion/test_go2_rough_height_scan.py,tests/envs/locomotion/test_go2_terrain_spawn.py,tests/envs/locomotion/test_terrain_spawn.pyBackend materialization boundaries:
tests/utils/test_xml_utils.py
Evidence In Repo¶
Terrain configs and presets:
src/unilab/terrains/config.pyTerrain generator:
src/unilab/terrains/terrain_generator.pyHeightfield terrain types:
src/unilab/terrains/heightfield_terrains.pyHeight-scan helper:
src/unilab/envs/locomotion/common/height_scan.py