mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-07 08:33:42 +08:00
7e5a84b897
# Conflicts: # opendbc_repo # panda # selfdrive/modeld/fill_model_msg.py # selfdrive/pandad/pandad.cc # selfdrive/test/process_replay/ref_commit # selfdrive/ui/qt/home.h # selfdrive/ui/qt/offroad/developer_panel.cc # selfdrive/ui/qt/offroad/developer_panel.h # selfdrive/ui/tests/test_ui/run.py # selfdrive/ui/translations/main_ar.ts # selfdrive/ui/translations/main_de.ts # selfdrive/ui/translations/main_es.ts # selfdrive/ui/translations/main_ko.ts # selfdrive/ui/translations/main_pt-BR.ts # selfdrive/ui/translations/main_th.ts # selfdrive/ui/translations/main_tr.ts # selfdrive/ui/translations/main_zh-CHS.ts # selfdrive/ui/translations/main_zh-CHT.ts
124 lines
5.0 KiB
C++
124 lines
5.0 KiB
C++
#include <QDebug>
|
|
#include <QProcess>
|
|
|
|
#include "selfdrive/ui/qt/offroad/developer_panel.h"
|
|
#include "selfdrive/ui/qt/widgets/ssh_keys.h"
|
|
#include "common/util.h"
|
|
|
|
#ifdef SUNNYPILOT
|
|
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
|
#else
|
|
#include "selfdrive/ui/qt/widgets/controls.h"
|
|
#endif
|
|
|
|
DeveloperPanel::DeveloperPanel(SettingsWindow *parent) : ListWidget(parent) {
|
|
adbToggle = new ParamControl("AdbEnabled", tr("Enable ADB"),
|
|
tr("ADB (Android Debug Bridge) allows connecting to your device over USB or over the network. See https://docs.comma.ai/how-to/connect-to-comma for more info."), "");
|
|
addItem(adbToggle);
|
|
|
|
// SSH keys
|
|
addItem(new SshToggle());
|
|
addItem(new SshControl());
|
|
|
|
joystickToggle = new ParamControl("JoystickDebugMode", tr("Joystick Debug Mode"), "", "");
|
|
QObject::connect(joystickToggle, &ParamControl::toggleFlipped, [=](bool state) {
|
|
params.putBool("LongitudinalManeuverMode", false);
|
|
longManeuverToggle->refresh();
|
|
});
|
|
addItem(joystickToggle);
|
|
|
|
longManeuverToggle = new ParamControl("LongitudinalManeuverMode", tr("Longitudinal Maneuver Mode"), "", "");
|
|
QObject::connect(longManeuverToggle, &ParamControl::toggleFlipped, [=](bool state) {
|
|
params.putBool("JoystickDebugMode", false);
|
|
joystickToggle->refresh();
|
|
});
|
|
addItem(longManeuverToggle);
|
|
|
|
experimentalLongitudinalToggle = new ParamControl(
|
|
"ExperimentalLongitudinalEnabled",
|
|
tr("openpilot Longitudinal Control (Alpha)"),
|
|
QString("<b>%1</b><br><br>%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.")),
|
|
""
|
|
);
|
|
experimentalLongitudinalToggle->setConfirmation(true, false);
|
|
QObject::connect(experimentalLongitudinalToggle, &ParamControl::toggleFlipped, [=]() {
|
|
updateToggles(offroad);
|
|
});
|
|
addItem(experimentalLongitudinalToggle);
|
|
|
|
// TODO-SP: Move to Vehicles panel when ported back
|
|
hyundaiRadarTracksToggle = new ParamControl(
|
|
"HyundaiRadarTracksToggle",
|
|
tr("Hyundai: Enable Radar Tracks"),
|
|
tr("Enable this to attempt to enable radar tracks for Hyundai, Kia, and Genesis models equipped with the supported Mando SCC radar. "
|
|
"This allows sunnypilot to use radar data for improved lead tracking and overall longitudinal performance."), "");
|
|
hyundaiRadarTracksToggle->setConfirmation(true, false);
|
|
QObject::connect(hyundaiRadarTracksToggle, &ParamControl::toggleFlipped, [=](bool state) {
|
|
updateToggles(offroad);
|
|
});
|
|
addItem(hyundaiRadarTracksToggle);
|
|
|
|
auto enableGithubRunner = new ParamControl("EnableGithubRunner", tr("Enable GitHub runner service"), tr("Enables or disables the github runner service."), "");
|
|
addItem(enableGithubRunner);
|
|
|
|
// Joystick and longitudinal maneuvers should be hidden on release branches
|
|
is_release = params.getBool("IsReleaseBranch");
|
|
|
|
// Toggles should be not available to change in onroad state
|
|
QObject::connect(uiState(), &UIState::offroadTransition, this, &DeveloperPanel::updateToggles);
|
|
}
|
|
|
|
void DeveloperPanel::updateToggles(bool _offroad) {
|
|
for (auto btn : findChildren<ParamControl *>()) {
|
|
btn->setVisible(!is_release);
|
|
|
|
/*
|
|
* experimentalLongitudinalToggle should be toggelable when:
|
|
* - visible, and
|
|
* - during onroad & offroad states
|
|
*/
|
|
if (btn != experimentalLongitudinalToggle) {
|
|
btn->setEnabled(_offroad);
|
|
}
|
|
}
|
|
|
|
// longManeuverToggle and experimentalLongitudinalToggle should not be toggleable if the car does not have longitudinal control
|
|
auto cp_bytes = params.get("CarParamsPersistent");
|
|
if (!cp_bytes.empty()) {
|
|
AlignedBuffer aligned_buf;
|
|
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(cp_bytes.data(), cp_bytes.size()));
|
|
cereal::CarParams::Reader CP = cmsg.getRoot<cereal::CarParams>();
|
|
|
|
auto hyundai = CP.getBrand() == "hyundai";
|
|
auto hyundai_mando_radar = hyundai && (CP.getFlags() & 4096);
|
|
|
|
if (!CP.getExperimentalLongitudinalAvailable() || is_release) {
|
|
params.remove("ExperimentalLongitudinalEnabled");
|
|
experimentalLongitudinalToggle->setEnabled(false);
|
|
}
|
|
|
|
/*
|
|
* experimentalLongitudinalToggle should be visible when:
|
|
* - is not a release branch, and
|
|
* - the car supports experimental longitudinal control (alpha)
|
|
*/
|
|
experimentalLongitudinalToggle->setVisible(CP.getExperimentalLongitudinalAvailable() && !is_release);
|
|
|
|
longManeuverToggle->setEnabled(hasLongitudinalControl(CP) && _offroad);
|
|
hyundaiRadarTracksToggle->setVisible(hyundai_mando_radar && hasLongitudinalControl(CP));
|
|
} else {
|
|
longManeuverToggle->setEnabled(false);
|
|
experimentalLongitudinalToggle->setVisible(false);
|
|
hyundaiRadarTracksToggle->setVisible(false);
|
|
}
|
|
|
|
offroad = _offroad;
|
|
}
|
|
|
|
void DeveloperPanel::showEvent(QShowEvent *event) {
|
|
updateToggles(offroad);
|
|
}
|