Repository navigation
belief-material controller: the golden libcvc's C++ twin reproduces - #164
Merged
Merged
Conversation
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
force-pushed
the
feat/belief-material-controller-golden
branch
from
November 9, 2026 01:18
e6c3adb to
bde7b6d
Compare
transfix
changed the base branch from
fix/belief-material-stable-strict
to
main
November 9, 2026 01:18
transfix
added a commit
to transfix/libcvc
that referenced
this pull request
Nov 9, 2026
* nav: the belief-material controller's contract and inputs (C1)
C1 of docs/roadmap/NAV-BELIEF-MATERIAL-CONTROLLER-ROADMAP.md: the C++ twin of
GRL-SNAM's BeliefMaterialController, up to the model inputs. Joe settled
decisions E1-E10 on the recommended column ("Yes, start C1"), and the spec now
records them as settled.
inc/cvc/nav/belief_material_controller.h (built with -ffp-contract=off):
- belief_material_contract: the .cvcnm meta record (grl_snam.belief_material).
from_meta parses it with a small JSON reader that behaves like Python's
json.loads: NaN/Infinity, last duplicate key wins, locale-free numbers. It
accepts only JSON numbers and a string frame (E6). to_meta writes
byte-for-byte what Python's json.dumps(sort_keys=True) writes, using Python's
float repr.
- belief_header_mismatches: the .cvcnm v2 belief block against the belief and
patch settings, within 1e-6 (E7).
- belief_runtime_mismatches: a material_config against the contract.
- material_config_for: the config a contract implies on a grid. The gate
horizon is Python's 25 m rounded half-even to cells; libcvc's 12-cell
default would look 180 m ahead on the Austin 15 m grid.
- belief_material_controller: a loaded net that passed those checks, with
check_runtime.
- build_belief_material_controller_inputs: robot-relative float32 tokens in
numpy's operation order, and the 3-channel patch centred on the float32
position.
- visible_obstacles: the twin of scan_visible_geometry. Equal distances are
kept in row-major order (E5).
The golden (G1-G5) is written by GRL-SNAM
(grl_snam.tools.belief_material_controller_golden, CVC-Lab/GRL-SNAM#164, on
#163's E5/E6 changes) and committed in src/cvc/tests/data.
nav_belief_material_controller_test reproduces it bit for bit; the goal
token's dist may differ by 1 ulp because numpy's norm can go through BLAS. The
planes the tokens are cropped from hash to belief_material_golden.json's
values, so they are libcvc's own belief planes.
pycvc gains nav_belief_material_contract, nav_belief_material_contract_to_meta,
nav_belief_material_check_cvcnm, nav_visible_obstacles and
nav_belief_material_controller_inputs; refusals raise ValueError.
test_pycvc_nav_belief_controller.py checks them against the same golden.
* nav: keep a JSON object's keys and values in parallel vectors
clang-tsan's build (clang with libstdc++ 13) refused json_value's
std::vector<std::pair<std::string, json_value>>: the pair needs json_value
complete inside its own definition. A vector of an incomplete type is fine
in C++17, so the object now holds obj_keys and obj_vals side by side.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is T-a of libcvc's belief-material controller spec (transfix/libcvc#1053,
docs/roadmap/NAV-BELIEF-MATERIAL-CONTROLLER-ROADMAP.md§6). The Python controller is the reference: this generator writes the golden, libcvc commits it insrc/cvc/tests/data, and libcvc's C1 PR reproduces every case.Stacked on #163 (E5's stable obstacle order and E6's strict contract types), since the golden pins both. Once #163 merges, GitHub retargets this PR to
main.Usage:
python -m grl_snam.tools.belief_material_controller_golden --out DIRwritesbelief_material_controller_golden.json(336 KB) andbelief_material_controller_golden.cvcnm(241 KB). It covers the C1 cases (G1–G5 in the spec):contractmetastrings throughfrom_meta: defaults, partial and integer records, repr edge cases (1e+16,5e-324,0.0001,9999999999999998.0), other keys withNaN/-Infinity, a duplicate key, then 18 refusalsto_meta(); refused: only that it was refusedheader_check.cvcnmagainst 12 belief/patch settings: one field each, one case with two, and two within the 1e-6 toleranceruntime_checkmaterial_configconstant sets (float32k_sharp/d_hat, as libcvc holds them)check_runtimenamesmaterial_config_forMaterialRuntimederives on 8 cell widths (0.3 to 70 m)obstaclesscan_visible_geometryafter each agent's sense tick on the belief golden's 32 × 32 scene,max_obstacles36 and 5; plus a 9 × 9 scene of equal distanceslast_visibleplanes/tokensbuild_belief_material_controller_inputsfor 3 belief cases × 3 ticks × 3 agents, a 7.5 m scale variant and a no-obstacle variant, on the planes it recordsobs_feats,goal_feats, the 3 × 9 × 9 patch (f32 bits)Determinism:
test_belief_material_controller_golden.pyregenerates both files and compares them withtests/fixtures/belief_material_controller_golden/..gitattributesmarks the fixtures-text, so line endings match on every OS.Tests: 42 passed locally (Windows, cvcpkg cp312, torch 2.8 CPU): the new golden test,
test_belief_material_controller.pyandtest_austin_material_evaluation.py.black --checkandruff checkare clean.docs/MATERIAL_NAV.md's parity table has a row for the golden.C2 extends the generator with
decideandrollout(G6–G7).