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. 75
      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{
{
"OpenpilotEnabledToggle",
"Enable openpilot", "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.", "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/offroad/icon_openpilot.png", "../assets/offroad/icon_openpilot.png",
this)); },
addItem(new ParamControl("IsLdwEnabled", {
"IsLdwEnabled",
"Enable Lane Departure Warnings", "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).", "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", "../assets/offroad/icon_warning.png",
this)); },
addItem(new ParamControl("IsRHD", {
"IsRHD",
"Enable Right-Hand Drive", "Enable Right-Hand Drive",
"Allow openpilot to obey left-hand traffic conventions and perform driver monitoring on right driver seat.", "Allow openpilot to obey left-hand traffic conventions and perform driver monitoring on right driver seat.",
"../assets/offroad/icon_openpilot_mirrored.png", "../assets/offroad/icon_openpilot_mirrored.png",
this)); },
addItem(new ParamControl("IsMetric", {
"IsMetric",
"Use Metric System", "Use Metric System",
"Display speed in km/h instead of mph.", "Display speed in km/h instead of mph.",
"../assets/offroad/icon_metric.png", "../assets/offroad/icon_metric.png",
this)); },
addItem(new ParamControl("CommunityFeaturesToggle", {
"CommunityFeaturesToggle",
"Enable Community Features", "Enable Community Features",
"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", "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_shell.png", "../assets/offroad/icon_shell.png",
this)); },
{
addItem(new ParamControl("UploadRaw", "UploadRaw",
"Upload Raw Logs", "Upload Raw Logs",
"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.", "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_network.png", "../assets/offroad/icon_network.png",
this)); },
{
ParamControl *record_toggle = new ParamControl("RecordFront", "RecordFront",
"Record and Upload Driver Camera", "Record and Upload Driver Camera",
"Upload data from the driver facing camera and help improve the driver monitoring algorithm.", "Upload data from the driver facing camera and help improve the driver monitoring algorithm.",
"../assets/offroad/icon_monitoring.png", "../assets/offroad/icon_monitoring.png",
this); },
addItem(record_toggle); {
addItem(new ParamControl("EndToEndToggle", "EndToEndToggle",
"\U0001f96c Disable use of lanelines (Alpha) \U0001f96c", "\U0001f96c Disable use of lanelines (Alpha) \U0001f96c",
"In this mode openpilot will ignore lanelines and just drive how it thinks a human would.", "In this mode openpilot will ignore lanelines and just drive how it thinks a human would.",
"../assets/offroad/icon_road.png", "../assets/offroad/icon_road.png",
this)); },
#ifdef ENABLE_MAPS #ifdef ENABLE_MAPS
addItem(new ParamControl("NavSettingTime24h", {
"NavSettingTime24h",
"Show ETA in 24h format", "Show ETA in 24h format",
"Use 24h format instead of am/pm", "Use 24h format instead of am/pm",
"../assets/offroad/icon_metric.png", "../assets/offroad/icon_metric.png",
this)); },
#endif #endif
};
Params params;
if (params.getBool("DisableRadar_Allow")) { if (params.getBool("DisableRadar_Allow")) {
addItem(new ParamControl("DisableRadar", toggles.push_back({
"DisableRadar",
"openpilot Longitudinal Control", "openpilot Longitudinal Control",
"openpilot will disable the car's radar and will take over control of gas and brakes. Warning: this disables AEB!", "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", "../assets/offroad/icon_speed_limit.png",
this)); });
} }
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) {

@ -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