Permalink
Switch branches/tags
v2.4 pre-apm2-support gx9-6485d734 cellular-modem-0.5 cellular-modem-0-5 Rudder_elevon Rover-3.4.1 Rover-3.4.0 Rover-3.3.0 Rover-3.2.3 Rover-3.2.2 Rover-3.2.1 Rover-3.2.0 Copter-3.5.7 Copter-3.5.6 Copter-3.5.5 Copter-3.5.4 Copter-3.5.3 Copter-3.5.2 Copter-3.5.2-rc1 Copter-3.5.1 Copter-3.5.1-rc1 Copter-3.5.0 Copter-3.5.0-rc11 Copter-3.5.0-rc10 Copter-3.5.0-rc9 Copter-3.5.0-rc8 Copter-3.5.0-rc7 Copter-3.5.0-rc2 Copter-3.5.0-rc1 Copter-3.4.6 Copter-3.4.5 Copter-3.4.4 Copter-3.4.3 Copter-3.4.3-rc1 Copter-3.4.2 Copter-3.4.2-rc2 Copter-3.4.2-rc1 Copter-3.4.1 Copter-3.4.0 Copter-3.3.2 Copter-3.3.1 Copter-3.3-rc7 Copter-3.3-rc5 CanberraUAV-OBC-2012 ArduSub-stable ArduSub-beta ArduPlane-stable ArduPlane-stable-AVR ArduPlane-beta ArduPlane-beta-AVR ArduPlane-3.8.5 ArduPlane-3.8.4 ArduPlane-3.8.3 ArduPlane-3.8.2 ArduPlane-3.8.1 ArduPlane-3.8.0 ArduPlane-3.7.1 ArduPlane-3.7.0 ArduPlane-3.7.0-beta1 ArduPlane-3.6.0 ArduPlane-3.5.3 ArduPlane-3.5.2 ArduPlane-3.5.1 ArduPlane-3.4.0 ArduPlane-3.3.0 ArduPlane-3.2.2 ArduPlane-3.2.1 ArduPlane-3.2.0 ArduPlane-3.1.0 ArduPlane-3.0.3 ArduPlane-3.0.2 ArduPlane-3.0.1 ArduPlane-3.0.0 ArduPlane-2.78 ArduPlane-2.78b ArduPlane-2.75 ArduPlane-2.74 ArduPlane-2.74b ArduPlane-2.73 ArduPlane-2.72 ArduPlane-2.70 ArduPlane-2.69 ArduPlane-2.68 ArduPlane-2.67 ArduPlane-2.66 ArduPlane-2.65 ArduPlane-2.64 ArduPlane-2.63 ArduPlane-2.62 ArduPlane-2.61 ArduPlane-2.60 ArduPlane-2.50 ArduPlane-2.40 ArduPlane-2.40-beta ArduPlane-2.34 ArduPlane-2.33 ArduPlane-2.32 ArduPlane-2.31 ArduPlane-2.30
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
111 lines (91 sloc) 3.66 KB
# Copyright (C) 2016 Intel Corporation. All rights reserved.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
'''
This module shows the geodesic sections hit by the samples collected during
compass calibration, and also some status data. The objective of this module is
to provide a reference on how to interpret the field `completion_mask` from the
MAG_CAL_PROGRESS mavlink message. That information can be used in order to
guide the vehicle user during calibration.
The plot shown by this module isn't very helpful to the end user, but it might
help developers during development of internal calibration support in ground
control stations.
'''
from MAVProxy.modules.lib import mp_module, mp_util
import multiprocessing
class MagcalGraph():
def __init__(self):
self.parent_pipe, self.child_pipe = multiprocessing.Pipe()
self.ui_process = None
self._last_mavlink_msgs = {}
def start(self):
if self.is_active():
return
if self.ui_process:
self.ui_process.join()
for l in self._last_mavlink_msgs.values():
for m in l:
if not m:
continue
self.parent_pipe.send(m)
self.ui_process = multiprocessing.Process(target=self.ui_task)
self.ui_process.start()
def stop(self):
if not self.is_active():
return
self.parent_pipe.send('close')
self.ui_process.join()
def ui_task(self):
mp_util.child_close_fds()
from MAVProxy.modules.lib import wx_processguard
from MAVProxy.modules.lib.wx_loader import wx
from lib.magcal_graph_ui import MagcalFrame
app = wx.App(False)
app.frame = MagcalFrame(self.child_pipe)
app.frame.Show()
app.MainLoop()
def is_active(self):
return self.ui_process is not None and self.ui_process.is_alive()
def mavlink_packet(self, m):
if m.compass_id not in self._last_mavlink_msgs:
# Keep the two last messages so that, if one is the calibration
# report message, the previous one is the last progress message.
self._last_mavlink_msgs[m.compass_id] = [None, m]
else:
l = self._last_mavlink_msgs[m.compass_id]
l[0] = l[1]
l[1] = m
if not self.is_active():
return
self.parent_pipe.send(m)
class MagcalGraphModule(mp_module.MPModule):
def __init__(self, mpstate):
super(MagcalGraphModule, self).__init__(mpstate, 'magcal_graph')
self.add_command(
'magcal_graph',
self.cmd_magcal_graph,
'open a window to report magcal progress and plot geodesic ' +
'sections hit by the collected data in real time',
)
self.graph = MagcalGraph()
def cmd_magcal_graph(self, args):
self.graph.start()
def mavlink_packet(self, m):
if m.get_type() not in ('MAG_CAL_PROGRESS', 'MAG_CAL_REPORT'):
return
self.graph.mavlink_packet(m)
def unload(self):
self.graph.stop()
def init(mpstate):
return MagcalGraphModule(mpstate)