diff --git a/opendbc_repo/opendbc/car/gm/interface.py b/opendbc_repo/opendbc/car/gm/interface.py index c8b71028..c7312fcd 100755 --- a/opendbc_repo/opendbc/car/gm/interface.py +++ b/opendbc_repo/opendbc/car/gm/interface.py @@ -574,12 +574,13 @@ class CarInterface(CarInterfaceBase): ) if volt_test_tune_active: # Volt interceptor-long currently falls back to an all-I tune on this path. - # The test-ground tune adds a modest P term, reduces I memory, and uses a - # dedicated starting state so stop-and-go launches do not wind up the PID. + # The test-ground tune adds a modest P term, trims mid/high-speed I memory, + # and uses a dedicated starting state so stop-and-go launches do not wind + # up the PID. ret.longitudinalTuning.kpBP = [0.0, 4.0, 12.0, 35.0] - ret.longitudinalTuning.kpV = [0.10, 0.08, 0.06, 0.045] + ret.longitudinalTuning.kpV = [0.10, 0.072, 0.050, 0.040] ret.longitudinalTuning.kiBP = [0.0, 4.0, 12.0, 35.0] - ret.longitudinalTuning.kiV = [0.025, 0.035, 0.055, 0.080] + ret.longitudinalTuning.kiV = [0.025, 0.030, 0.040, 0.055] ret.startingState = True ret.startAccel = 1.15 ret.vEgoStarting = max(ret.vEgoStarting, 0.35) diff --git a/opendbc_repo/opendbc/car/gm/tests/test_gm.py b/opendbc_repo/opendbc/car/gm/tests/test_gm.py index 828c08a2..1e71a4b5 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_gm.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_gm.py @@ -68,8 +68,8 @@ class TestGMInterface: car_params = CarInterface.get_params(CAR.CHEVROLET_VOLT_ASCM, fingerprint, [], alpha_long=False, is_release=False, docs=False, starpilot_toggles=_test_starpilot_toggles()) - assert list(car_params.longitudinalTuning.kpV) == [0.10, 0.08, 0.06, 0.045] - assert list(car_params.longitudinalTuning.kiV) == [0.025, 0.035, 0.055, 0.08] + assert list(car_params.longitudinalTuning.kpV) == [0.10, 0.072, 0.05, 0.04] + assert list(car_params.longitudinalTuning.kiV) == [0.025, 0.03, 0.04, 0.055] assert car_params.startingState assert car_params.startAccel == pytest.approx(1.15) diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py index 34137e03..72a6dff3 100644 --- a/selfdrive/controls/lib/latcontrol_torque.py +++ b/selfdrive/controls/lib/latcontrol_torque.py @@ -86,19 +86,19 @@ BOLT_2018_2021_TRANSITION_SPEED = 8.5 BOLT_2018_2021_PHASE_SCALE = 0.10 BOLT_2018_2021_TURN_IN_BOOST_LEFT = 0.22 BOLT_2018_2021_TURN_IN_BOOST_RIGHT = 0.12 -BOLT_2018_2021_UNWIND_TAPER_GAIN_LEFT = 0.72 -BOLT_2018_2021_UNWIND_TAPER_GAIN_RIGHT = 0.84 +BOLT_2018_2021_UNWIND_TAPER_GAIN_LEFT = 0.80 +BOLT_2018_2021_UNWIND_TAPER_GAIN_RIGHT = 0.96 BOLT_2018_2021_FRICTION_MULT = 1.01 BOLT_2018_2021_FRICTION_LAT_RISE = 0.24 BOLT_2018_2021_FRICTION_JERK_RISE = 0.28 BOLT_2018_2021_TURN_IN_THRESHOLD_REDUCTION_LEFT = 0.16 BOLT_2018_2021_TURN_IN_THRESHOLD_REDUCTION_RIGHT = 0.13 -BOLT_2018_2021_UNWIND_THRESHOLD_INCREASE_LEFT = 0.12 -BOLT_2018_2021_UNWIND_THRESHOLD_INCREASE_RIGHT = 0.17 +BOLT_2018_2021_UNWIND_THRESHOLD_INCREASE_LEFT = 0.15 +BOLT_2018_2021_UNWIND_THRESHOLD_INCREASE_RIGHT = 0.21 BOLT_2018_2021_TURN_IN_FRICTION_BOOST_LEFT = 0.08 BOLT_2018_2021_TURN_IN_FRICTION_BOOST_RIGHT = 0.06 -BOLT_2018_2021_UNWIND_FRICTION_REDUCTION_LEFT = 0.14 -BOLT_2018_2021_UNWIND_FRICTION_REDUCTION_RIGHT = 0.19 +BOLT_2018_2021_UNWIND_FRICTION_REDUCTION_LEFT = 0.17 +BOLT_2018_2021_UNWIND_FRICTION_REDUCTION_RIGHT = 0.23 BOLT_2022_2023_LATERAL_TESTING_GROUND_ID = testing_ground.id_5 BOLT_2022_2023_FF_GAIN_LEFT = 0.13 diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 90eb5aa6..dec1939e 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -155,14 +155,21 @@ class LongControl: self.integrator_hold_frames = 0 def _get_pedal_long_freeze(self, a_target, error, v_ego, accel_limits): - if not self.is_gm_pedal_long: + volt_test_tune_handoff = self.is_volt_interceptor and testing_ground.use_2 + + if not self.is_gm_pedal_long and not volt_test_tune_handoff: self.last_a_target = a_target self.integrator_hold_frames = 0 return False - handoff_threshold = interp(v_ego, [0.0, 4.0, 12.0, 25.0], [0.35, 0.45, 0.55, 0.70]) - if abs(a_target - self.last_a_target) > handoff_threshold: + if self.is_gm_pedal_long: + handoff_threshold = interp(v_ego, [0.0, 4.0, 12.0, 25.0], [0.35, 0.45, 0.55, 0.70]) hold_frames = int(round(interp(v_ego, [0.0, 4.0, 12.0, 25.0], [25.0, 20.0, 14.0, 10.0]))) + else: + handoff_threshold = interp(v_ego, [0.0, 4.0, 12.0, 25.0], [0.24, 0.30, 0.38, 0.48]) + hold_frames = int(round(interp(v_ego, [0.0, 4.0, 12.0, 25.0], [12.0, 10.0, 8.0, 6.0]))) + + if abs(a_target - self.last_a_target) > handoff_threshold: self.integrator_hold_frames = max(self.integrator_hold_frames, hold_frames) self.last_a_target = a_target @@ -183,7 +190,7 @@ class LongControl: # Bleed stale I quickly when the target reverses against stored integrator. if self.pid.i * error < 0.0 and abs(error) > 0.05: - bleed = interp(v_ego, [0.0, 4.0, 12.0, 25.0], [0.86, 0.90, 0.94, 0.97]) + bleed = interp(v_ego, [0.0, 4.0, 12.0, 25.0], [0.82, 0.86, 0.90, 0.94]) self.pid.i *= bleed def update(self, active, CS, a_target, should_stop, accel_limits, starpilot_toggles): diff --git a/selfdrive/controls/tests/test_longcontrol.py b/selfdrive/controls/tests/test_longcontrol.py index ab50810d..f61986ae 100644 --- a/selfdrive/controls/tests/test_longcontrol.py +++ b/selfdrive/controls/tests/test_longcontrol.py @@ -1,5 +1,7 @@ from cereal import car from openpilot.selfdrive.controls.lib.longcontrol import LongCtrlState, long_control_state_trans +import openpilot.selfdrive.controls.lib.longcontrol as longcontrol +from openpilot.selfdrive.controls.lib.longcontrol import LongControl @@ -54,3 +56,22 @@ def test_starting(): next_state = long_control_state_trans(CP, active, current_state, v_ego=1.0, should_stop=False, brake_pressed=False, cruise_standstill=False) assert next_state == LongCtrlState.pid + + +def test_volt_testing_ground_handoff_freezes_integrator(monkeypatch): + CP = car.CarParams.new_message() + CP.brand = "gm" + CP.enableGasInterceptorDEPRECATED = True + CP.carFingerprint = "CHEVROLET_VOLT_ASCM" + CP.longitudinalTuning.kpBP = [0.0] + CP.longitudinalTuning.kpV = [0.1] + CP.longitudinalTuning.kiBP = [0.0] + CP.longitudinalTuning.kiV = [0.03] + + monkeypatch.setattr(longcontrol.testing_ground, "use_2", True, raising=False) + + lc = LongControl(CP) + freeze = lc._get_pedal_long_freeze(a_target=0.7, error=0.7, v_ego=8.0, accel_limits=(-3.0, 2.0)) + + assert freeze + assert lc.integrator_hold_frames > 0