From cec9f090c49ff844bcdad669ad730cabdc33257b Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Wed, 24 Jun 2026 22:51:14 -0500 Subject: [PATCH] Bolt Pedal Friction Tune --- selfdrive/controls/lib/longcontrol.py | 10 ++++---- selfdrive/controls/tests/test_longcontrol.py | 24 ++++++++++++++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 4cee83a3c..54267e8fd 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -332,12 +332,10 @@ class LongControl: if a_target >= pedal_regen_limit: return feedforward - # Preserve the existing pedal/interceptor shaping up to the known regen - # envelope, then restore full-gain feedforward only for the extra decel - # that must be satisfied by friction blending. - pedal_component = pedal_regen_limit * self.feedforward_gain - friction_component = a_target - pedal_regen_limit - return pedal_component + friction_component + friction_gap = pedal_regen_limit - a_target + gain_restore = float(interp(friction_gap, [0.0, 0.25, 0.75], [0.0, 0.6, 1.0])) + effective_gain = self.feedforward_gain + ((1.0 - self.feedforward_gain) * gain_restore) + return a_target * effective_gain def update(self, active, CS, a_target, should_stop, accel_limits, starpilot_toggles): """Update longitudinal control. This updates the state machine and runs a PID loop""" diff --git a/selfdrive/controls/tests/test_longcontrol.py b/selfdrive/controls/tests/test_longcontrol.py index 356f7be77..30fdc7a5e 100644 --- a/selfdrive/controls/tests/test_longcontrol.py +++ b/selfdrive/controls/tests/test_longcontrol.py @@ -493,11 +493,27 @@ def test_bolt_acc_pedal_friction_feedforward_restores_full_gain_beyond_regen_env CP.longitudinalTuning.kfDEPRECATED = 0.20 lc = LongControl(CP) - pedal_regen_limit = float(longcontrol.interp(4.73, longcontrol.BOLT_ACC_PEDAL_REGEN_LIMIT_BP, - longcontrol.BOLT_ACC_PEDAL_REGEN_LIMIT_V)) - expected = pedal_regen_limit * 0.20 + (-3.22 - pedal_regen_limit) - assert lc._get_longitudinal_feedforward(-3.22, 4.73) == pytest.approx(expected) + assert lc._get_longitudinal_feedforward(-3.22, 4.73) == pytest.approx(-3.22) + + +def test_bolt_acc_pedal_friction_feedforward_blends_back_in_for_small_friction_request(): + CP = make_longcontrol_cp( + brand="gm", + enableGasInterceptorDEPRECATED=True, + flags=GMFlags.PEDAL_LONG.value, + carFingerprint=CAR.CHEVROLET_BOLT_ACC_2022_2023_PEDAL, + ) + CP.longitudinalTuning.kfDEPRECATED = 0.20 + + lc = LongControl(CP) + pedal_regen_limit = float(longcontrol.interp(20.0, longcontrol.BOLT_ACC_PEDAL_REGEN_LIMIT_BP, + longcontrol.BOLT_ACC_PEDAL_REGEN_LIMIT_V)) + a_target = pedal_regen_limit - 0.10 + gain_restore = float(longcontrol.interp(0.10, [0.0, 0.25, 0.75], [0.0, 0.6, 1.0])) + expected = a_target * (0.20 + ((1.0 - 0.20) * gain_restore)) + + assert lc._get_longitudinal_feedforward(a_target, 20.0) == pytest.approx(expected) def test_bolt_cc_pedal_friction_feedforward_remains_fully_scaled_by_kf():