diff --git a/selfdrive/ui/qt/offroad/developer_panel.cc b/selfdrive/ui/qt/offroad/developer_panel.cc index b4f6e588fd..5e127eb21f 100644 --- a/selfdrive/ui/qt/offroad/developer_panel.cc +++ b/selfdrive/ui/qt/offroad/developer_panel.cc @@ -24,13 +24,6 @@ DeveloperPanel::DeveloperPanel(SettingsWindow *parent) : ListWidget(parent) { }); addItem(longManeuverToggle); - alphaLongToggle = new ParamControl("ExperimentalLongitudinalEnabled", tr("openpilot Longitudinal Control (Alpha)"), "", "../assets/offroad/icon_speed_limit.png"); - QObject::connect(alphaLongToggle, &ParamControl::toggleFlipped, [=](bool state) { - updateToggles(offroad); - }); - addItem(alphaLongToggle); - alphaLongToggle->setConfirmation(true, false); - // Joystick and longitudinal maneuvers should be hidden on release branches is_release = params.getBool("IsReleaseBranch"); @@ -50,29 +43,8 @@ void DeveloperPanel::updateToggles(bool _offroad) { AlignedBuffer aligned_buf; capnp::FlatArrayMessageReader cmsg(aligned_buf.align(cp_bytes.data(), cp_bytes.size())); cereal::CarParams::Reader CP = cmsg.getRoot(); - - const QString alpha_long_description = QString("%1

%2") - .arg(tr("WARNING: openpilot longitudinal control is in alpha for this car and will disable Automatic Emergency Braking (AEB).")) - .arg(tr("On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. " - "Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha.")); - alphaLongToggle->setDescription("" + alpha_long_description + ""); - - if (!CP.getExperimentalLongitudinalAvailable() && !CP.getOpenpilotLongitudinalControl()) { - params.remove("ExperimentalLongitudinalEnabled"); - alphaLongToggle->setEnabled(false); - alphaLongToggle->setDescription("" + tr("openpilot longitudinal control may come in a future update.") + ""); - } - - // if is a release branch or if the car already have long control the alphaLongToggle should not be visible - if (is_release || CP.getOpenpilotLongitudinalControl()) { - params.remove("ExperimentalLongitudinalEnabled"); - alphaLongToggle->setVisible(false); - } - - alphaLongToggle->refresh(); longManeuverToggle->setEnabled(hasLongitudinalControl(CP) && _offroad); } else { - alphaLongToggle->setVisible(false); longManeuverToggle->setEnabled(false); } diff --git a/selfdrive/ui/qt/offroad/developer_panel.h b/selfdrive/ui/qt/offroad/developer_panel.h index 5e7e6c7395..fe38612e57 100644 --- a/selfdrive/ui/qt/offroad/developer_panel.h +++ b/selfdrive/ui/qt/offroad/developer_panel.h @@ -12,8 +12,6 @@ private: Params params; ParamControl* joystickToggle; ParamControl* longManeuverToggle; - ParamControl* alphaLongToggle; - bool is_release; bool offroad; diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 02a9284168..20d21d0dd6 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -24,6 +24,15 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { tr("Use the openpilot system for adaptive cruise control and lane keep driver assistance. Your attention is required at all times to use this feature. Changing this setting takes effect when the car is powered off."), "../assets/img_chffr_wheel.png", }, + { + "ExperimentalLongitudinalEnabled", + tr("openpilot Longitudinal Control (Alpha)"), + QString("%1

%2") + .arg(tr("WARNING: openpilot longitudinal control is in alpha for this car and will disable Automatic Emergency Braking (AEB).")) + .arg(tr("On this car, openpilot defaults to the car's built-in ACC instead of openpilot's longitudinal control. " + "Enable this to switch to openpilot longitudinal control. Enabling Experimental mode is recommended when enabling openpilot longitudinal control alpha.")), + "../assets/offroad/icon_speed_limit.png", + }, { "ExperimentalMode", tr("Experimental Mode"), @@ -92,6 +101,11 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { // Toggles with confirmation dialogs toggles["ExperimentalMode"]->setActiveIcon("../assets/img_experimental.svg"); toggles["ExperimentalMode"]->setConfirmation(true, true); + toggles["ExperimentalLongitudinalEnabled"]->setConfirmation(true, false); + + connect(toggles["ExperimentalLongitudinalEnabled"], &ToggleControl::toggleFlipped, [=]() { + updateToggles(); + }); } void TogglesPanel::updateState(const UIState &s) { @@ -116,6 +130,7 @@ void TogglesPanel::showEvent(QShowEvent *event) { void TogglesPanel::updateToggles() { auto experimental_mode_toggle = toggles["ExperimentalMode"]; + auto op_long_toggle = toggles["ExperimentalLongitudinalEnabled"]; const QString e2e_description = QString("%1
" "

%2


" "%3
" @@ -139,6 +154,7 @@ void TogglesPanel::updateToggles() { if (!CP.getExperimentalLongitudinalAvailable() || is_release) { params.remove("ExperimentalLongitudinalEnabled"); } + op_long_toggle->setVisible(CP.getExperimentalLongitudinalAvailable() && !is_release); if (hasLongitudinalControl(CP)) { // normal description and toggle experimental_mode_toggle->setEnabled(true); @@ -167,6 +183,7 @@ void TogglesPanel::updateToggles() { experimental_mode_toggle->refresh(); } else { experimental_mode_toggle->setDescription(e2e_description); + op_long_toggle->setVisible(false); } }