From 34813dee41d151dc1e1969eb9cb0dc78a14be719 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sat, 20 Jun 2026 23:04:18 -0500 Subject: [PATCH] cap'n crunch --- opendbc_repo/opendbc/car/gm/carcontroller.py | 9 ++++++- .../car/gm/tests/test_carcontroller.py | 26 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/opendbc_repo/opendbc/car/gm/carcontroller.py b/opendbc_repo/opendbc/car/gm/carcontroller.py index 9c5a50c62..3a4264107 100644 --- a/opendbc_repo/opendbc/car/gm/carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/carcontroller.py @@ -333,6 +333,13 @@ def get_bolt_acc_pedal_friction_command_state(apply_brake: int, cruise_main_on: return command_brake, release_frames, should_send +def should_use_fixed_stopping_brake(CP, near_stop: bool, stopping: bool, resume: bool) -> bool: + if not (near_stop and stopping and not resume): + return False + + return not supports_bolt_acc_pedal_friction_experiment(CP) + + class CarController(CarControllerBase): def __init__(self, dbc_names, CP): super().__init__(dbc_names, CP) @@ -796,7 +803,7 @@ class CarController(CarControllerBase): self.regen_release_counter = 0 self.regen_min_on_frames = 0 self.regen_min_off_frames = 0 - elif near_stop and stopping and not CC.cruiseControl.resume: + elif should_use_fixed_stopping_brake(self.CP, near_stop, stopping, CC.cruiseControl.resume): stop_accel = getattr(starpilot_toggles, "stopAccel", self.CP.stopAccel) self.apply_gas = self.params.INACTIVE_REGEN self.apply_brake = int(min(-100 * stop_accel, self.params.MAX_BRAKE)) diff --git a/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py b/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py index c11a6b742..d991472a5 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py @@ -51,6 +51,7 @@ from opendbc.car.gm.carcontroller import ( get_testing_ground_1_brake_switch_bias, get_stock_cc_active_for_cancel, shape_truck_positive_accel, + should_use_fixed_stopping_brake, should_activate_auto_hold, should_activate_volt_one_pedal, should_send_adas_status, @@ -198,6 +199,31 @@ def test_bolt_acc_pedal_friction_command_state_sends_zero_unwind_after_main_off( assert should_send +def test_fixed_stopping_brake_is_disabled_for_bolt_acc_pedal_experiment(): + CP = SimpleNamespace( + carFingerprint=CAR.CHEVROLET_BOLT_ACC_2022_2023_PEDAL, + openpilotLongitudinalControl=True, + enableGasInterceptorDEPRECATED=True, + flags=GMFlags.PEDAL_LONG.value, + ) + + assert not should_use_fixed_stopping_brake(CP, True, True, False) + + +def test_fixed_stopping_brake_stays_enabled_for_normal_acc_path(): + CP = SimpleNamespace( + carFingerprint=CAR.CHEVROLET_BOLT_ACC_2022_2023, + openpilotLongitudinalControl=True, + enableGasInterceptorDEPRECATED=False, + flags=0, + ) + + assert should_use_fixed_stopping_brake(CP, True, True, False) + assert not should_use_fixed_stopping_brake(CP, False, True, False) + assert not should_use_fixed_stopping_brake(CP, True, False, False) + assert not should_use_fixed_stopping_brake(CP, True, True, True) + + def test_stock_cancel_is_suppressed_when_acc_is_faulted(): CP = SimpleNamespace(carFingerprint=CAR.CHEVROLET_VOLT_CAMERA) cs = _cs(True, AccState.FAULTED)