From 284b26b9ebed4e928b6bb9ce37f94149d509ee94 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Fri, 15 Mar 2024 21:05:18 -0700 Subject: [PATCH] Disable openpilot longitudinal control Added toggle to disable openpilot longitudinal control. --- common/params.cc | 1 + selfdrive/car/ford/interface.py | 2 +- selfdrive/car/gm/interface.py | 6 +++--- selfdrive/car/honda/interface.py | 4 ++-- selfdrive/car/hyundai/interface.py | 2 +- selfdrive/car/subaru/interface.py | 2 +- selfdrive/car/tesla/interface.py | 2 +- selfdrive/car/toyota/interface.py | 1 + selfdrive/car/volkswagen/interface.py | 2 +- selfdrive/frogpilot/ui/vehicle_settings.cc | 11 +++++++++++ 10 files changed, 23 insertions(+), 10 deletions(-) mode change 100755 => 100644 selfdrive/car/gm/interface.py mode change 100755 => 100644 selfdrive/car/honda/interface.py diff --git a/common/params.cc b/common/params.cc index 8d0896a..63399b7 100644 --- a/common/params.cc +++ b/common/params.cc @@ -245,6 +245,7 @@ std::unordered_map keys = { {"CydiaTune", PERSISTENT}, {"DecelerationProfile", PERSISTENT}, {"DeviceShutdown", PERSISTENT}, + {"DisableOpenpilotLongitudinal", PERSISTENT}, {"DisengageVolume", PERSISTENT}, {"DriveStats", PERSISTENT}, {"DynamicPathWidth", PERSISTENT}, diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index 320ebb8..9724592 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -34,7 +34,7 @@ class CarInterface(CarInterfaceBase): ret.experimentalLongitudinalAvailable = True if experimental_long: ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_FORD_LONG_CONTROL - ret.openpilotLongitudinalControl = True + ret.openpilotLongitudinalControl = True and not params.get_bool("DisableOpenpilotLongitudinal") if candidate in CANFD_CAR: ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_FORD_CANFD diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py old mode 100755 new mode 100644 index bdd1b10..b20efba --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -124,7 +124,7 @@ class CarInterface(CarInterfaceBase): if experimental_long: ret.pcmCruise = False - ret.openpilotLongitudinalControl = True + ret.openpilotLongitudinalControl = True and not params.get_bool("DisableOpenpilotLongitudinal") ret.safetyConfigs[0].safetyParam |= Panda.FLAG_GM_HW_CAM_LONG elif candidate in SDGM_CAR: @@ -137,7 +137,7 @@ class CarInterface(CarInterfaceBase): ret.safetyConfigs[0].safetyParam |= Panda.FLAG_GM_HW_SDGM else: # ASCM, OBD-II harness - ret.openpilotLongitudinalControl = True + ret.openpilotLongitudinalControl = True and not params.get_bool("DisableOpenpilotLongitudinal") ret.networkLocation = NetworkLocation.gateway ret.radarUnavailable = RADAR_HEADER_MSG not in fingerprint[CanBus.OBSTACLE] and not docs ret.pcmCruise = False # stock non-adaptive cruise control is kept off @@ -322,7 +322,7 @@ class CarInterface(CarInterfaceBase): ret.radarUnavailable = True ret.experimentalLongitudinalAvailable = False ret.minEnableSpeed = 24 * CV.MPH_TO_MS - ret.openpilotLongitudinalControl = True + ret.openpilotLongitudinalControl = True and not params.get_bool("DisableOpenpilotLongitudinal") ret.pcmCruise = False ret.longitudinalTuning.deadzoneBP = [0.] diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py old mode 100755 new mode 100644 index 873c874..737f274 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -49,12 +49,12 @@ class CarInterface(CarInterfaceBase): # WARNING: THIS DISABLES AEB! # If Bosch radarless, this blocks ACC messages from the camera ret.experimentalLongitudinalAvailable = True - ret.openpilotLongitudinalControl = experimental_long + ret.openpilotLongitudinalControl = experimental_long and not params.get_bool("DisableOpenpilotLongitudinal") ret.pcmCruise = not ret.openpilotLongitudinalControl else: ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hondaNidec)] ret.enableGasInterceptor = 0x201 in fingerprint[0] - ret.openpilotLongitudinalControl = True + ret.openpilotLongitudinalControl = True and not params.get_bool("DisableOpenpilotLongitudinal") ret.pcmCruise = not ret.enableGasInterceptor diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 0df2163..b6a9853 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -275,7 +275,7 @@ class CarInterface(CarInterfaceBase): ret.longitudinalTuning.kpV = [0.5] ret.longitudinalTuning.kiV = [0.0] ret.experimentalLongitudinalAvailable = candidate not in (UNSUPPORTED_LONGITUDINAL_CAR | CAMERA_SCC_CAR) - ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable + ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable and not params.get_bool("DisableOpenpilotLongitudinal") ret.pcmCruise = not ret.openpilotLongitudinalControl ret.stoppingControl = True diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index d501965..3cd76ec 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -119,7 +119,7 @@ class CarInterface(CarInterfaceBase): raise ValueError(f"unknown car: {candidate}") ret.experimentalLongitudinalAvailable = candidate not in (GLOBAL_GEN2 | PREGLOBAL_CARS | LKAS_ANGLE | HYBRID_CARS) - ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable + ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable and not params.get_bool("DisableOpenpilotLongitudinal") if candidate in GLOBAL_GEN2 and ret.openpilotLongitudinalControl: ret.flags |= SubaruFlags.DISABLE_EYESIGHT.value diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py index 72e2b0d..ca06171 100755 --- a/selfdrive/car/tesla/interface.py +++ b/selfdrive/car/tesla/interface.py @@ -29,7 +29,7 @@ class CarInterface(CarInterfaceBase): # Check if we have messages on an auxiliary panda, and that 0x2bf (DAS_control) is present on the AP powertrain bus # If so, we assume that it is connected to the longitudinal harness. if (CANBUS.autopilot_powertrain in fingerprint.keys()) and (0x2bf in fingerprint[CANBUS.autopilot_powertrain].keys()): - ret.openpilotLongitudinalControl = True + ret.openpilotLongitudinalControl = True and not params.get_bool("DisableOpenpilotLongitudinal") ret.safetyConfigs = [ get_safety_config(car.CarParams.SafetyModel.tesla, Panda.FLAG_TESLA_LONG_CONTROL), get_safety_config(car.CarParams.SafetyModel.tesla, Panda.FLAG_TESLA_LONG_CONTROL | Panda.FLAG_TESLA_POWERTRAIN), diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 2aaf377..7c27b9e 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -251,6 +251,7 @@ class CarInterface(CarInterfaceBase): # - TSS2 radar ACC cars w/o smartDSU installed (disables radar) # - TSS-P DSU-less cars w/ CAN filter installed (no radar parser yet) ret.openpilotLongitudinalControl = use_sdsu or ret.enableDsu or candidate in (TSS2_CAR - RADAR_ACC_CAR) or bool(ret.flags & ToyotaFlags.DISABLE_RADAR.value) + ret.openpilotLongitudinalControl &= not params.get_bool("DisableOpenpilotLongitudinal") ret.autoResumeSng = ret.openpilotLongitudinalControl and candidate in NO_STOP_TIMER_CAR ret.enableGasInterceptor = 0x201 in fingerprint[0] and ret.openpilotLongitudinalControl diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py index b2f5db7..30df8d0 100644 --- a/selfdrive/car/volkswagen/interface.py +++ b/selfdrive/car/volkswagen/interface.py @@ -86,7 +86,7 @@ class CarInterface(CarInterfaceBase): ret.experimentalLongitudinalAvailable = ret.networkLocation == NetworkLocation.gateway or docs if experimental_long: # Proof-of-concept, prep for E2E only. No radar points available. Panda ALLOW_DEBUG firmware required. - ret.openpilotLongitudinalControl = True + ret.openpilotLongitudinalControl = True and not params.get_bool("DisableOpenpilotLongitudinal") ret.safetyConfigs[0].safetyParam |= Panda.FLAG_VOLKSWAGEN_LONG_CONTROL if ret.transmissionType == TransmissionType.manual: ret.minEnableSpeed = 4.5 diff --git a/selfdrive/frogpilot/ui/vehicle_settings.cc b/selfdrive/frogpilot/ui/vehicle_settings.cc index 48b111d..28c9081 100644 --- a/selfdrive/frogpilot/ui/vehicle_settings.cc +++ b/selfdrive/frogpilot/ui/vehicle_settings.cc @@ -1,6 +1,17 @@ #include "selfdrive/frogpilot/ui/vehicle_settings.h" FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) { + ParamControl *disableOpenpilotLong = new ParamControl("DisableOpenpilotLongitudinal", "Disable Openpilot Longitudinal Control", "Disables openpilot longitudinal control to use stock ACC.", "", this); + addItem(disableOpenpilotLong); + + QObject::connect(disableOpenpilotLong, &ToggleControl::toggleFlipped, [=]() { + if (started) { + if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) { + Hardware::reboot(); + } + } + }); + std::vector> vehicleToggles { {"LongitudinalTune", "Longitudinal Tune", "Use a custom Toyota longitudinal tune.\n\nCydia = More focused on TSS-P vehicles but works for all Toyotas\n\nDragonPilot = Focused on TSS2 vehicles\n\nFrogPilot = Takes the best of both worlds with some personal tweaks focused around my 2019 Lexus ES 350", ""}, };