From be7a2a284a5ea74ed7bc0f16470fa9f2eba263d0 Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Thu, 13 Jun 2024 22:03:15 +0800 Subject: [PATCH] display GPS accuracy --- selfdrive/ui/qt/sidebar.cc | 15 +++++++++++++-- selfdrive/ui/qt/sidebar.h | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index 1cedbb9cf..d98ba612a 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -4,6 +4,12 @@ #include "selfdrive/ui/qt/util.h" +#ifdef DP +#include "dp_priv/selfdrive/ui/qt/util.h" +#endif +// dp - for satellite fmin +#include + void Sidebar::drawMetric(QPainter &p, const QPair &label, QColor c, int y) { const QRect rect = {30, y, 240, 126}; @@ -102,8 +108,13 @@ void Sidebar::updateState(const UIState &s) { ItemStatus pandaStatus = {{tr("VEHICLE"), tr("ONLINE")}, good_color}; if (s.scene.pandaType == cereal::PandaState::PandaType::UNKNOWN) { pandaStatus = {{tr("NO"), tr("PANDA")}, danger_color}; - } else if (s.scene.started && !sm["liveLocationKalman"].getLiveLocationKalman().getGpsOK()) { - pandaStatus = {{tr("GPS"), tr("SEARCH")}, warning_color}; +// } else if (s.scene.started && !sm["liveLocationKalman"].getLiveLocationKalman().getGpsOK()) { +// pandaStatus = {{tr("GPS"), tr("SEARCH")}, warning_color}; + } else if (s.scene.started) { //} && sm["liveLocationKalman"].getLiveLocationKalman().getGpsOK()) { + auto gpsReader = s.gps_service == "gpsLocationExternal"? sm["gpsLocationExternal"].getGpsLocationExternal() : sm["gpsLocation"].getGpsLocation(); + float gpsAccuracy = gpsReader.getVerticalAccuracy(); + bool gps_ok = sm["liveLocationKalman"].getLiveLocationKalman().getGpsOK() && gpsAccuracy < 10; + pandaStatus = {{tr("GPS"), gps_ok? QString("%1 m").arg(fmin(99, gpsAccuracy), 0, 'f', 2) : "N/A"}, gps_ok? good_color : warning_color}; } setProperty("pandaStatus", QVariant::fromValue(pandaStatus)); // rick - update every 5 secs diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index 0b818a640..d7dc64e8b 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -6,6 +6,9 @@ #include #include "selfdrive/ui/ui.h" +#ifdef DP +#include "dp_priv/selfdrive/ui/qt/sidebar.h" +#endif typedef QPair, QColor> ItemStatus; Q_DECLARE_METATYPE(ItemStatus);