unilab.envs.locomotion.common.height_scan¶
Shared height-scan and terrain-bound helpers for rough locomotion envs.
These functions and the HeightScanConfig dataclass are consumed by Go2,
Go2W, Go1, and G1 rough environments — anywhere the policy / critic ingests
a forward-looking height grid sampled from a procedural heightfield.
Each helper mirrors the original implementation that lived inline in
go2/rough.py so that behavior is bit-for-bit identical; the only change
is the host: env classes import these instead of redefining them.
Functions
|
Estimate base-relative height by averaging the heightfield samples below the body. |
|
|
|
Clipped, scaled height observation matching the Go2 rough format. |
|
Build a contiguous (P, 2) array of (x, y) sampling offsets in body frame. |
|
Wire a yaw-aligned heightfield scanner onto |
|
Return (raw_heights (N, P), base_pos (N, 3)) or (None, None) if sensor not ready. |
|
|
|
Boolean mask: True when the body's (x, y) is outside the terrain footprint. |
Classes
HeightScanConfig(enabled: 'bool' = True, hfield_name: 'str' = 'terrain_hfield', geom_name: 'str' = 'floor', measured_points_x: 'list[float]' = <factory>, measured_points_y: 'list[float]' = <factory>, vertical_offset: 'float' = 0.5, scale: 'float' = 5.0) |
- class unilab.envs.locomotion.common.height_scan.HeightScanConfig[source]¶
Bases:
objectHeightScanConfig(enabled: ‘bool’ = True, hfield_name: ‘str’ = ‘terrain_hfield’, geom_name: ‘str’ = ‘floor’, measured_points_x: ‘list[float]’ = <factory>, measured_points_y: ‘list[float]’ = <factory>, vertical_offset: ‘float’ = 0.5, scale: ‘float’ = 5.0)
- Parameters:
- __init__(enabled=True, hfield_name='terrain_hfield', geom_name='floor', measured_points_x=<factory>, measured_points_y=<factory>, vertical_offset=0.5, scale=5.0)¶
- unilab.envs.locomotion.common.height_scan.height_scan_offsets(points_x, points_y)[source]¶
Build a contiguous (P, 2) array of (x, y) sampling offsets in body frame.
- unilab.envs.locomotion.common.height_scan.configured_height_scan_dim(scan_cfg)[source]¶
- Parameters:
scan_cfg (
HeightScanConfig)- Return type:
- unilab.envs.locomotion.common.height_scan.init_height_scan_sensor(env, scan_cfg, base_body_name)[source]¶
Wire a yaw-aligned heightfield scanner onto
env.- Sets the following attributes on
env: _height_scan_dim, _height_scan_hfield_geom_id, _height_scan_frame_body_id, _height_scan_offsets, _height_scan_sensor.
- Parameters:
env (
Any)scan_cfg (
HeightScanConfig)base_body_name (
str)
- Return type:
- Sets the following attributes on
- unilab.envs.locomotion.common.height_scan.raw_height_scan_obs(env, num_obs)[source]¶
Return (raw_heights (N, P), base_pos (N, 3)) or (None, None) if sensor not ready.
- unilab.envs.locomotion.common.height_scan.height_scan_obs(env, scan_cfg, num_obs)[source]¶
Clipped, scaled height observation matching the Go2 rough format.
- Parameters:
env (
Any)scan_cfg (
HeightScanConfig)num_obs (
int)
- Return type:
- unilab.envs.locomotion.common.height_scan.base_height_from_scan(env, num_obs=None)[source]¶
Estimate base-relative height by averaging the heightfield samples below the body.