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

map: avoid exceptions when wp module not loaded #1259

Merged
merged 2 commits into from
Nov 17, 2023
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
19 changes: 15 additions & 4 deletions MAVProxy/modules/mavproxy_map/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,15 +1018,28 @@ def mavlink_packet(self, m):
# the rest should only be done for the primary vehicle
return

self.check_redisplay_waypoints()
self.check_redisplay_fencepoints()
self.check_redisplay_rallypoints()

# check for any events from the map
self.map.check_events()

def check_redisplay_waypoints(self):
# if the waypoints have changed, redisplay
last_wp_change = self.module('wp').wploader.last_change
wp_module = self.module('wp')
if wp_module is None:
'''wp nodule not loaded'''
return
last_wp_change = wp_module.wploader.last_change
if self.wp_change_time != last_wp_change and abs(time.time() - last_wp_change) > 1:
self.wp_change_time = last_wp_change
self.display_waypoints()

#this may have affected the landing lines from the rally points:
self.rally_change_time = time.time()

def check_redisplay_fencepoints(self):
# if the fence has changed, redisplay
fence_module = self.module('fence')
if fence_module is not None:
Expand All @@ -1040,6 +1053,7 @@ def mavlink_packet(self, m):
self.fence_change_time = last_change
self.display_fence()

def check_redisplay_rallypoints(self):
# if the rallypoints have changed, redisplay
if (self.module('rally') and
self.rally_change_time != self.module('rally').last_change()):
Expand Down Expand Up @@ -1090,9 +1104,6 @@ def mavlink_packet(self, m):
points.append((nearest_land_wp.x, nearest_land_wp.y))
self.map.add_object(mp_slipmap.SlipPolygon('Rally Land %u' % (i+1), points, 'RallyPoints', (255,255,0), 2))

# check for any events from the map
self.map.check_events()

def init(mpstate):
'''initialise module'''
return MapModule(mpstate)