From a81c11c43eda35483d69658a29c95f52add71265 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Sat, 12 Oct 2024 09:52:30 +0900 Subject: [PATCH] mavpicviewer: handle arithmetic exception in image viewer --- MAVProxy/tools/mavpicviewer/mavpicviewer_image.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/MAVProxy/tools/mavpicviewer/mavpicviewer_image.py b/MAVProxy/tools/mavpicviewer/mavpicviewer_image.py index 415d846816..6c1f309e3f 100644 --- a/MAVProxy/tools/mavpicviewer/mavpicviewer_image.py +++ b/MAVProxy/tools/mavpicviewer/mavpicviewer_image.py @@ -430,11 +430,15 @@ def update_map(self): if self.sm is not None: self.sm.set_center(self.lat, self.lon) - projection1 = self.cam1_projection.get_projection(self.lat, self.lon, self.alt_amsl, self.roll, self.pitch, self.yaw) - if projection1 is not None and self.sm is not None: - self.sm.add_object(mp_slipmap.SlipPolygon('projection1', projection1, layer=1, linewidth=2, colour=mpv.RGB_GREEN)) - else: - print(prefix_str + "failed to add projection to map") + # calculate image outline polygon for map + try: + projection1 = self.cam1_projection.get_projection(self.lat, self.lon, self.alt_amsl, self.roll, self.pitch, self.yaw) + if projection1 is not None and self.sm is not None: + self.sm.add_object(mp_slipmap.SlipPolygon('projection1', projection1, layer=1, linewidth=2, colour=mpv.RGB_GREEN)) + else: + print(prefix_str + "failed to add projection to map") + except ArithmeticError as e: + print(prefix_str + "failed to add projection to map due to arithmetic error: " + str(e)) # add a rectangle specified by two locations to the map def add_rectangle_to_map(self, name, lat1, lon1, lat2, lon2):