Repository navigation
nav: a differentiable power model, fitted to the P3 ledger, and energy in the dynamic loss (P8c) - #782
Merged
Conversation
…y in the dynamic loss (P8c)
diff::power_step (detail/dyn_power.h) prices what the dynamic vehicle draws from its fuel or
battery over a step, from its state at the step's end:
E = dt (k_pos P+ + k_neg P- + p_idle + c_v |vx| + c_v3 |vx|^3 + c_lat m (vx r)^2 |vx|)
with P = m a vx the drive power, smooth parts, and its derivatives in vx, a and r. nav/dyn_power.h
holds its SI form and the conversion into the normalized frame (by length exponent, as
dyn_bike_params_of).
Calibration (physics/plant_log.h):
- planar_sample carries each tick's energy (nav_plant::energy_step); samples.csv gains the column.
- fit_power fits the six coefficients by sign-constrained least squares on the ticks' energies,
reading the drive force the dynamic vehicle needs to make the plant's motion (the measured
acceleration less its own drag, rolling resistance and grade); evaluate_power reports r2, the
total and the worst run on held-out runs.
- cvc plant-log --fit-power fits every seed but the last and reports the last (residual.json's
"power").
- Fitted on four seeds of the swerve and the city and judged on two held out, the totals come
within +1.4% (Humvee) and -1.4% (RoboRacer); the swerve alone misses by +9.0% and +17.7%
(PlantLogPowerConvergence).
The loss (train_config::w_energy, train_config::power; rollout_kind::dynamic):
- each step adds w_energy / window * E_t / (hdt * P_full) per agent, P_full the source power at
full drive and top speed, so the term is O(1); its adjoint lands on (vx, r, a)_{t+1};
- 0 leaves the loss and its gradient bit for bit; without the dynamic rollout or with another
vehicle's mass it throws;
- the energy term's gradcheck: direction error 9.0e-4; over 60 steps it lowers the energy term
0.970 -> 0.937, against 0.962 without it.
Open: the Jolt gate (a policy trained with it draws less per km for what it gives up in reach),
the four-wheel plant's rollout, and the torch twin.
This was referenced Oct 24, 2026
transfix
added a commit
that referenced
this pull request
Oct 29, 2026
…at hit no other vehicle (#875) PlantLogPowerConvergence.FitsTheLedgerAndPredictsHeldOutSeeds has failed on every package-linux release lane since #782 added it (41673b3): the RoboRacer's held-out tick r2 is 0.598 against > 0.8, the same on every push run since. It was calibrated on Windows, where it is 0.91, and the Linux fit has not moved since. The runs that drag it down are city runs in which the vehicle hit another one. On Windows the RoboRacer's two worst held-out runs (-35%, -8%) are the only two that touched another vehicle: two contact ticks and two impact ticks each, then a long stall with the wheels spinning. Every other run is within 8%, though nearly every city run touches the scene's walls. On Linux, four of its city runs miss, by -52% to +31%. The planar power model has no collisions and no wheel spin (docs/NAV_TRAINING.md), so no term of its state sees that energy. Which runs collide depends on the platform's floating point. - planar_sample gains vehicle_contact: the other agent the vehicle touched that tick, from nav_plant::vehicle_contact_step (-1 none). - The test judges the held-out prediction on the runs that hit no other vehicle (no vehicle_contact and no impact past kImpactG), and requires them to be at least three quarters of the held-out runs. The others are printed with their errors. The fit itself is unchanged and still uses every run and tick. - docs/NAV_TRAINING.md: the measured table on that basis (Windows: Humvee r2 0.90, RoboRacer 0.97, 22 of 24 runs each), and the excluded runs.
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.
P8c of
docs/roadmap/NAV-VEHICLE-PHYSICS-ROADMAP.md: a differentiable power model, calibrated to the P3 energy ledger, with energy as an optional term in the dynamic rollout's loss.The model
diff::power_step(inc/cvc/nav/detail/dyn_power.h) gives what the dynamic vehicle draws from its fuel or battery over a step. It reads the vehicle's state at the end of the step:nav/dyn_power.hholds the SI parameters and converts them into the normalized frame by length exponent, asdyn_bike_params_ofdoes.k_neg≤ 0 is regeneration). p_idle is the draw at rest. c_v and c_v3 cover rolling and drag where the dynamic vehicle leaves them out. c_lat is cornering loss.Calibrated to the ledger
planar_samplenow carries each tick's energy (nav_plant::energy_step), andsamples.csvgains anenergycolumn.fit_power/evaluate_powerinphysics/plant_log.h. It is least squares on each tick's energy, with each coefficient's sign held.dyn_state::a.cvc plant-log --fit-powerfits every seed but the last, reports the last, and writes the result toresidual.json's"power".Measured (
PlantLogPowerConvergence, Windows, Jolt): each vehicle fitted on four seeds of both scenes (30 s each) and judged on two held-out seeds:Limits, also in
docs/NAV_TRAINING.md:In the loss
train_config::w_energyandtrain_config::power, withrollout_kind::dynamic.w_energy / window · E_t / (hdt · P_full)per agent. That's the window's mean power as a fraction of full power, so it is O(1), likew_coll.(vx, r, a)after the step, before the rollout's reverse pass.w_energy = 0leaves the loss and its gradient bit for bit.dyn's.Tests (all passing locally on Windows with Jolt)
nav_coef_train_test(17 tests):PowerStepMatchesFiniteDifferenceAndConverts: the step's derivatives against central differences, and the SI conversion.EnergyTermNeedsADynamicVehicleAndIsOffByDefault: the checks, and bit-for-bit off.EnergyGradcheckMatchesFiniteDifference: the energy term's own gradient, direction error 9.0e-4.EnergyTrainingDrawsLessEnergy: over 60 steps from the same start, the energy term falls 0.970 → 0.937 with it, against 0.962 without it.physics_plant_log_test(11 tests):FitRecoversAKnownPowerModel.LogsTheEnergyEachTickDrew(Jolt).PlantLogPowerConvergence.FitsTheLedgerAndPredictsHeldOutSeeds(Jolt, about 85 s; in a Convergence suite, so the recipe CI skips it).cvc_cli_testPlantLog*(6 tests).physics_energy_test(11),nav_plant_test(18),nav_dyn_bike_test(20),nav_dyn_4w_test(16).Not in this PR
sdf_nav'strain_bicyclebefore the two are compared.