DLP: move selector to SP - Controls menu (#220)

* DLP: move options to SP - Controls

* remove driving ui button

* Update CHANGELOGS.md
This commit is contained in:
Jason Wen
2023-08-06 23:26:16 -04:00
committed by GitHub
parent a22b22d4ae
commit c3fd676e67
6 changed files with 83 additions and 62 deletions
+2
View File
@@ -1,6 +1,8 @@
sunnypilot - 0.9.4.1 (2023-08-xx)
========================
* UPDATED: Synced with commaai's 0.9.4 release
* UPDATED: Dynamic Lane Profile selector in the "SP - Controls" menu
* REMOVED: Dynamic Lane Profile driving screen UI button
* FIXED: Disallow torque lateral control for angle control platforms (e.g. Ford, Nissan, Tesla)
* Torque lateral control cannot be used by angle control platforms, and would cause a "Controls Unresponsive" error if Torque lateral control is enforced in settings
* Honda Accord 2016-17 support thanks to mlocoteta!
+52 -7
View File
@@ -165,12 +165,7 @@ SPControlsPanel::SPControlsPanel(QWidget *parent) : ListWidget(parent) {
tr("Enable this toggle to block lane change when road edge is detected on the stalk actuated side."),
"../assets/offroad/icon_openpilot.png",
},
{
"DynamicLaneProfileToggle",
tr("Enable Dynamic Lane Profile"),
tr("Enable toggle to use Dynamic Lane Profile. Disable toggle to use Laneless only."),
"../assets/offroad/icon_road.png",
},
// Dynamic Lane Profile group will fit here
{
"VisionCurveLaneless",
tr("Laneless for Curves in \"Auto lane\""),
@@ -265,11 +260,16 @@ SPControlsPanel::SPControlsPanel(QWidget *parent) : ListWidget(parent) {
},
};
// Controls: Dynamic Lane Profile group
auto dynamic_lane_profile = new DynamicLaneProfile(this);
// toggle names to trigger updateToggles() when toggleFlipped
std::vector<std::string> updateTogglesNames{
"EnableMads", "DynamicLaneProfileToggle", "CustomOffsets", "GapAdjustCruise", "EnforceTorqueLateral",
"EnableMads", "CustomOffsets", "GapAdjustCruise", "EnforceTorqueLateral",
"SpeedLimitPercOffset", "SpeedLimitControl"
};
connect(dynamic_lane_profile, &DynamicLaneProfile::updateExternalToggles, this, &SPControlsPanel::updateToggles);
// toggle names to trigger updateToggles() when toggleFlipped and display ConfirmationDialog::alert
std::vector<std::string> updateTogglesNamesAlert{
"CustomTorqueLateral", "LiveTorque"
@@ -305,6 +305,11 @@ SPControlsPanel::SPControlsPanel(QWidget *parent) : ListWidget(parent) {
addItem(toggle);
toggles[param.toStdString()] = toggle;
if (param == "RoadEdge") {
// Controls: Dynamic Lane Profile group
addItem(dynamic_lane_profile);
}
if (param == "CustomOffsets") {
// Controls: Camera Offset (cm)
addItem(camera_offset);
@@ -1843,3 +1848,43 @@ void SidebarTemp::showEvent(QShowEvent *event) {
void SidebarTemp::updateToggles() {
sidebar_temp_setting->setVisible(params.getBool("SidebarTemperature"));
}
DynamicLaneProfile::DynamicLaneProfile(QWidget *parent) : QWidget(parent), outer_layout(this) {
outer_layout.setMargin(0);
outer_layout.setSpacing(0);
outer_layout.addLayout(&inner_layout);
inner_layout.setMargin(0);
//inner_layout.setSpacing(25); // default spacing is 25
outer_layout.addStretch();
dynamicLaneProfile = new ParamControl(
"DynamicLaneProfileToggle",
tr("Enable Dynamic Lane Profile"),
tr("Enable toggle to use Dynamic Lane Profile. Disable toggle to use Laneless only."),
"../assets/offroad/icon_road.png"
);
std::vector<QString> dlp_settings_texts{tr("Laneful"), tr("Laneless"), tr("Auto")};
dlp_settings = new ButtonParamControl(
"DynamicLaneProfile", "", "",
"../assets/offroad/icon_blank.png",
dlp_settings_texts
);
connect(dynamicLaneProfile, &ToggleControl::toggleFlipped, [=]() {
updateToggles();
emit updateExternalToggles();
});
addItem(dynamicLaneProfile);
addItem(dlp_settings);
}
void DynamicLaneProfile::showEvent(QShowEvent *event) {
updateToggles();
}
void DynamicLaneProfile::updateToggles() {
// toggle names to update when DynamicLaneProfile is flipped
dlp_settings->setVisible(params.getBool("DynamicLaneProfileToggle"));
}
@@ -264,6 +264,31 @@ private:
ButtonParamControl *sidebar_temp_setting;
};
class DynamicLaneProfile : public QWidget {
Q_OBJECT
public:
explicit DynamicLaneProfile(QWidget *parent = nullptr);
void showEvent(QShowEvent *event) override;
signals:
void updateExternalToggles();
public slots:
void updateToggles();
private:
inline void addItem(QWidget *w) { inner_layout.addWidget(w); }
inline void addItem(QLayout *layout) { inner_layout.addLayout(layout); }
inline void setSpacing(int spacing) { inner_layout.setSpacing(spacing); }
QVBoxLayout outer_layout;
QVBoxLayout inner_layout;
Params params;
ParamControl *dynamicLaneProfile;
ButtonParamControl *dlp_settings;
};
class SPGeneralPanel : public ListWidget {
Q_OBJECT
+3 -47
View File
@@ -147,17 +147,11 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) {
auto longitudinal_plan = sm["longitudinalPlan"].getLongitudinalPlan();
auto car_state = sm["carState"].getCarState();
QRect dlp_btn_rect = QRect(scene.dlp_btn, (rect().bottom() - (UI_BORDER_SIZE + btn_size / 2) - 75) - scene.rn_offset, 150, 150);
QRect gac_btn_rect = QRect(scene.gac_btn, (rect().bottom() - (UI_BORDER_SIZE + btn_size / 2) - 75) - scene.rn_offset, 150, 150);
QRect debug_tap_rect = QRect(rect().center().x() - 200, rect().center().y() - 200, 400, 400);
QRect speed_limit_touch_rect = speed_sgn_rc.adjusted(-50, -50, 50, 50);
if (scene.dynamic_lane_profile_toggle && scene.sleep_btn_opacity == 20 && dlp_btn_rect.contains(e->x(), e->y())) {
scene.dynamic_lane_profile++;
scene.dynamic_lane_profile = scene.dynamic_lane_profile > 2 ? 0 : scene.dynamic_lane_profile;
params.put("DynamicLaneProfile", std::to_string(scene.dynamic_lane_profile));
propagate_event = false;
} else if (scene.gac && scene.gac_mode != 0 && scene.longitudinal_control && car_state.getCruiseState().getAvailable() &&
if (scene.gac && scene.gac_mode != 0 && scene.longitudinal_control && car_state.getCruiseState().getAvailable() &&
scene.sleep_btn_opacity == 20 && gac_btn_rect.contains(e->x(), e->y())) {
scene.gac_tr--;
scene.gac_tr = scene.gac_tr < scene.gac_min ? scene.gac_max : scene.gac_tr;
@@ -467,9 +461,6 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
setProperty("latActive", car_control.getLatActive());
setProperty("madsEnabled", car_state.getMadsEnabled());
setProperty("dynamicLaneProfileToggle", s.scene.dynamic_lane_profile_toggle);
setProperty("dynamicLaneProfile", s.scene.dynamic_lane_profile);
setProperty("brakeLights", car_state.getBrakeLights() && s.scene.visual_brake_lights);
setProperty("standStillTimer", s.scene.stand_still_timer);
@@ -789,16 +780,14 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
}
// counts total number of UI buttons to display; modify this if add/change/remove UI buttons
bool dlp_on = dynamicLaneProfileToggle;
bool gac_on = gac;
int total_ui_buttons = int(dlp_on) + int(gac_on);
int total_ui_buttons = int(gac_on);
int btnValues[total_ui_buttons];
for (int i = 0; i < total_ui_buttons; i++) {
btnValues[i] = UI_BORDER_SIZE * 2 + 220 + (i * 180);
}
uiState()->scene.dlp_btn = dlp_on ? btnValues[0] : 0;
uiState()->scene.gac_btn = dlp_on ? btnValues[1] : btnValues[0];
uiState()->scene.gac_btn = gac_on ? btnValues[0] : 0;
if (!reversing) {
// ####### 1 ROW #######
@@ -820,11 +809,6 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
rn_btn = devUiEnabled && !mapVisible && devUiInfo == 1 ? 30 : 0;
uiState()->scene.rn_offset = rn_btn;
// Dynamic Lane Profile Button
if (dynamicLaneProfileToggle) {
drawDlpButton(p, uiState()->scene.dlp_btn, (rect().bottom() - (UI_BORDER_SIZE + btn_size / 2) - 75) - rn_btn, 150, 150);
}
if (gac) {
drawGacButton(p, uiState()->scene.gac_btn, (rect().bottom() - (UI_BORDER_SIZE + btn_size / 2) - 75) - rn_btn, 150, 150);
}
@@ -911,34 +895,6 @@ void AnnotatedCameraWidget::drawVisionTurnControllerUI(QPainter &p, int x, int y
drawCenteredText(p, rvtc.center().x(), rvtc.center().y(), vision_speed, color);
}
void AnnotatedCameraWidget::drawDlpButton(QPainter &p, int x, int y, int w, int h) {
int prev_dynamic_lane_profile = -1;
QString dlp_text = "";
QColor dlp_border = QColor(255, 255, 255, (255 * btnPerc));
if (prev_dynamic_lane_profile != dynamicLaneProfile) {
prev_dynamic_lane_profile = dynamicLaneProfile;
if (dynamicLaneProfile == 0) {
dlp_text = tr("Lane\nonly");
dlp_border = QColor(32, 32, 248, (255 * btnPerc));
} else if (dynamicLaneProfile == 1) {
dlp_text = tr("Lane\nless");
dlp_border = QColor(13, 248, 122, (255 * btnPerc));
} else if (dynamicLaneProfile == 2) {
dlp_text = tr("Auto\nLane");
dlp_border = QColor(13, 248, 248, (255 * btnPerc));
}
}
QRect dlpBtn(x, y, w, h);
p.setPen(QPen(dlp_border, 6));
p.setBrush(QColor(75, 75, 75, (75 * btnPerc)));
p.drawEllipse(dlpBtn);
p.setPen(QColor(255, 255, 255, (255 * btnPerc)));
p.setFont(InterFont(36, QFont::DemiBold));
p.drawText(dlpBtn, Qt::AlignCenter, dlp_text);
}
void AnnotatedCameraWidget::drawGacButton(QPainter &p, int x, int y, int w, int h) {
int prev_gac_tr = -1;
QString gac_text = "";
-7
View File
@@ -90,9 +90,6 @@ class AnnotatedCameraWidget : public CameraWidget {
Q_PROPERTY(bool latActive MEMBER latActive);
Q_PROPERTY(bool madsEnabled MEMBER madsEnabled);
Q_PROPERTY(bool dynamicLaneProfileToggle MEMBER dynamicLaneProfileToggle);
Q_PROPERTY(int dynamicLaneProfile MEMBER dynamicLaneProfile);
Q_PROPERTY(bool brakeLights MEMBER brakeLights);
Q_PROPERTY(bool standStillTimer MEMBER standStillTimer);
@@ -182,7 +179,6 @@ private:
void drawTrunSpeedSign(QPainter &p, QRect rc, const QString &speed, const QString &sub_text, int curv_sign,
bool is_active);
void drawDlpButton(QPainter &p, int x, int y, int w, int h);
void drawGacButton(QPainter &p, int x, int y, int w, int h);
void drawColoredText(QPainter &p, int x, int y, const QString &text, QColor color);
void drawStandstillTimer(QPainter &p, int x, int y);
@@ -236,9 +232,6 @@ private:
bool latActive = false;
bool madsEnabled = false;
bool dynamicLaneProfileToggle;
int dynamicLaneProfile;
bool brakeLights;
bool standStillTimer;
+1 -1
View File
@@ -210,7 +210,7 @@ typedef struct UIScene {
int sidebar_temp_options;
// UI button sorting
int dlp_btn, gac_btn;
int gac_btn;
} UIScene;
class UIState : public QObject {