Skip to content

nav: CoPH's learner: field fit, damping fit, maze-routed replay and update (C3; G5-G8) - #1386

Merged
transfix merged 1 commit into
masterfrom
nav/coph-c3
Nov 20, 2026
Merged

transfix merged 1 commit into
masterfrom
nav/coph-c3

Conversation

@transfix

Copy link
Copy Markdown
Owner

C3 of docs/roadmap/NAV-COPH-ROADMAP.md (§4.3): the update of the demos' own learner (crossing_demo.CrossingLearner, in GRL-SNAM's grl_snam.coph) in C++, in the demos' profile. It is additive and default-off: nothing calls it yet; C5's fleet driver will.

Depends on CVC-Lab/GRL-SNAM#195 (the G5–G8 generator). src/cvc/tests/data/coph_golden.json is that PR's fixture, the same blob (f2754a27). Its G1–G4 and G11 are unchanged. If #195 changes, this copy follows.

What lands

  • inc/cvc/nav/coph_dual.h: forward-mode duals.
    • coph_dual2 gives the replay's cost and its gradient in the two policy gains in one pass.
    • The hyper-dual coph_dual<coph_dual<double, 1>, 1> gives the damping loss's first and second derivatives.
    • coph_model.cpp gains scalar traits for them and instantiates the plant, potential and command on them.
  • inc/cvc/nav/coph_learner.h, over plain-data state (coph_learner_state). That state holds C1's stages, the geometry store, what the router reads, and the committed damping, policy and version.
    • coph_field_fit (G5): each kept stage's ridge fit. The system is block diagonal, so each stage's 16 × 16 normal equations are solved by Cholesky.
    • coph_fit_damping (G6): 8 Newton steps on the plant loss, with derivatives from hyper-duals. coph_reconcile_damping then clips the result to the trust region.
    • coph_maze_route and coph_control: the profile's routed controller (below).
    • coph_prepare and coph_replay (G7): the supported_boundary plan with its pilots, the update cap and the routed reserve; then retained_replay over the kept stages.
    • coph_update (G8):
      • the fits;
      • the baseline and gradient replays;
      • the projected policy step and up to 8 halvings under the budget;
      • field and plant validation against the slack, and feasibility;
      • the commit (weights, version, policy, damping, shaping jump) or the rollback.
  • src/cvc/tests/nav_coph_learner_test.cpp: rebuilds each of the three snapshots from the file's inputs alone and checks G5–G8. It also has unit tests of the duals and of the router (the middle door closing the middle row).

Results on Windows (MSVC 19.44, Release)

G5: 1591 of 4159 values bit for bit; the worst is 0.0069 of the tier's allowance
G6: 98 of 150 values bit for bit; the worst is 6.42e-07 of the tier's allowance
G7: 2885 of 3804 values bit for bit; the worst is 1.06e-05 of the tier's allowance
G8: 39 of 60 values bit for bit; the worst is 7.04e-05 of the tier's allowance
  • Decisions: every one matches. That covers each plan's horizon, reason, pilot steps and handoffs; each replay's eligibility, routed controls, route nodes, guard steps, lengths and step counts; and each update's attempts, accept or reject, and reason.
  • Tier: rtol 1e-9, atol 1e-12.
  • Other tests: nav_coph_test (12) and nav_coph_model_test (10) still pass. clang-format 18 is clean on the touched files.

Where the spec met the code

  • The routed controller is the maze router, not the route field. §4.3 said the C++ takes "the route field's anchors". The demos' learner is a MazeLearner, so a replay step actually runs:

    • maze_learning.maze_route: Dijkstra on the surveyed corridor network (coph_crossing_network), with edges closed by the reported geometry and priced over the terrain anchors, then a waypoint on the 0.1 m grid;
    • navigation.project (fast when the raw force satisfies every constraint);
    • the guard, with maze_geometry.corridor_clear.

    The roadmap's §4.3 now says so.

  • Cholesky, not Eigen's LLT. No other nav code uses Eigen, and the blocks are 16 × 16.

  • What the golden does not reach:

    • The scripted run's replay barely depends on the policy (|∂cost/∂π| ≤ 2.9e-3), so no case halves or exhausts the budget.
    • No replay control is projected or braked. The CBF projection's full candidate set and the brake are ported but carry no golden.
  • Left for C5:

    • the terrain anchors an update leaves behind (TerrainLearner.update's local cells);
    • the diagnostic controls CooperativeLearner.update runs around an update, which only count guard steps outside the budget.

Merge is left to Joe.

…pdate (C3; G5-G8)

C3 of docs/roadmap/NAV-COPH-ROADMAP.md (§4.3): the update of the demos' own learner
(crossing_demo.CrossingLearner) in the profile, in inc/cvc/nav/coph_learner.h.

- coph_field_fit: each kept stage's ridge fit (Cholesky on its 16 x 16 system).
- coph_fit_damping: Newton steps on the plant loss, on hyper-duals (coph_dual.h).
- coph_maze_route and coph_control: the profile's routed controller is MazeLearner's maze
  router on the surveyed corridor network, then the CBF projection and the corridor guard.
- coph_prepare and coph_replay: the supported_boundary plan and budget, and retained_replay;
  on coph_dual2 one pass gives the cost and d cost / d policy.
- coph_update: the fits, the policy step and its halvings, validation, then commit or rollback.

coph_model.cpp gains scalar traits for the duals and instantiates the plant, potential and
command on them. The golden (data/coph_golden.json) is CVC-Lab/GRL-SNAM#195's, with G5-G8
added; G1-G4 and G11 are unchanged. On Windows nav_coph_learner_test matches every decision,
with values within 0.0069 of the tier's allowance (rtol 1e-9, atol 1e-12). nav_coph_test and
nav_coph_model_test still pass. The roadmap's §4.3 records what landed, and corrects its
routed-controller text: the profile never reaches the route field's anchors.
@transfix
transfix merged commit 3424f9c into master Nov 20, 2026
29 checks passed
@transfix
transfix deleted the nav/coph-c3 branch November 20, 2026 05:38
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