Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid exceptions when wp module is not loaded #1448

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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