Repository navigation
nav: evaluate U_nav along the rollouts, and gradcheck F = -grad U at every call site - #747
Merged
Merged
Conversation
…every call site
The navigator's forces are written as closed-form derivatives of an energy that was never
computed. This evaluates it (doc 20's rung 1):
U_nav = beta/2 |o - g|^2 + sum_j alpha_j b_IPC(d_j) + lam_soft r~ + lam_hard b_sp(phi)
(+ the terrain's grade cost and slope barrier)
with the coefficients held fixed. Damping is dissipation and the external force a port, so
neither is part of U.
- detail/nav_potential.h: potential_terms and the barrier potentials, each the one whose
derivative its force primitive returns: ipc_b (diff::ipc_, drive.cpp's ipc_dbdd, continued
linearly below the 1e-6 floor), ipc_b_pw (ipc_dbdd_pw, continued with slope -200 below the
clamp's knee) and sdf_barrier_b (the softplus hazard barrier).
- Exposed without changing any output:
- diff::surr_potential; coef_trainer::loss_and_grad's optional `potential` (per step, with
the step's coefficients); bike_control's optional `force` out.
- material.h rollout_energy (potential, terms, force per step), an optional last argument
of integrate_surrogate_material, integrate_bicycle_material and
integrate_dynamic_material.
- drive_telemetry gains potential, terms and force_x/force_y at the tick's start pose, and
drive_potential() evaluates U at any pose. The material and terrain hard forces read
grad phi per metre in the normalized frame, so their potential is lam_hard S b_sp(phi).
- nav_potential_test (10): the barrier potentials differentiate to the force primitives; at
every call site (coef_train surrogate and bicycle, the three material rollouts, the drive
plain / material / terrain / footprint / plant arm) the site's own force is -grad U by
central differences on exact planes (worst 7.9e-4 relative); on the city scene with built
material planes the grid's residual is p50 1.2e-4, max 8.7e-3; every rollout is
byte-identical with and without the record; on the point mass KE + U falls by the damping's
work with an O(dt) error (1.4e-2, 8.2e-3, 4.3e-3 at dt 0.02, 0.01, 0.005); and
NavPotential.Golden pins tests/data/nav_potential_golden.json for the torch twin.
…rollouts are Its material checks compare the U a rollout logged with the same inline evaluator called in the test, bit for bit. The rollouts' TUs are built without FMA contraction; on aarch64 clang contracted the test's copy, and the last bits differed (macOS CI).
…eval # Conflicts: # src/cvc/tests/CMakeLists.txt
transfix
enabled auto-merge (squash)
October 21, 2026 18:41
transfix
added a commit
that referenced
this pull request
Oct 27, 2026
…k at the tick (#832) The white paper's navigator energy ledger (Eq. 38) was specified but not built: the rollouts evaluate U_nav (#747), but nothing booked a step's energy or checked it. - rollout_energy gains per-step books for the point-mass material surrogate: kinetic energy, damping work, port work, clamp loss, clamp cross term, the residual r_E, its cheap bound (every step) and the sharp check r_hat_E (two extra force evaluations a step, when asked). They are the books of the step taken from the rollout's state, evaluated in double, so they resolve r_E - r_hat_E = O(dt^3), which is below float round-off on U. The bicycle and dynamic rollouts throw when asked for them. - book_step() books any semi-implicit point-mass step from its quantities; energy_residual_bound() is the cheap bound with the secant Lipschitz estimate and kappa_H = 2. - The barrier potentials and force primitives become *_t<T> templates; the float functions are their float instantiations, op for op. detail::material_energy<T> evaluates U and the force the surrogate applies. - sim_world fills three new drive_telemetry fields while it captures: potential_end, projection_work (override_command and min_gap) and context_work (this tick's U at its start pose minus U at the same pose with last tick's context, evaluated before the sense and the field rebuild). The vehicle-params block moves unchanged into sim_world::drive_vehicle() so both evaluations read the same vehicle. The drive leaves the three fields zero. nav_potential_test, 10 -> 16 tests: as dt halves 0.02 -> 0.0025 the measured order of r_E is 1.99/2.00/2.00 and of r_E - r_hat_E 2.99/2.94/2.93. The cheap bound catches an unlogged force and an unbooked clamp cross term; explicit Euler passes it (its residual is second order too) and fails the sharp check.
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.
The navigator's forces are written as closed-form derivatives of an energy that was never computed. This evaluates it as a number along every rollout and checks, at every call site, that the conservative force is its negative gradient (the first rung of the port-Hamiltonian ladder):
The coefficients are held fixed. Damping is dissipation and the external force is a port, so neither is part of U.
What changes
Nothing that runs today changes: every new output is optional and write-only.
detail/nav_potential.h:potential_termsand the barrier potentials, each the one whose derivative its force primitive returns:ipc_b:diff::ipc_/drive.cpp'sipc_dbdd, continued linearly below the 1e-6 floor;ipc_b_pw:ipc_dbdd_pw, continued with slope -200 below the clamp's knee;sdf_barrier_b: the softplus hazard barrier.diff::surr_potential;coef_trainer::loss_and_grad(..., potential), per step with that step's coefficients;bike_control's optionalforceout.rollout_energy(potential, terms and force per step), an optional last argument ofintegrate_surrogate_material,integrate_bicycle_materialandintegrate_dynamic_material.drive_telemetrygainspotential,termsandforce_x/force_yat the tick's start pose.sim_world's telemetry capture therefore logs U along kinematic and Jolt runs.drive_potential()evaluates U at any pose.lam_hard * S * b_sp(phi_m), with S the stack's normalized units per metre. Dropping S makes the check fail by 34-45x.Measured (
nav_potential_test, 10 tests)material_build. Here the residual is the grid's (stored normals and gradient planes against the bilinear values): p50 1.2e-4, p90 3.4e-4, max 8.7e-3 over 483 poses (145 inside the barrier).NavPotential.Goldenpinstests/data/nav_potential_golden.jsonfor the torch twin, nav_potential: U_nav evaluated, the torch twin of libcvc's, held to its golden CVC-Lab/GRL-SNAM#133 (the barrier sweep, U along a material rollout,drive_potentialwith and without a footprint).Locally (Linux, Jolt 5.6.0 from cvcpkg):
nav_potential_test10/10, and every nav/physics ctest case passes (408/408).CI note (macOS arm64)
nav_potential_test: its material checks compare the U a rollout logs with the same inline evaluator called in the test, bit for bit. The first macOS run failed by a few ULPs, because clang contracted the test file's copy into FMAs while the material rollouts build with-ffp-contract=off.NavMaterialExt.ACallbackGivingThePatchIsThePatch(dynamic case) also failed there, and not because of this PR.nav_material_ext_test.cppfixes it: nav_material_ext_test: build it with -ffp-contract=off, as the material rollouts are #752. On x86, writing the callback's sample with the FMAs clang forms reproduces the macOS pattern: only the dynamic case fails.