diff --git a/frogpilot/common/frogpilot_variables.py b/frogpilot/common/frogpilot_variables.py index e938943d7..63ac3cee5 100644 --- a/frogpilot/common/frogpilot_variables.py +++ b/frogpilot/common/frogpilot_variables.py @@ -268,8 +268,10 @@ class FrogPilotVariables: else: FPCP = interfaces[MOCK.MOCK].get_frogpilot_params(MOCK.MOCK, gen_empty_fingerprint(), [], CP, toggle) + alpha_longitudinal = CP.alphaLongitudinalAvailable toggle.car_make = CP.brand toggle.car_model = CP.carFingerprint + toggle.disable_openpilot_long = self.get_value("DisableOpenpilotLongitudinal", condition=not alpha_longitudinal) friction = CP.lateralTuning.torque.friction has_bsm = CP.enableBsm toggle.has_cc_long = toggle.car_make == "gm" and bool(CP.flags & GMFlags.CC_LONG.value) diff --git a/frogpilot/ui/qt/offroad/vehicle_settings.cc b/frogpilot/ui/qt/offroad/vehicle_settings.cc index 7f78b2667..e4c8afd37 100644 --- a/frogpilot/ui/qt/offroad/vehicle_settings.cc +++ b/frogpilot/ui/qt/offroad/vehicle_settings.cc @@ -12,6 +12,26 @@ FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(FrogPilotSettingsWindow *parent, vehiclesLayout->addWidget(vehiclesPanel); + disableOpenpilotLong = new ParamControl("DisableOpenpilotLongitudinal", tr("Disable openpilot Longitudinal Control"), tr("Disable openpilot longitudinal and use the car's stock ACC instead."), ""); + QObject::connect(disableOpenpilotLong, &ToggleControl::toggleFlipped, [parent, this](bool state) { + if (state) { + if (FrogPilotConfirmationDialog::yesorno(tr("Are you sure you want to completely disable openpilot longitudinal control?"), this)) { + if (started) { + if (FrogPilotConfirmationDialog::toggleReboot(this)) { + Hardware::reboot(); + } + } + } else { + params.putBool("DisableOpenpilotLongitudinal", false); + disableOpenpilotLong->refresh(); + } + } + + parent->updateVariables(); + updateToggles(); + }); + settingsList->addItem(disableOpenpilotLong); + FrogPilotListWidget *gmList = new FrogPilotListWidget(this); FrogPilotListWidget *hkgList = new FrogPilotListWidget(this); FrogPilotListWidget *subaruList = new FrogPilotListWidget(this); @@ -178,6 +198,7 @@ FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(FrogPilotSettingsWindow *parent, QObject::connect(parent, &FrogPilotSettingsWindow::closeSubPanel, [vehiclesLayout, vehiclesPanel, this] { if (forceOpenDescriptions) { openDescriptions(forceOpenDescriptions, toggles); + disableOpenpilotLong->showDescription(); } vehiclesLayout->setCurrentWidget(vehiclesPanel); }); @@ -186,6 +207,7 @@ FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(FrogPilotSettingsWindow *parent, void FrogPilotVehiclesPanel::showEvent(QShowEvent *event) { if (forceOpenDescriptions) { + disableOpenpilotLong->showDescription(); } QStringList detected; @@ -275,6 +297,8 @@ void FrogPilotVehiclesPanel::updateToggles() { } } + disableOpenpilotLong->setVisible((parent->hasOpenpilotLongitudinal || parent->openpilotLongitudinalControlDisabled) && !parent->hasAlphaLongitudinal && parent->tuningLevel >= parent->frogpilotToggleLevels["DisableOpenpilotLongitudinal"].toBool()); + openDescriptions(forceOpenDescriptions, toggles); update(); diff --git a/frogpilot/ui/qt/offroad/vehicle_settings.h b/frogpilot/ui/qt/offroad/vehicle_settings.h index 4716593d7..4494e56d9 100644 --- a/frogpilot/ui/qt/offroad/vehicle_settings.h +++ b/frogpilot/ui/qt/offroad/vehicle_settings.h @@ -34,5 +34,7 @@ private: FrogPilotSettingsWindow *parent; + ParamControl *disableOpenpilotLong; + Params params; }; diff --git a/opendbc_repo/opendbc/car/car_helpers.py b/opendbc_repo/opendbc/car/car_helpers.py index b75886637..78b35c354 100644 --- a/opendbc_repo/opendbc/car/car_helpers.py +++ b/opendbc_repo/opendbc/car/car_helpers.py @@ -175,6 +175,10 @@ def get_car(can_recv: CanRecvCallable, can_send: CanSendCallable, set_obd_multip # FrogPilot variables FPCP: FrogPilotCarParams = CarInterface.get_frogpilot_params(candidate, fingerprints, car_fw, CP, frogpilot_toggles) + if not CP.alphaLongitudinalAvailable and frogpilot_toggles.disable_openpilot_long: + CP.openpilotLongitudinalControl = False + FPCP.openpilotLongitudinalControlDisabled = True + return interfaces[CP.carFingerprint](CP, FPCP) diff --git a/selfdrive/ui/qt/util.cc b/selfdrive/ui/qt/util.cc index e89746fb6..b6621e7b1 100644 --- a/selfdrive/ui/qt/util.cc +++ b/selfdrive/ui/qt/util.cc @@ -198,9 +198,10 @@ QPixmap bootstrapPixmap(const QString &id) { bool hasLongitudinalControl(const cereal::CarParams::Reader &car_params) { // Using the experimental longitudinal toggle, returns whether longitudinal control // will be active without needing a restart of openpilot - return car_params.getAlphaLongitudinalAvailable() - ? Params().getBool("AlphaLongitudinalEnabled") - : car_params.getOpenpilotLongitudinalControl(); + Params params = Params(); + return (car_params.getAlphaLongitudinalAvailable() + ? params.getBool("AlphaLongitudinalEnabled") + : car_params.getOpenpilotLongitudinalControl()) && !params.getBool("DisableOpenpilotLongitudinal"); } // ParamWatcher