ui: disable toggles while onroad (#22975)

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 63779c385d
commatwo_master
Dean Lee 3 years ago committed by GitHub
parent 19c69ee0c2
commit 97ee5320f3
  1. 139
      selfdrive/ui/qt/offroad/settings.cc
  2. 47
      selfdrive/ui/qt/offroad/settings.h

@ -25,69 +25,88 @@
#include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/util.h"
#include "selfdrive/ui/qt/qt_window.h" #include "selfdrive/ui/qt/qt_window.h"
TogglesPanel::TogglesPanel(QWidget *parent) : ListWidget(parent) { TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
auto params = Params(); // param, title, desc, icon
addItem(new ParamControl("OpenpilotEnabledToggle", std::vector<std::tuple<QString, QString, QString, QString>> toggles{
"Enable openpilot", {
"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.", "OpenpilotEnabledToggle",
"../assets/offroad/icon_openpilot.png", "Enable openpilot",
this)); "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.",
addItem(new ParamControl("IsLdwEnabled", "../assets/offroad/icon_openpilot.png",
"Enable Lane Departure Warnings", },
"Receive alerts to steer back into the lane when your vehicle drifts over a detected lane line without a turn signal activated while driving over 31mph (50kph).", {
"../assets/offroad/icon_warning.png", "IsLdwEnabled",
this)); "Enable Lane Departure Warnings",
addItem(new ParamControl("IsRHD", "Receive alerts to steer back into the lane when your vehicle drifts over a detected lane line without a turn signal activated while driving over 31mph (50kph).",
"Enable Right-Hand Drive", "../assets/offroad/icon_warning.png",
"Allow openpilot to obey left-hand traffic conventions and perform driver monitoring on right driver seat.", },
"../assets/offroad/icon_openpilot_mirrored.png", {
this)); "IsRHD",
addItem(new ParamControl("IsMetric", "Enable Right-Hand Drive",
"Use Metric System", "Allow openpilot to obey left-hand traffic conventions and perform driver monitoring on right driver seat.",
"Display speed in km/h instead of mph.", "../assets/offroad/icon_openpilot_mirrored.png",
"../assets/offroad/icon_metric.png", },
this)); {
addItem(new ParamControl("CommunityFeaturesToggle", "IsMetric",
"Enable Community Features", "Use Metric System",
"Use features, such as community supported hardware, from the open source community that are not maintained or supported by comma.ai and have not been confirmed to meet the standard safety model. Be extra cautious when using these features", "Display speed in km/h instead of mph.",
"../assets/offroad/icon_shell.png", "../assets/offroad/icon_metric.png",
this)); },
{
addItem(new ParamControl("UploadRaw", "CommunityFeaturesToggle",
"Upload Raw Logs", "Enable Community Features",
"Upload full logs and full resolution video by default while on Wi-Fi. If not enabled, individual logs can be marked for upload at useradmin.comma.ai.", "Use features, such as community supported hardware, from the open source community that are not maintained or supported by comma.ai and have not been confirmed to meet the standard safety model. Be extra cautious when using these features",
"../assets/offroad/icon_network.png", "../assets/offroad/icon_shell.png",
this)); },
{
ParamControl *record_toggle = new ParamControl("RecordFront", "UploadRaw",
"Record and Upload Driver Camera", "Upload Raw Logs",
"Upload data from the driver facing camera and help improve the driver monitoring algorithm.", "Upload full logs and full resolution video by default while on Wi-Fi. If not enabled, individual logs can be marked for upload at useradmin.comma.ai.",
"../assets/offroad/icon_monitoring.png", "../assets/offroad/icon_network.png",
this); },
addItem(record_toggle); {
addItem(new ParamControl("EndToEndToggle", "RecordFront",
"\U0001f96c Disable use of lanelines (Alpha) \U0001f96c", "Record and Upload Driver Camera",
"In this mode openpilot will ignore lanelines and just drive how it thinks a human would.", "Upload data from the driver facing camera and help improve the driver monitoring algorithm.",
"../assets/offroad/icon_road.png", "../assets/offroad/icon_monitoring.png",
this)); },
{
"EndToEndToggle",
"\U0001f96c Disable use of lanelines (Alpha) \U0001f96c",
"In this mode openpilot will ignore lanelines and just drive how it thinks a human would.",
"../assets/offroad/icon_road.png",
},
#ifdef ENABLE_MAPS #ifdef ENABLE_MAPS
addItem(new ParamControl("NavSettingTime24h", {
"Show ETA in 24h format", "NavSettingTime24h",
"Use 24h format instead of am/pm", "Show ETA in 24h format",
"../assets/offroad/icon_metric.png", "Use 24h format instead of am/pm",
this)); "../assets/offroad/icon_metric.png",
},
#endif #endif
if (params.getBool("DisableRadar_Allow")) {
addItem(new ParamControl("DisableRadar",
"openpilot Longitudinal Control",
"openpilot will disable the car's radar and will take over control of gas and brakes. Warning: this disables AEB!",
"../assets/offroad/icon_speed_limit.png",
this));
};
Params params;
if (params.getBool("DisableRadar_Allow")) {
toggles.push_back({
"DisableRadar",
"openpilot Longitudinal Control",
"openpilot will disable the car's radar and will take over control of gas and brakes. Warning: this disables AEB!",
"../assets/offroad/icon_speed_limit.png",
});
} }
bool record_lock = params.getBool("RecordFrontLock"); for (auto &[param, title, desc, icon] : toggles) {
record_toggle->setEnabled(!record_lock); auto toggle = new ParamControl(param, title, desc, icon, this);
bool locked = params.getBool((param + "Lock").toStdString());
toggle->setEnabled(!locked);
if (!locked) {
connect(parent, &SettingsWindow::offroadTransition, toggle, &ParamControl::setEnabled);
}
addItem(toggle);
}
} }
DevicePanel::DevicePanel(QWidget* parent) : ListWidget(parent) { DevicePanel::DevicePanel(QWidget* parent) : ListWidget(parent) {
@ -123,8 +142,8 @@ DevicePanel::DevicePanel(QWidget* parent) : ListWidget(parent) {
double pitch = calib.getRpyCalib()[1] * (180 / M_PI); double pitch = calib.getRpyCalib()[1] * (180 / M_PI);
double yaw = calib.getRpyCalib()[2] * (180 / M_PI); double yaw = calib.getRpyCalib()[2] * (180 / M_PI);
desc += QString(" Your device is pointed %1° %2 and %3° %4.") desc += QString(" Your device is pointed %1° %2 and %3° %4.")
.arg(QString::number(std::abs(pitch), 'g', 1), pitch > 0 ? "up" : "down", .arg(QString::number(std::abs(pitch), 'g', 1), pitch > 0 ? "up" : "down",
QString::number(std::abs(yaw), 'g', 1), yaw > 0 ? "right" : "left"); QString::number(std::abs(yaw), 'g', 1), yaw > 0 ? "right" : "left");
} }
} catch (kj::Exception) { } catch (kj::Exception) {
qInfo() << "invalid CalibrationParams"; qInfo() << "invalid CalibrationParams";

@ -12,6 +12,28 @@
#include "selfdrive/ui/qt/widgets/controls.h" #include "selfdrive/ui/qt/widgets/controls.h"
// ********** settings window + top-level panels ********** // ********** settings window + top-level panels **********
class SettingsWindow : public QFrame {
Q_OBJECT
public:
explicit SettingsWindow(QWidget *parent = 0);
protected:
void hideEvent(QHideEvent *event) override;
void showEvent(QShowEvent *event) override;
signals:
void closeSettings();
void offroadTransition(bool offroad);
void reviewTrainingGuide();
void showDriverView();
private:
QPushButton *sidebar_alert_widget;
QWidget *sidebar_widget;
QButtonGroup *nav_btns;
QStackedWidget *panel_widget;
};
class DevicePanel : public ListWidget { class DevicePanel : public ListWidget {
Q_OBJECT Q_OBJECT
@ -25,7 +47,7 @@ signals:
class TogglesPanel : public ListWidget { class TogglesPanel : public ListWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit TogglesPanel(QWidget *parent = nullptr); explicit TogglesPanel(SettingsWindow *parent);
}; };
class SoftwarePanel : public ListWidget { class SoftwarePanel : public ListWidget {
@ -47,26 +69,3 @@ private:
Params params; Params params;
QFileSystemWatcher *fs_watch; QFileSystemWatcher *fs_watch;
}; };
class SettingsWindow : public QFrame {
Q_OBJECT
public:
explicit SettingsWindow(QWidget *parent = 0);
protected:
void hideEvent(QHideEvent *event) override;
void showEvent(QShowEvent *event) override;
signals:
void closeSettings();
void offroadTransition(bool offroad);
void reviewTrainingGuide();
void showDriverView();
private:
QPushButton *sidebar_alert_widget;
QWidget *sidebar_widget;
QButtonGroup *nav_btns;
QStackedWidget *panel_widget;
};

Loading…
Cancel
Save