Skip to content

Commit

Permalink
Avoid exceptions when wp module is not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Dec 15, 2024
1 parent a14f834 commit d8a28aa
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions MAVProxy/modules/mavproxy_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ def menu_callback(self, m):

def estimated_time_remaining(self, lat, lon, wpnum, speed):
'''estimate time remaining in mission in seconds'''
if self.module('wp') is None:
return 0
idx = wpnum
if wpnum >= self.module('wp').wploader.count():
return 0
Expand Down Expand Up @@ -382,13 +384,14 @@ def handle_vfr_hud(self, msg):
alt = master.field('GPS_RAW_INT', 'alt', 0) / 1.0e3
else:
alt = master.field('GPS_RAW', 'alt', 0)
home = self.module('wp').get_home()
if home is not None:
home_lat = home.x
home_lng = home.y
else:
home_lat = None
home_lng = None
home_lat = None
home_lng = None
if self.module('wp') is not None:
home = self.module('wp').get_home()
if home is not None:
home_lat = home.x
home_lng = home.y

lat = master.field('GLOBAL_POSITION_INT', 'lat', 0) * 1.0e-7
lng = master.field('GLOBAL_POSITION_INT', 'lon', 0) * 1.0e-7
rel_alt = master.field('GLOBAL_POSITION_INT', 'relative_alt', 0) * 1.0e-3
Expand Down Expand Up @@ -631,7 +634,10 @@ def handle_heartbeat(self, msg):

def handle_mission_current(self, msg):
master = self.master
wpmax = self.module('wp').wploader.count()
if self.module('wp') is not None:
wpmax = self.module('wp').wploader.count()
else:
wpmax = 0
if wpmax > 0:
wpmax = "/%u" % wpmax
else:
Expand Down

0 comments on commit d8a28aa

Please sign in to comment.