From 3af959128d191929f8b016093585cb35e217a0d4 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Fri, 12 Jan 2024 22:39:30 -0700 Subject: [PATCH] Detect if the map is open --- selfdrive/ui/qt/maps/map_panel.cc | 5 +++++ selfdrive/ui/qt/maps/map_panel.h | 1 + selfdrive/ui/qt/onroad.cc | 27 ++++++++++++++------------- selfdrive/ui/qt/onroad.h | 1 + selfdrive/ui/ui.h | 1 + 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/selfdrive/ui/qt/maps/map_panel.cc b/selfdrive/ui/qt/maps/map_panel.cc index 0a2286f..7913314 100644 --- a/selfdrive/ui/qt/maps/map_panel.cc +++ b/selfdrive/ui/qt/maps/map_panel.cc @@ -41,3 +41,8 @@ void MapPanel::toggleMapSettings() { emit mapPanelRequested(); show(); } + +void MapPanel::setVisible(bool visible) { + QFrame::setVisible(visible); + uiState()->scene.map_open = visible; +} diff --git a/selfdrive/ui/qt/maps/map_panel.h b/selfdrive/ui/qt/maps/map_panel.h index 43a2cc7..1b0ba42 100644 --- a/selfdrive/ui/qt/maps/map_panel.h +++ b/selfdrive/ui/qt/maps/map_panel.h @@ -9,6 +9,7 @@ class MapPanel : public QFrame { public: explicit MapPanel(const QMapboxGLSettings &settings, QWidget *parent = nullptr); + void setVisible(bool visible); signals: void mapPanelRequested(); diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 018dd9d..f446b65 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -1024,6 +1024,7 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) { laneWidthLeft = scene.lane_width_left; laneWidthRight = scene.lane_width_right; leadInfo = scene.lead_info; + mapOpen = scene.map_open; obstacleDistance = scene.obstacle_distance; obstacleDistanceStock = scene.obstacle_distance_stock; stoppedEquivalence = scene.stopped_equivalence; @@ -1091,7 +1092,7 @@ void AnnotatedCameraWidget::drawLeadInfo(QPainter &p) { // Constants for units and conversions QString unit_a = " m/s²"; - QString unit_d = "meters"; + QString unit_d = mapOpen ? "m" : "meters"; QString unit_s = "kmh"; float distanceConversion = 1.0f; float speedConversion = 1.0f; @@ -1104,7 +1105,7 @@ void AnnotatedCameraWidget::drawLeadInfo(QPainter &p) { if (!(is_metric || useSI)) { // US imperial conversion unit_a = " ft/s²"; - unit_d = "feet"; + unit_d = mapOpen ? "ft" : "feet"; unit_s = "mph"; distanceConversion = toFeet; speedConversion = toMph; @@ -1132,13 +1133,13 @@ void AnnotatedCameraWidget::drawLeadInfo(QPainter &p) { .arg(currentAcceleration * speedConversion, 0, 'f', 2) .arg(unit_a); - QString maxAccSuffix = QString(" - Max: %1%2") + QString maxAccSuffix = QString(mapOpen ? "" : " - Max: %1%2") .arg(maxAcceleration * speedConversion, 0, 'f', 2) .arg(unit_a); - QString obstacleText = createText(" | Obstacle Factor: ", obstacleDistance); - QString stopText = createText(" - Stop Factor: ", stoppedEquivalence); - QString followText = " = " + createText("Follow Distance: ", desiredFollow); + QString obstacleText = createText(mapOpen ? " | Obstacle: " : " | Obstacle Factor: ", obstacleDistance); + QString stopText = createText(mapOpen ? " - Stop: " : " - Stop Factor: ", stoppedEquivalence); + QString followText = " = " + createText(mapOpen ? "Follow: " : "Follow Distance: ", desiredFollow); // Check if the longitudinal toggles have an impact on the driving logics auto createDiffText = [&](const double data, const double stockData) { @@ -1211,18 +1212,18 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) { {2, "Experimental Mode manually activated"}, {3, "Conditional Experimental overridden"}, {4, "Experimental Mode manually activated"}, - {5, "Experimental Mode activated for navigation" + (QString(" instructions input"))}, - {6, "Experimental Mode activated due to" + (QString(" no speed limit set"))}, - {7, "Experimental Mode activated due to" + (" speed being less than " + QString::number(conditionalSpeedLead) + (is_metric ? " kph" : " mph"))}, - {8, "Experimental Mode activated due to" + (" speed being less than " + QString::number(conditionalSpeed) + (is_metric ? " kph" : " mph"))}, + {5, "Experimental Mode activated for navigation" + (mapOpen ? "" : QString(" instructions input"))}, + {6, "Experimental Mode activated due to" + (mapOpen ? "SLC" : QString(" no speed limit set"))}, + {7, "Experimental Mode activated due to" + (mapOpen ? " speed" : " speed being less than " + QString::number(conditionalSpeedLead) + (is_metric ? " kph" : " mph"))}, + {8, "Experimental Mode activated due to" + (mapOpen ? " speed" : " speed being less than " + QString::number(conditionalSpeed) + (is_metric ? " kph" : " mph"))}, {9, "Experimental Mode activated for slower lead"}, - {10, "Experimental Mode activated for turn" + (QString(" / lane change"))}, + {10, "Experimental Mode activated for turn" + (mapOpen ? "" : QString(" / lane change"))}, {11, "Experimental Mode activated for curve"}, - {12, "Experimental Mode activated for stop" + (QString(" sign / stop light"))} + {12, "Experimental Mode activated for stop" + (mapOpen ? "" : QString(" sign / stop light"))}, }; if (alwaysOnLateral) { - newStatus = QString("Always On Lateral active") + (". Press the \"Cruise Control\" button to disable"); + newStatus = QString("Always On Lateral active") + (mapOpen ? "" : ". Press the \"Cruise Control\" button to disable"); } else if (conditionalExperimental) { newStatus = conditionalStatusMap.contains(conditionalStatus) && status != STATUS_DISENGAGED ? conditionalStatusMap[conditionalStatus] : conditionalStatusMap[0]; } diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index 0397ccb..c4f956f 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -134,6 +134,7 @@ private: bool conditionalExperimental; bool experimentalMode; bool leadInfo; + bool mapOpen; bool turnSignalLeft; bool turnSignalRight; bool useSI; diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index f5c0200..e485636 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -182,6 +182,7 @@ typedef struct UIScene { bool enabled; bool experimental_mode; bool lead_info; + bool map_open; bool model_ui; bool show_fps; bool turn_signal_left;