TerrainEntity#
TerrainEntity 是 scene.add_entity(gs.morphs.Terrain(...)) 返回的刚体实体。它唯一的固定连杆是一个高度场,即物体所停靠的高程网格,get_terrain_height 可读取其上任意位置的表面高程。用法参见 地形。
- class genesis.engine.entities.rigid_entity.terrain_entity.TerrainEntity(scene: Scene, solver: RigidSolver, idx: int, desc: RigidEntityDescription)[source]#
Bases:
RigidEntityA rigid entity whose single fixed link is a height field, authored as a grid of elevations.
Links rest on the surface those elevations define, and the stored grid answers a height query at any point.
- property terrain_hf: ndarray#
Elevation of every grid cell in meters, the vertical scale of the morph applied.
- property terrain_scale: ndarray#
Horizontal size of a grid cell in meters, and the factor the elevation is scaled by.
- get_terrain_height(positions, envs_idx=None)[source]#
Return terrain surface heights in meters at world-frame x-y positions.
Heights match the piecewise-planar surface on which rigid bodies rest. Terrain translation, yaw, and environment-specific poses are applied to the query. Positions up to one grid cell outside the terrain are clamped to its edge. Terrain tilt up to 0.001 radians from world vertical is treated as numerical noise. The query returns not-a-number (NaN) heights for positions containing NaN or infinity, positions farther outside, and terrains with greater tilt.
- Parameters:
positions (array_like) – World-frame x-y positions in meters, with shape (2,), (n_points, 2), or (n_selected_envs, n_points, 2). A two-dimensional array is shared across the selected environments; use a three-dimensional array for environment-specific positions. A leading dimension of 1 in the three-dimensional form is also treated as shared.
envs_idx (None | array_like, optional) – The indices of the environments. If None, all environments will be considered. Defaults to None.
- Returns:
heights – World-frame surface heights in meters. The point dimension is preserved except for an explicit
(2,)input, and an environment dimension is prepended in a parallelized scene.- Return type:
torch.Tensor
- Raises:
GenesisException – If the shape of
positionsis unsupported.
另见#
地形:构建地形并查询其表面高度。
Terrain(地形 morph):
gs.morphs.Terrainmorph 及其选项。