From 5da573ff39afd137fb8d9c0b0c75c2ef82106b17 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 11 Jan 2024 23:15:29 -0800 Subject: [PATCH] navd: handle errors in parsing api response (#30977) --- selfdrive/navd/navd.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/selfdrive/navd/navd.py b/selfdrive/navd/navd.py index fcaf46aff4..2be703cdb2 100755 --- a/selfdrive/navd/navd.py +++ b/selfdrive/navd/navd.py @@ -71,8 +71,11 @@ class RouteEngine: self.ui_pid = ui_pid[0] self.update_location() - self.recompute_route() - self.send_instruction() + try: + self.recompute_route() + self.send_instruction() + except Exception: + cloudlog.exception("navd.failed_to_compute") def update_location(self): location = self.sm['liveLocationKalman'] @@ -256,7 +259,10 @@ class RouteEngine: for i in range(self.step_idx + 1, len(self.route)): total_distance += self.route[i]['distance'] total_time += self.route[i]['duration'] - total_time_typical += self.route[i]['duration_typical'] + if self.route[i]['duration_typical'] is None: + total_time_typical += self.route[i]['duration'] + else: + total_time_typical += self.route[i]['duration_typical'] msg.navInstruction.distanceRemaining = total_distance msg.navInstruction.timeRemaining = total_time