From 9307fe434cf7e9adb68a12d0b9073ebcf75e1f3e Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 4 May 2022 11:37:31 +0200 Subject: [PATCH] map.cc: fix crash on older route with missing liveLocationKalman values --- selfdrive/ui/qt/maps/map.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 3b8668d0b..055f93b29 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -117,17 +117,15 @@ void MapWindow::timerUpdate() { auto location = (*sm)["liveLocationKalman"].getLiveLocationKalman(); auto pos = location.getPositionGeodetic(); auto orientation = location.getCalibratedOrientationNED(); + auto velocity = location.getVelocityCalibrated(); - localizer_valid = (location.getStatus() == cereal::LiveLocationKalman::Status::VALID) && pos.getValid(); + localizer_valid = (location.getStatus() == cereal::LiveLocationKalman::Status::VALID) && + pos.getValid() && orientation.getValid() && velocity.getValid(); if (localizer_valid) { - float velocity = location.getVelocityCalibrated().getValue()[0]; - float bearing = RAD2DEG(orientation.getValue()[2]); - auto coordinate = QMapbox::Coordinate(pos.getValue()[0], pos.getValue()[1]); - - last_position = coordinate; - last_bearing = bearing; - velocity_filter.update(velocity); + last_position = QMapbox::Coordinate(pos.getValue()[0], pos.getValue()[1]); + last_bearing = RAD2DEG(orientation.getValue()[2]); + velocity_filter.update(velocity.getValue()[0]); } }