Documentation / @interstellar-tools/maps / safeLandingGrid
Function: safeLandingGrid()
ts
function safeLandingGrid(
grid: GridInterface,
lander: SafeLandingOptionsInterface
): GridInterface;Defined in: landing/safe-landing-grid.ts:78
Map where a lander can touch down safely on an elevation grid: where it stays upright on the slope and the ground is smooth enough.
Where:
is the cell's slope, from slopeAt - the tip-over check is isStableLanding
- TRI is the cell's terrainRoughnessIndexAt
Units
- Inputs: heights,
rFootprint,hCoMandmaxRoughnessin m,dynamicTiltin radians. - Output: a grid of the same shape: 1 where it's safe, 0 where it isn't,
NaNwhere it can't tell.
Notes
- A first screen, not a landing decision. It's static: touchdown speed, leg stroke, friction and footpads digging in or sliding all change the real limits. And it only sees what the grid sees: pick a cell size about the size of the lander's footprint, since boulders smaller than a cell don't show in its slope or roughness.
- The slope is the steepest one over each cell, so the check assumes the lander faces its weakest direction downhill. Pass the footprint distance in that direction: for four legs on a circle of radius
, . NaNon the grid's edge and next to a missing cell: a cell can only be judged with its whole 3 × 3 neighbourhood.
Parameters
| Parameter | Type | Description |
|---|---|---|
grid | GridInterface | Elevation grid, heights in m. |
lander | SafeLandingOptionsInterface | The lander: rFootprint, hCoM, maxRoughness, and optionally dynamicTilt. |
Returns
A grid of 1 (safe), 0 (unsafe) and NaN (unknown).
Throws
- If a grid size, cell size or lander value is not finite.
- If the grid's parts don't fit together,
rFootprintorhCoMis<= 0, ordynamicTiltormaxRoughnessis negative.
Example
ts
// A lander that tips at 40°, with 2° of rock-up and 0.5 m of clearance
const safe = safeLandingGrid(grid, {
rFootprint: 3.0,
hCoM: 3.6,
dynamicTilt: toRad(2),
maxRoughness: 0.5
});
gridValueAt(safe, 10, 12); // 1, 0 or NaN