diff --git a/opendbc_repo/opendbc/car/chrysler/values.py b/opendbc_repo/opendbc/car/chrysler/values.py index b3ae3bef3..cd05100ea 100644 --- a/opendbc_repo/opendbc/car/chrysler/values.py +++ b/opendbc_repo/opendbc/car/chrysler/values.py @@ -97,6 +97,22 @@ class CAR(Platforms): ) +PACIFICA_HYBRID_AOL_CARS = frozenset({ + CAR.CHRYSLER_PACIFICA_2019_HYBRID, +}) + + +def pacifica_hybrid_aol_stock_acc_mode(car_fingerprint, pcm_cruise: bool, + controls_enabled: bool, always_on_lateral_enabled: bool) -> bool: + # Keep this narrow until we have logs proving other Chrysler platforms need the same exemption. + return ( + car_fingerprint in PACIFICA_HYBRID_AOL_CARS and + pcm_cruise and + always_on_lateral_enabled and + not controls_enabled + ) + + class CarControllerParams: def __init__(self, CP): self.STEER_STEP = 2 # 50 Hz diff --git a/opendbc_repo/opendbc/car/tests/test_platform_configs.py b/opendbc_repo/opendbc/car/tests/test_platform_configs.py index 1704621dd..bee089475 100644 --- a/opendbc_repo/opendbc/car/tests/test_platform_configs.py +++ b/opendbc_repo/opendbc/car/tests/test_platform_configs.py @@ -1,3 +1,4 @@ +from opendbc.car.chrysler.values import CAR as CHRYSLER_CAR, pacifica_hybrid_aol_stock_acc_mode from opendbc.car.values import PLATFORMS @@ -15,3 +16,13 @@ class TestPlatformConfigs: assert name == platform.config.platform_str assert platform.config.specs is not None + + def test_pacifica_hybrid_aol_stock_acc_mode_requires_pr_conditions(self): + assert pacifica_hybrid_aol_stock_acc_mode(CHRYSLER_CAR.CHRYSLER_PACIFICA_2019_HYBRID, True, False, True) + assert not pacifica_hybrid_aol_stock_acc_mode(CHRYSLER_CAR.CHRYSLER_PACIFICA_2019_HYBRID, True, True, True) + assert not pacifica_hybrid_aol_stock_acc_mode(CHRYSLER_CAR.CHRYSLER_PACIFICA_2019_HYBRID, True, False, False) + assert not pacifica_hybrid_aol_stock_acc_mode(CHRYSLER_CAR.CHRYSLER_PACIFICA_2019_HYBRID, False, False, True) + + def test_pacifica_hybrid_aol_stock_acc_mode_stays_narrow(self): + assert not pacifica_hybrid_aol_stock_acc_mode(CHRYSLER_CAR.CHRYSLER_PACIFICA_2018_HYBRID, True, False, True) + assert not pacifica_hybrid_aol_stock_acc_mode(CHRYSLER_CAR.CHRYSLER_PACIFICA_2020, True, False, True) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index bf004e15e..28d5af54a 100644 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -10,6 +10,7 @@ from openpilot.common.realtime import config_realtime_process, DT_CTRL, Priority from openpilot.common.swaglog import cloudlog from opendbc.car.car_helpers import interfaces +from opendbc.car.chrysler.values import pacifica_hybrid_aol_stock_acc_mode from opendbc.car.gm.values import CAR as GM_CAR from opendbc.car.vehicle_model import VehicleModel from openpilot.selfdrive.controls.lib.drive_helpers import clip_curvature, get_lateral_active @@ -225,7 +226,14 @@ class Controls: CC.angularVelocity = self.calibrated_pose.angular_velocity.xyz.tolist() CC.cruiseControl.override = CC.enabled and not CC.longActive and self.CP.openpilotLongitudinalControl - CC.cruiseControl.cancel = CS.cruiseState.enabled and (not CC.enabled or not self.CP.pcmCruise) + pacifica_hybrid_aol = pacifica_hybrid_aol_stock_acc_mode( + self.CP.carFingerprint, + self.CP.pcmCruise, + CC.enabled, + self.sm['starpilotCarState'].alwaysOnLateralEnabled, + ) + cancel_requested = CS.cruiseState.enabled and (not CC.enabled or not self.CP.pcmCruise) + CC.cruiseControl.cancel = cancel_requested and not pacifica_hybrid_aol CC.cruiseControl.resume = CC.enabled and CS.cruiseState.standstill and not self.sm['longitudinalPlan'].shouldStop hudControl = CC.hudControl diff --git a/selfdrive/selfdrived/selfdrived.py b/selfdrive/selfdrived/selfdrived.py index 1869c8ba2..98f7e0720 100644 --- a/selfdrive/selfdrived/selfdrived.py +++ b/selfdrive/selfdrived/selfdrived.py @@ -9,6 +9,7 @@ from cereal import car, custom, log from msgq.visionipc import VisionIpcClient, VisionStreamType +from opendbc.car.chrysler.values import pacifica_hybrid_aol_stock_acc_mode from opendbc.car.gm.values import GMFlags from opendbc.safety import ALTERNATIVE_EXPERIENCE @@ -425,7 +426,13 @@ class SelfdriveD: if not REPLAY: # Check for mismatch between openpilot and car's PCM - cruise_mismatch = CS.cruiseState.enabled and (not self.enabled or not self.CP.pcmCruise) + pacifica_hybrid_aol = pacifica_hybrid_aol_stock_acc_mode( + self.CP.carFingerprint, + self.CP.pcmCruise, + self.enabled, + self.sm['starpilotCarState'].alwaysOnLateralEnabled, + ) + cruise_mismatch = CS.cruiseState.enabled and (not self.enabled or not self.CP.pcmCruise) and not pacifica_hybrid_aol self.cruise_mismatch_counter = self.cruise_mismatch_counter + 1 if cruise_mismatch else 0 if self.cruise_mismatch_counter > int(6. / DT_CTRL): self.events.add(EventName.cruiseMismatch)