display GPS accuracy

This commit is contained in:
Rick Lan
2024-06-13 22:03:15 +08:00
parent cf36d4b9e6
commit be7a2a284a
2 changed files with 16 additions and 2 deletions

View File

@@ -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 <cmath>
void Sidebar::drawMetric(QPainter &p, const QPair<QString, QString> &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

View File

@@ -6,6 +6,9 @@
#include <QMap>
#include "selfdrive/ui/ui.h"
#ifdef DP
#include "dp_priv/selfdrive/ui/qt/sidebar.h"
#endif
typedef QPair<QPair<QString, QString>, QColor> ItemStatus;
Q_DECLARE_METATYPE(ItemStatus);