Skip to content

nav: every length and force in the state tree is in world units - #824

Merged
transfix merged 2 commits into
masterfrom
fix/nav-tree-world-units
Oct 27, 2026
Merged

transfix merged 2 commits into
masterfrom
fix/nav-tree-world-units

Conversation

@transfix

@transfix transfix commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #823 (base docs/nav-key-tooltips); I'll retarget it to master when #823 merges.

Why

The state tree is meant to hold world units: metres and seconds, whatever config.scale is or how big the map's cells are. An audit of every key sim_world binds found six that didn't.

  • nav.sep_gain: the carrot shift at contact, a length in the normalized frame, passed through unconverted.
  • nav.terrain.sigma: the grade cost's blur, passed through in grid cells.
  • The material and terrain force weights: lam_soft, lam_hard, lam_grade and lam_grade_hard were in the drive's normalized acceleration units. The soft weights multiply a risk gradient taken per normalized unit, so their world size goes as 1/scale². The barrier weights multiply a unit direction, so theirs goes as 1/scale.

nav_plant's keys were already consistent: lengths and speeds go through world_units, and accelerations are SI.

A separate bug: with block_infeasible on, turning it off (or loosening the limit) left the formerly infeasible cells as obstacles until the next sense tick. With freeze_sense there is never a sense tick, so they stayed forever.

What

Units (sim_world_binding.cpp):

Key Unit now Conversion
nav.sep_gain m × 1/scale
nav.terrain.sigma m × cell width
nav.material.lam_hard, nav.terrain.lam_grade_hard m/s² ÷ scale
nav.material.lam_soft, nav.terrain.lam_grade m²/s² ÷ scale²
  • The m²/s² weights read as the push in m/s² per unit of risk or grade cost gained per metre.
  • The multipliers lam_soft_scale and lam_hard_scale stay plain ratios.
  • Descriptions and ranges follow. Defaults given in normalized units are no longer quoted.
  • docs/PHYSICS_API.md lists the conversions.

Freed cells leave at once: set_terrain_config now recomposites every plane's occupancy from its log-odds, via a new private recomposite_occupancy(), whenever infeasible cells were blocking. A frozen map's log-odds hold its prior, so that works for it too.

Nothing inside the library changes. The structs keep their units, and only the tree's view of them changes.

Tests

  • NavBinding.EveryLengthIsInMetres: scale 0.05 with 2 m cells. sep_gain and sigma are seeded in metres, applied converted, and stable across pulls.
  • NavBinding.MaterialWeightsAreKnobsOnceAMaterialIsSet and TerrainSettingsRebuildThePlanes: now check the weights' world units.
  • NavTerrain.CellsTheTerrainFreesLeaveTheMapAtOnce: on a frozen map, the field is rebuilt as soon as block_infeasible is turned off, and an agent held short of a ramp then crosses it.

Ran locally (Windows, MSVC, no CUDA) and all pass: nav_binding (6), nav_terrain (11), nav_material (33), nav (62).

nav.sep_gain (the carrot shift at contact) and nav.terrain.sigma (the grade cost's blur, kept in cells) crossed the tree unconverted: the first in the normalized frame, the second in cells. Both are metres now. The material and terrain force weights are in world units too: lam_hard and lam_grade_hard (a barrier's full push) in m/s^2, lam_soft and lam_grade (the push per unit of risk or grade cost gained per metre) in m^2/s^2.

set_terrain_config recomposites the occupancy at once when infeasible cells were blocking, so cells it frees (block_infeasible off, a looser limit) leave the map now, a frozen one's too, not at the next sense tick (never, with freeze_sense).
@transfix
transfix changed the base branch from docs/nav-key-tooltips to master October 27, 2026 04:04
transfix added a commit that referenced this pull request Oct 27, 2026
@transfix
transfix enabled auto-merge (squash) October 27, 2026 05:39
@transfix
transfix merged commit 0eb0ec7 into master Oct 27, 2026
19 of 24 checks passed
@transfix
transfix deleted the fix/nav-tree-world-units branch October 29, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant