Ford angle-mode lateral: closed-loop auto-calibration of the speed factors - #161
Ford angle-mode lateral: closed-loop auto-calibration of the speed factors#161ghbarker wants to merge 1 commit into
Conversation
f2b69d1 to
f7acbda
Compare
|
Rebased onto latest bp-dev (picks up the FORD_EDGE_MK2 pinion-toggle commit that touches the same settings files) and addressed the full design-review findings with five new commits:
On-road result: on a ~1 h drive (route 47 tests (incl. the onboard-glue suite) pass; the reference-route replay is byte-identical through the refactors. 🤖 Generated with Claude Code |
|
Two small additions since the reformat: the evidence Frame is now only constructed while the calibrator is armed (it was built and discarded every frame for drivers with the toggle off — caught by downstream sim tooling whose minimal mock had no wheelSpeeds), and the toggle is now exposed in sunnylink with the same angle-mode gating as the on-device surfaces. The anti-weave smoothing feature is now up as #163, stacked on this branch — merging this first shrinks that one to its own two commits. 🤖 Generated with Claude Code |
46b68ab to
071f9b3
Compare
071f9b3 to
6baea2a
Compare
…ctors A pure estimator (angle_autocal.py) fits the two gain anchors from clean cornering evidence — steady curve segments and matched command/measured apexes — and nudges the applied factors toward the fit in small damped steps, verifying each step against fresh evidence before the next. Evidence is only taken while the loop is quietly tracking (hunting can never read as gain) and while the actuation delay is estimated, aligned against the command from lateral_delay ago so a moving command on winding roads still counts. Lifecycle (arm/disarm, persistence, nudge writes, lock) lives in a controller; the same estimator runs offline against logged drives. The sub-knee small-signal lift rides the FordHighSpeedDampening_ang knob merged in BluePilotDev#166 (mechanically the same multiplier); no duplicate param is added. Settings are on the on-device menus (comma 3X + comma four) and sunnylink. Menu neutral values leave steering bit-identical to today.
6baea2a to
1b8caa2
Compare
The evidence that motivated this
FordLowSpeedFactor_ang/FordHighSpeedFactor_ang) are per-car: pinion geometry, tires, and alignment move the true gains, and most drivers never find their values. Manual stepping is trial-and-error at 0.01 granularity across two coupled knobs.Why the fix is shaped this way
angle_autocal.py): weighted least-squares fit of the two gain anchors from curve samples,y = g_applied / rper sample so the target is invariant to whatever factor was in force when the sample was taken. The same module runs offline against logged drives — every onboard decision is reproducible on a PC.MIN_KAPPA— sub-knee under-delivery cannot contaminate the fit), only whileliveDelayreportsestimated, and lag-aligned against the command fromlateralDelayago so winding roads still count. Saturated frames, hands-on frames, and lat-accel-implausible samples are rejected.angle_autocal_controller.py): arm/disarm from the toggle, JSON persistence across drives, blocking nudge writes (single owner of the factor params), user-edit detection, an error channel that can never clobber evidence, and ground-truth telemetry from the live controller — not param snapshots.FordHighSpeedDampening_angfrom Add High Speed Low Curve Tuning Option #166 (mechanically the same multiplier) — no duplicate param.The evidence afterwards
0000001e, 32 segments): the calibrator proposed, stepped, and verify-confirmed the high anchor at 1.16 with the live response ratio settling at 0.996–1.013 — the car measurably doing what is asked after calibration.What each change is
opendbc/sunnypilot/car/ford/angle_autocal.py: the pure estimator — evidence gates, staged steady/apex collection, the two-anchor fit, nudger, verify, lock.opendbc/sunnypilot/car/ford/angle_autocal_controller.py: lifecycle — arm/disarm, persistence, blocking factor writes, error channel, telemetry status.opendbc/sunnypilot/car/ford/lateral_angle_ext.py: frame feed + factor read-back (the strategy stays the single reader of the params the nudger writes); platform gains extracted tovalues_ext.py.cereal/custom.capnp+opendbc/car/structs.py+bluepilot/selfdrive/car/bp_card_publisher.py: ground-truth auto-cal telemetry (bmsAngleAutoCalibrate,bmsAngleAutoCalState,angleSaturated).common/params_keys.h: the fiveFordAngleAutoCal*params.docs/ford-angle-autocal.md: driver-facing guide.test_angle_autocal.py(estimator + controller),test_lateral_angle_ext.py(strategy glue).Test it yourself
docs/ford-angle-autocal.md.angle_autocal_analyze.py) and compare its fit to what the car converged on.Risks / limits
Part 1 of 3: anti-weave smoothing (#171) and the on-device gauges (#172) are stacked on this PR.