Skip to content

docs(nav): spec the belief-material controller (GRL-SNAM#141's twin) - #1053

Merged
transfix merged 1 commit into
masterfrom
docs/nav-belief-material-controller
Nov 8, 2026
Merged

transfix merged 1 commit into
masterfrom
docs/nav-belief-material-controller

Conversation

@transfix

@transfix transfix commented Nov 8, 2026

Copy link
Copy Markdown
Owner

This is the spec for the C++ twin of GRL-SNAM's range-limited belief-material controller (CVC-Lab/GRL-SNAM#141, grl_snam/belief_material_controller.py). The goal is that a .cvcnm v2 net trained by grl-snam austin-material-train drives in C++ and makes the same decisions. It is a spec only; there is no code here. It stops here so the design can be reviewed before C1.

New: docs/roadmap/NAV-BELIEF-MATERIAL-CONTROLLER-ROADMAP.md. NAV-BELIEF-MATERIAL-ROADMAP.md §6 and NAV_MATERIAL.md each gain a link to it.

What it pins

  1. The meta contract (grl_snam.belief_material: feature_frame, feature_scale_m, k_sharp, d_hat_sdf_m, material_gate_trigger, geometry_d_hat_m).
    • It is parsed as from_meta parses it: missing fields take their defaults, and an unknown field or no record is refused.
    • The header check (from_cvcnm) runs against belief_material_params and the patch settings, and the runtime check (check_runtime) against material_config. Each reports all mismatches.
    • material_config_for(contract, ..., cell_w) builds a passing config. It includes Python's 25 m gate horizon in cells; libcvc's default of 12 cells would look 180 m ahead on the Austin 15 m grid.
  2. The tokens.
    • Robot-relative, divided by feature_scale_m, with the f32 operation order spelled out. They are BIT except dist, which is within 1 ulp (numpy's norm may go through BLAS).
    • The crop is centred on the float32 position, as Python's is.
    • A twin of the obstacle source both Austin tools use (scan_visible_geometry), with a tie-order fix proposed.
  3. decide. lam_soft is predicted if the gate is active and 0 if not. With the gate disabled it is fail-open, and lam_hard is never gated. The gate bit is BIT; the coefficients are FLOAT (the forward's tier). The predicted and effective coefficients are both returned.
  4. sim_world. set_material_controller attaches on belief material only.
    • Mode lam: the net's lambdas next to the coef_mlp's alpha/beta/gamma, the twin of live_material_kwargs.
    • The goal is clipped to 30 m and shared by the token and the gate.
    • decide_every sets the decision cadence, and the force-bias scale still applies.
    • Mode full (all six coefficients) is deferred to C4.
  5. Goldens generated from the Python reference (G1–G7): a GRL-SNAM generator, committed here, with a byte-compare test on the GRL-SNAM side.

Open decisions (§9)

  • E1: the sim_world mode;
  • E2: the local goal;
  • E3: the obstacle source with shared planes;
  • E4: the cadence;
  • E5: the tie order;
  • E6: the contract's value types;
  • E7: the tolerances;
  • E8: lam-head coef_mlp refusal;
  • E9: the scale after the gate;
  • E10: the constants the contract does not pin.

Work breakdown

  • libcvc: C1 (contract, checks, tokens, obstacles; BIT goldens), C2 (decide, rollout; FLOAT goldens), C3 (sim_world, mode lam), C4 (mode full, later).
  • GRL-SNAM: T-a (the golden generator), T-b (stable sort, stricter contract types).
  • cvcdbg follows C3.

GRL-SNAM#141 added BeliefMaterialController on top of the belief kernels
libcvc already has. This spec covers its C++ twin, before any code:

- the grl_snam.belief_material contract in a .cvcnm's meta, and the
  header and runtime refusals built on it;
- the robot-relative obstacle and goal tokens, and the obstacle source
  both Austin tools use;
- decide: the witness gate switching lam_soft;
- coef_energy_net per agent inside sim_world, next to the coef_mlp
  (lam mode) or, later, instead of it;
- goldens generated from the Python reference.

Open decisions E1-E10 are in its section 9.
@transfix
transfix merged commit ea1661c into master Nov 8, 2026
16 of 28 checks passed
@transfix
transfix deleted the docs/nav-belief-material-controller branch November 8, 2026 06:46
transfix added a commit to CVC-Lab/GRL-SNAM that referenced this pull request Nov 9, 2026
…stacles sort stably (#163)

libcvc is twinning the belief-material controller (transfix/libcvc#1053, its
NAV-BELIEF-MATERIAL-CONTROLLER-ROADMAP.md). Joe settled its two Python-side
decisions:

- E6: BeliefMaterialContract accepts only a string frame and real numbers.
  "5", true and null were stored as given; they are now refused. Integers are
  stored as floats, so to_meta writes 20.0 for a file that said 20, as the
  C++ to_meta does.
- E5: scan_visible_geometry sorts by distance with kind="stable". Equal
  distances keep argwhere's row-major order, so the max_obstacles cutoff picks
  the same set on both sides. numpy's default sort is unstable on arrays of
  more than 16 entries. On the new test's 9 x 9 ring it picks a different
  cell at the cutoff.

No committed result changes. There is no trained Austin checkpoint, and the
route corpus does not depend on the obstacle order.
transfix added a commit to CVC-Lab/GRL-SNAM that referenced this pull request Nov 9, 2026
T-a of libcvc's NAV-BELIEF-MATERIAL-CONTROLLER-ROADMAP.md (transfix/libcvc#1053,
§6): the Python controller is the reference. The generator writes
belief_material_controller_golden.{json,cvcnm}. libcvc commits them in
src/cvc/tests/data, and its C1 test reproduces every case.

Run python -m grl_snam.tools.belief_material_controller_golden --out DIR.
It covers the C1 cases (the spec's G1-G5):

- contract: 28 meta strings through from_meta. Accepted ones record the parsed
  values and to_meta(); refused ones record only the refusal.
- header_check: the golden .cvcnm against 12 belief/patch settings. Each
  records the fields the refusal names: one field each, one case with two, and
  two within the 1e-6 tolerance.
- runtime_check: 6 material_config constant sets (float32 k_sharp/d_hat, as
  libcvc holds them).
- material_config_for: the gate horizon and margin MaterialRuntime derives on
  8 cell widths.
- obstacles: scan_visible_geometry after each agent's sense tick on the
  belief golden's scene (max_obstacles 36 and 5), plus a 9 x 9 scene of equal
  distances.
- tokens: build_belief_material_controller_inputs for 3 belief cases x 3 ticks
  x 3 agents, plus a 7.5 m scale and a no-obstacle variant.

Float32 values are written as raw bits. The net (d_tok 16, 1 layer, P 9 over
36 m) takes its weights from numpy's PCG64 stream, so the file does not depend
on torch's initialisers. The test regenerates both files and compares bytes
with tests/fixtures. .gitattributes keeps git from converting their line
endings.

C2 adds decide and rollout (G6-G7).
transfix added a commit to CVC-Lab/GRL-SNAM that referenced this pull request Nov 9, 2026
…164)

T-a of libcvc's NAV-BELIEF-MATERIAL-CONTROLLER-ROADMAP.md (transfix/libcvc#1053,
§6): the Python controller is the reference. The generator writes
belief_material_controller_golden.{json,cvcnm}. libcvc commits them in
src/cvc/tests/data, and its C1 test reproduces every case.

Run python -m grl_snam.tools.belief_material_controller_golden --out DIR.
It covers the C1 cases (the spec's G1-G5):

- contract: 28 meta strings through from_meta. Accepted ones record the parsed
  values and to_meta(); refused ones record only the refusal.
- header_check: the golden .cvcnm against 12 belief/patch settings. Each
  records the fields the refusal names: one field each, one case with two, and
  two within the 1e-6 tolerance.
- runtime_check: 6 material_config constant sets (float32 k_sharp/d_hat, as
  libcvc holds them).
- material_config_for: the gate horizon and margin MaterialRuntime derives on
  8 cell widths.
- obstacles: scan_visible_geometry after each agent's sense tick on the
  belief golden's scene (max_obstacles 36 and 5), plus a 9 x 9 scene of equal
  distances.
- tokens: build_belief_material_controller_inputs for 3 belief cases x 3 ticks
  x 3 agents, plus a 7.5 m scale and a no-obstacle variant.

Float32 values are written as raw bits. The net (d_tok 16, 1 layer, P 9 over
36 m) takes its weights from numpy's PCG64 stream, so the file does not depend
on torch's initialisers. The test regenerates both files and compares bytes
with tests/fixtures. .gitattributes keeps git from converting their line
endings.

C2 adds decide and rollout (G6-G7).
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