diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index b4181f82b7..b674d39fbd 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -55,6 +55,10 @@ void HomeWindow::showSidebar(bool show) { sidebar->setVisible(show); } +void HomeWindow::showMapPanel(bool show) { + onroad->showMapPanel(show); +} + void HomeWindow::updateState(const UIState &s) { const SubMaster &sm = *(s.sm); diff --git a/selfdrive/ui/qt/home.h b/selfdrive/ui/qt/home.h index ed1c215467..c6032852a1 100644 --- a/selfdrive/ui/qt/home.h +++ b/selfdrive/ui/qt/home.h @@ -55,6 +55,7 @@ public slots: void offroadTransition(bool offroad); void showDriverView(bool show); void showSidebar(bool show); + void showMapPanel(bool show); protected: void mousePressEvent(QMouseEvent* e) override; diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 09eb4045b2..3ae708624d 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -130,6 +130,15 @@ void MapWindow::updateState(const UIState &s) { const SubMaster &sm = *(s.sm); update(); + // update navigate on openpilot status + if (sm.updated("modelV2")) { + bool nav_enabled = sm["modelV2"].getModelV2().getNavEnabled(); + if (nav_enabled && !uiState()->scene.navigate_on_openpilot) { + emit requestVisible(true); // Show map on rising edge of navigate on openpilot + } + uiState()->scene.navigate_on_openpilot = nav_enabled; + } + if (sm.updated("liveLocationKalman")) { auto locationd_location = sm["liveLocationKalman"].getLiveLocationKalman(); auto locationd_pos = locationd_location.getPositionGeodetic(); diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 4f144f667f..ef711afd50 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -74,8 +74,10 @@ void OnroadWindow::updateState(const UIState &s) { void OnroadWindow::mousePressEvent(QMouseEvent* e) { #ifdef ENABLE_MAPS if (map != nullptr) { + // Switch between map and sidebar when using navigate on openpilot bool sidebarVisible = geometry().x() > 0; - map->setVisible(!sidebarVisible && !map->isVisible()); + bool show_map = uiState()->scene.navigate_on_openpilot ? sidebarVisible : !sidebarVisible; + map->setVisible(show_map && !map->isVisible()); } #endif // propagation event to parent(HomeWindow) diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index 6f30d0f37e..955ddf254d 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -117,6 +117,7 @@ class OnroadWindow : public QWidget { public: OnroadWindow(QWidget* parent = 0); bool isMapVisible() const { return map && map->isVisible(); } + void showMapPanel(bool show) { if (map) map->setVisible(show); } signals: void mapPanelRequested(); diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index faa62a71e8..705c2f2172 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -75,6 +75,10 @@ void MainWindow::closeSettings() { if (uiState()->scene.started) { homeWindow->showSidebar(false); + // Map is always shown when using navigate on openpilot + if (uiState()->scene.navigate_on_openpilot) { + homeWindow->showMapPanel(true); + } } } diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index cf5094371c..2519f8ea2c 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -131,6 +131,8 @@ typedef struct UIScene { float driver_pose_coss[3]; vec3 face_kpts_draw[std::size(default_face_kpts_3d)]; + bool navigate_on_openpilot = false; + float light_sensor; bool started, ignition, is_metric, map_on_left, longitudinal_control; uint64_t started_frame;