Terrain configuration#
Motion adaptation and policy training share the terrain generator in
src/perceptive_bfm/terrains/config.py. It builds five terrain types at a
single difficulty level: flat ground, pyramid slopes and pyramid stairs,
including their inverse variants.
Terrain shapes#
MuJoCo views of the four non-flat patches. Each patch is 20 × 20 m. The ordinary variants rise toward the center; the inverse variants descend.#
Terrain |
Configuration class |
Dataset group |
Shape parameters |
|---|---|---|---|
Flat ground |
|
|
Level reference surface |
Pyramid slope |
|
|
|
Inverse pyramid slope |
|
|
Same range, |
Pyramid stairs |
|
|
|
Inverse pyramid stairs |
|
|
Same step height and width |
Slope is a gradient, not an angle. 0.3 specifies rise/run; a larger
magnitude produces a steeper surface. The inverse slope uses the same positive
range and reverses the direction through inverted=True.
Stair height and width are in meters. step_height_range sets the vertical
change per step; step_width sets the horizontal tread depth. The inverse
stair class creates descending steps with the same positive dimensions.
Parameters and where to change them#
The fixed difficulty is selected by _build_pyramid_terrain():
return _build_pyramid_terrain_grid(
num_rows=1,
slope_range=(0.3, 0.3),
step_height_range=(0.1, 0.1),
)
This is an excerpt from terrains/config.py. Edit the two range values there
to change the fixed slope or stair height. Keep each pair equal when selecting
one fixed difficulty. Patch size, tread width and the terrain-type dictionary
are configured in _build_pyramid_terrain_grid() in the same file.
The terrain classes also supply these defaults:
Parameter |
Applies to |
Default |
Effect |
|---|---|---|---|
|
Slopes and stairs |
|
Requested central platform width; stair discretization determines the final remaining width |
|
Slopes |
|
Heightfield grid spacing |
|
Slopes |
|
Height quantization |
|
Individual slopes and stairs |
|
Flat border around a patch |
|
Stairs |
|
Use complete steps rather than a cross with corner gaps |
Set these fields on the corresponding terrain configuration in
_build_pyramid_terrain_grid() when customizing them. A smaller heightfield
spacing resolves finer geometry but increases the heightfield size.
Keep reference motions and training geometry together#
After changing geometry, regenerate adapted motions and repack them into a new dataset directory using data preparation. Existing adapted motions retain the contacts and heights of the terrain used to generate them. Keeping the same group name does not make old motions match a new slope or staircase, and compatible existing output files are skipped by default.
The main adaptation entry builds the complete scene and uses each patch’s XY origin to place a motion during optimization. Saved motions have that XY offset removed while retaining absolute Z. Training and grouped replay restore the XY placement. This is why reference motions and their matching terrain must use the same geometry and height convention.
Standalone terrain scenes#
The standalone package bundles four terrain-only XMLs under
terrain_motion_adaptation/src/terrain_motion_adaptation/assets/scenes/.
Each contains one non-flat patch centered at XY zero. These files are static:
editing the main Python terrain configuration does not update them.
For standalone adaptation with custom terrain, supply a terrain-only MJCF
with a body named terrain, following the
model requirements. Use the
same scene for adaptation and motion replay.
Inspect a scene#
Export the full task scene from the repository root:
uv run python -m perceptive_bfm.scripts.export_scene \
Perceptive-PyramidTerrain-Unitree-G1-Teacher-Symmetry \
--output-dir logs/terrain_scene
To export only the ordinary stairs patch, select terrain column 3 and level
0:
uv run python -m perceptive_bfm.scripts.export_scene \
Perceptive-PyramidTerrain-Unitree-G1-Teacher-Symmetry \
--subterrain 3 0 \
--output-dir logs/terrain_stairs
Column indices follow the table above, starting with flat ground at 0.
The selected patch is centered for inspection. These exports include the task’s
robot and sensors; standalone adaptation takes a terrain-only scene.
Use a dedicated output directory that does not exist or is empty. The exporter
rejects nonempty directories and directory symlinks. With --zip, it also
rejects an existing destination archive; choose a new output path to retain
previous exports.