ui: show map with nav (#28867)

* accept touch events in map settings

* draft

* draft 2.0

* revert this stuff

* need this

* fix

* clean up debug prints

* fraft

* only show map on closeSettings if nav

* works!

* can't do it here

* I was going to connect signals from UIState to HomeWindow, then to OnroadWidget, but that seems like too much

* just need to keep track of it in onroad, seems like the cleanest option

* ideally we show the map where we set the scene variable, and that's in map.cc

* old variable

* comments

* less confusing

* app comment

* add back

* fix

* move to top

* remove this comment
pull/28894/head
Shane Smiskol 2 years ago committed by GitHub
parent 9ecf98c4ce
commit 34a5e626d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      selfdrive/ui/qt/home.cc
  2. 1
      selfdrive/ui/qt/home.h
  3. 9
      selfdrive/ui/qt/maps/map.cc
  4. 4
      selfdrive/ui/qt/onroad.cc
  5. 1
      selfdrive/ui/qt/onroad.h
  6. 4
      selfdrive/ui/qt/window.cc
  7. 2
      selfdrive/ui/ui.h

@ -55,6 +55,10 @@ void HomeWindow::showSidebar(bool show) {
sidebar->setVisible(show); sidebar->setVisible(show);
} }
void HomeWindow::showMapPanel(bool show) {
onroad->showMapPanel(show);
}
void HomeWindow::updateState(const UIState &s) { void HomeWindow::updateState(const UIState &s) {
const SubMaster &sm = *(s.sm); const SubMaster &sm = *(s.sm);

@ -55,6 +55,7 @@ public slots:
void offroadTransition(bool offroad); void offroadTransition(bool offroad);
void showDriverView(bool show); void showDriverView(bool show);
void showSidebar(bool show); void showSidebar(bool show);
void showMapPanel(bool show);
protected: protected:
void mousePressEvent(QMouseEvent* e) override; void mousePressEvent(QMouseEvent* e) override;

@ -130,6 +130,15 @@ void MapWindow::updateState(const UIState &s) {
const SubMaster &sm = *(s.sm); const SubMaster &sm = *(s.sm);
update(); 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")) { if (sm.updated("liveLocationKalman")) {
auto locationd_location = sm["liveLocationKalman"].getLiveLocationKalman(); auto locationd_location = sm["liveLocationKalman"].getLiveLocationKalman();
auto locationd_pos = locationd_location.getPositionGeodetic(); auto locationd_pos = locationd_location.getPositionGeodetic();

@ -74,8 +74,10 @@ void OnroadWindow::updateState(const UIState &s) {
void OnroadWindow::mousePressEvent(QMouseEvent* e) { void OnroadWindow::mousePressEvent(QMouseEvent* e) {
#ifdef ENABLE_MAPS #ifdef ENABLE_MAPS
if (map != nullptr) { if (map != nullptr) {
// Switch between map and sidebar when using navigate on openpilot
bool sidebarVisible = geometry().x() > 0; 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 #endif
// propagation event to parent(HomeWindow) // propagation event to parent(HomeWindow)

@ -117,6 +117,7 @@ class OnroadWindow : public QWidget {
public: public:
OnroadWindow(QWidget* parent = 0); OnroadWindow(QWidget* parent = 0);
bool isMapVisible() const { return map && map->isVisible(); } bool isMapVisible() const { return map && map->isVisible(); }
void showMapPanel(bool show) { if (map) map->setVisible(show); }
signals: signals:
void mapPanelRequested(); void mapPanelRequested();

@ -75,6 +75,10 @@ void MainWindow::closeSettings() {
if (uiState()->scene.started) { if (uiState()->scene.started) {
homeWindow->showSidebar(false); homeWindow->showSidebar(false);
// Map is always shown when using navigate on openpilot
if (uiState()->scene.navigate_on_openpilot) {
homeWindow->showMapPanel(true);
}
} }
} }

@ -131,6 +131,8 @@ typedef struct UIScene {
float driver_pose_coss[3]; float driver_pose_coss[3];
vec3 face_kpts_draw[std::size(default_face_kpts_3d)]; vec3 face_kpts_draw[std::size(default_face_kpts_3d)];
bool navigate_on_openpilot = false;
float light_sensor; float light_sensor;
bool started, ignition, is_metric, map_on_left, longitudinal_control; bool started, ignition, is_metric, map_on_left, longitudinal_control;
uint64_t started_frame; uint64_t started_frame;

Loading…
Cancel
Save