From cd08c87a801fa0fb672558eba1bba3c661ca1c5c Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Fri, 19 Jun 2026 17:33:49 -0500 Subject: [PATCH] again --- opendbc_repo/opendbc/car/gm/carcontroller.py | 64 +++++++++++-------- .../car/gm/tests/test_carcontroller.py | 31 +++++++++ 2 files changed, 69 insertions(+), 26 deletions(-) diff --git a/opendbc_repo/opendbc/car/gm/carcontroller.py b/opendbc_repo/opendbc/car/gm/carcontroller.py index d6470132e..4b1f05ebb 100644 --- a/opendbc_repo/opendbc/car/gm/carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/carcontroller.py @@ -149,6 +149,24 @@ def get_adas_keepalive_step(CP, is_kaofui_car): return None +def should_send_adas_status(CP, is_kaofui_car): + if CP.radarUnavailable: + return False + + if not is_kaofui_car: + return True + + # Volt ASCM/SASCM installs retain the stock radar-status source. Replacing it + # faults cruise as soon as the accelerator changes the stock radar state. + if CP.carFingerprint == CAR.CHEVROLET_VOLT_ASCM: + return False + + if CP.carFingerprint in ASCM_INT: + return True + + return CP.networkLocation != NetworkLocation.fwdCamera and CP.carFingerprint not in SDGM_CAR + + def get_testing_ground_1_brake_switch_bias(v_ego: float) -> int: return int(round(np.interp(v_ego, [0.0, 6.0, 15.0, 30.0], [40.0, 85.0, 130.0, 170.0]))) @@ -928,33 +946,27 @@ class CarController(CarControllerBase): # Radar needs to know current speed and yaw rate (50hz), # and that ADAS is alive (10hz) - if not self.CP.radarUnavailable: - send_adas = True + if should_send_adas_status(self.CP, self.CP.carFingerprint in kaofui_cars): + tt = self.frame * DT_CTRL if self.CP.carFingerprint in kaofui_cars: - if self.CP.carFingerprint not in ASCM_INT: - send_adas = (self.CP.networkLocation != NetworkLocation.fwdCamera) and (self.CP.carFingerprint not in SDGM_CAR) - - if send_adas: - tt = self.frame * DT_CTRL - if self.CP.carFingerprint in kaofui_cars: - time_and_headlights_step = 10 - speed_and_accelerometer_step = 2 - if self.frame % time_and_headlights_step == 0: - idx = (self.frame // time_and_headlights_step) % 4 - can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx)) - can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE)) - if self.frame % speed_and_accelerometer_step == 0: - idx = (self.frame // speed_and_accelerometer_step) % 4 - can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx)) - can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx)) - else: - time_and_headlights_step = 20 - if self.frame % time_and_headlights_step == 0: - idx = (self.frame // time_and_headlights_step) % 4 - can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx)) - can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE)) - can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx)) - can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx)) + time_and_headlights_step = 10 + speed_and_accelerometer_step = 2 + if self.frame % time_and_headlights_step == 0: + idx = (self.frame // time_and_headlights_step) % 4 + can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx)) + can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE)) + if self.frame % speed_and_accelerometer_step == 0: + idx = (self.frame // speed_and_accelerometer_step) % 4 + can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx)) + can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx)) + else: + time_and_headlights_step = 20 + if self.frame % time_and_headlights_step == 0: + idx = (self.frame // time_and_headlights_step) % 4 + can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx)) + can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE)) + can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx)) + can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx)) keepalive_step = get_adas_keepalive_step(self.CP, self.CP.carFingerprint in kaofui_cars) if keepalive_step is not None and self.frame % keepalive_step == 0: diff --git a/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py b/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py index f83b8fd62..ee9f1bd92 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py @@ -48,6 +48,7 @@ from opendbc.car.gm.carcontroller import ( should_activate_volt_one_pedal, should_neutralize_volt_long_on_driver_override, should_send_stock_long_cancel, + should_send_adas_status, should_suppress_volt_stock_cancel_in_park, should_suppress_volt_stock_long_pre_drive, should_spoof_dash_speed, @@ -155,6 +156,36 @@ def test_live_camera_path_does_not_send_pt_keepalive(): assert get_adas_keepalive_step(cp, is_kaofui_car=True) is None +def test_volt_ascm_does_not_replace_stock_radar_status(): + cp = SimpleNamespace( + carFingerprint=CAR.CHEVROLET_VOLT_ASCM, + networkLocation=CarParams.NetworkLocation.fwdCamera, + radarUnavailable=False, + ) + + assert not should_send_adas_status(cp, is_kaofui_car=True) + + +def test_other_ascm_int_cars_send_radar_status(): + cp = SimpleNamespace( + carFingerprint=CAR.BUICK_LACROSSE_ASCM, + networkLocation=CarParams.NetworkLocation.fwdCamera, + radarUnavailable=False, + ) + + assert should_send_adas_status(cp, is_kaofui_car=True) + + +def test_radar_status_is_suppressed_when_radar_is_unavailable(): + cp = SimpleNamespace( + carFingerprint=CAR.BUICK_LACROSSE_ASCM, + networkLocation=CarParams.NetworkLocation.fwdCamera, + radarUnavailable=True, + ) + + assert not should_send_adas_status(cp, is_kaofui_car=True) + + def test_volt_auto_hold_requires_toggle_supported_non_cc_only_volt_and_stock_safety(): stock_safety = [SimpleNamespace(safetyParam=0x8000)] no_safety = [SimpleNamespace(safetyParam=0)]