From 1dcac8cfefc79f28a9e29c74fb906307ee8a55fc Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Mon, 15 Jun 2026 22:25:18 -0500 Subject: [PATCH] Tiny Dancer 2 --- opendbc_repo/opendbc/car/gm/carcontroller.py | 6 ++++-- opendbc_repo/opendbc/car/gm/gmcan.py | 16 +++++++++++----- .../opendbc/car/gm/tests/test_carcontroller.py | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/opendbc_repo/opendbc/car/gm/carcontroller.py b/opendbc_repo/opendbc/car/gm/carcontroller.py index a3d854491..153b54a78 100644 --- a/opendbc_repo/opendbc/car/gm/carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/carcontroller.py @@ -690,7 +690,8 @@ class CarController(CarControllerBase): hold_standstill = CS.pcm_acc_status == AccState.STANDSTILL hold_near_stop = CS.out.vEgo < self.params.NEAR_STOP_BRAKE_PHASE can_sends.append(gmcan.create_friction_brake_command( - self.packer_ch, friction_brake_bus, hold_brake, idx, False, hold_near_stop, hold_standstill, self.CP)) + self.packer_ch, friction_brake_bus, hold_brake, idx, False, hold_near_stop, hold_standstill, + self.CP, allow_near_stop_mode=True)) CS.auto_hold_engaged = True CS.auto_hold_fault_suppression_timer = 1.0 else: @@ -765,7 +766,8 @@ class CarController(CarControllerBase): hold_standstill = CS.pcm_acc_status == AccState.STANDSTILL hold_near_stop = CS.out.vEgo < self.params.NEAR_STOP_BRAKE_PHASE can_sends.append(gmcan.create_friction_brake_command( - self.packer_ch, get_friction_brake_bus(self.CP), hold_brake, idx, False, hold_near_stop, hold_standstill, self.CP)) + self.packer_ch, get_friction_brake_bus(self.CP), hold_brake, idx, False, hold_near_stop, hold_standstill, + self.CP, allow_near_stop_mode=True)) CS.auto_hold_engaged = True CS.auto_hold_fault_suppression_timer = 1.0 elif self.frame % 4 == 0: diff --git a/opendbc_repo/opendbc/car/gm/gmcan.py b/opendbc_repo/opendbc/car/gm/gmcan.py index d0b8e17a4..ab2fab317 100644 --- a/opendbc_repo/opendbc/car/gm/gmcan.py +++ b/opendbc_repo/opendbc/car/gm/gmcan.py @@ -179,7 +179,7 @@ def create_ecm_cruise_control_command(packer, bus, enabled, target_speed_kph): return CanData(0x3D1, bytes(dat), bus) -def create_friction_brake_command(packer, bus, apply_brake, idx, enabled, near_stop, at_full_stop, CP): +def get_friction_brake_mode(apply_brake, enabled, near_stop, at_full_stop, CP, allow_near_stop_mode=False): mode = 0x1 # TODO: Understand this better. Volts and ICE Camera ACC cars are 0x1 when enabled with no brake @@ -190,11 +190,17 @@ def create_friction_brake_command(packer, bus, apply_brake, idx, enabled, near_s mode = 0xa if at_full_stop: mode = 0xd + elif allow_near_stop_mode and near_stop: + # Stock Volt auto hold can run with cruise main on but ACC inactive, so + # there is no stock STANDSTILL state to promote 0xa -> 0xd. Restore the + # older near-stop hold mode only for that path. + mode = 0xb - # TODO: this is to have GM bringing the car to complete stop, - # but currently it conflicts with OP controls, so turned off. Not set by all cars - #elif near_stop: - # mode = 0xb + return mode + + +def create_friction_brake_command(packer, bus, apply_brake, idx, enabled, near_stop, at_full_stop, CP, allow_near_stop_mode=False): + mode = get_friction_brake_mode(apply_brake, enabled, near_stop, at_full_stop, CP, allow_near_stop_mode) brake = (0x1000 - apply_brake) & 0xfff checksum = (0x10000 - (mode << 12) - brake - idx) & 0xffff diff --git a/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py b/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py index aef983706..35f1a3d1c 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py @@ -46,6 +46,7 @@ from opendbc.car.gm.carcontroller import ( supports_volt_auto_hold, use_interceptor_sng_launch, ) +from opendbc.car.gm.gmcan import get_friction_brake_mode from opendbc.car.gm.values import AccState, CAR, GMFlags from opendbc.car.structs import CarParams @@ -280,6 +281,19 @@ def test_auto_hold_activation_allows_standstill_even_if_speed_filter_is_slightly ) +def test_friction_brake_mode_keeps_near_stop_disabled_for_regular_long_braking(): + CP = SimpleNamespace(carFingerprint=CAR.CHEVROLET_VOLT_ASCM) + + assert get_friction_brake_mode(120, False, True, False, CP) == 0xa + + +def test_friction_brake_mode_uses_near_stop_hold_mode_for_volt_auto_hold(): + CP = SimpleNamespace(carFingerprint=CAR.CHEVROLET_VOLT_ASCM) + + assert get_friction_brake_mode(120, False, True, False, CP, allow_near_stop_mode=True) == 0xb + assert get_friction_brake_mode(120, False, True, True, CP, allow_near_stop_mode=True) == 0xd + + def test_calc_pedal_command_small_accel_deadband_keeps_creep_target_stable(): pos_controller = _controller() neg_controller = _controller()