Skip to content

Commit 86a7dd8

Browse files
committed
Avoid exceptions when wp module is not loaded
1 parent 8c15c9d commit 86a7dd8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

MAVProxy/modules/mavproxy_console.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ def menu_callback(self, m):
184184

185185
def estimated_time_remaining(self, lat, lon, wpnum, speed):
186186
'''estimate time remaining in mission in seconds'''
187+
if self.module('wp') is None:
188+
return 0
187189
idx = wpnum
188190
if wpnum >= self.module('wp').wploader.count():
189191
return 0
@@ -378,13 +380,14 @@ def handle_vfr_hud(self, msg):
378380
alt = master.field('GPS_RAW_INT', 'alt', 0) / 1.0e3
379381
else:
380382
alt = master.field('GPS_RAW', 'alt', 0)
381-
home = self.module('wp').get_home()
382-
if home is not None:
383-
home_lat = home.x
384-
home_lng = home.y
385-
else:
386-
home_lat = None
387-
home_lng = None
383+
home_lat = None
384+
home_lng = None
385+
if self.module('wp') is not None:
386+
home = self.module('wp').get_home()
387+
if home is not None:
388+
home_lat = home.x
389+
home_lng = home.y
390+
388391
lat = master.field('GLOBAL_POSITION_INT', 'lat', 0) * 1.0e-7
389392
lng = master.field('GLOBAL_POSITION_INT', 'lon', 0) * 1.0e-7
390393
rel_alt = master.field('GLOBAL_POSITION_INT', 'relative_alt', 0) * 1.0e-3
@@ -620,7 +623,10 @@ def handle_heartbeat(self, msg):
620623

621624
def handle_mission_current(self, msg):
622625
master = self.master
623-
wpmax = self.module('wp').wploader.count()
626+
if self.module('wp') is not None:
627+
wpmax = self.module('wp').wploader.count()
628+
else:
629+
wpmax = 0
624630
if wpmax > 0:
625631
wpmax = "/%u" % wpmax
626632
else:

0 commit comments

Comments
 (0)