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

Modules: grapher layout and file export fixed for Windows #1432

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/windows_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
$wc.DownloadFile('https://autotest.ardupilot.org/Parameters/ArduPlane/apm.pdef.xml', 'Parameters\ArduPlane.xml')
$wc.DownloadFile('https://autotest.ardupilot.org/Parameters/ArduSub/apm.pdef.xml', 'Parameters\ArduSub.xml')
$wc.DownloadFile('https://autotest.ardupilot.org/Parameters/AntennaTracker/apm.pdef.xml', 'Parameters\AntennaTracker.xml')
$wc.DownloadFile('https://autotest.ardupilot.org/Parameters/Heli/apm.pdef.xml', 'Parameters\Heli.xml')
- name: Build installer
run: |
cd windows
Expand Down
4 changes: 2 additions & 2 deletions MAVProxy/MAVProxyWinLAN.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cd ..\
python setup.py build install --user
python .\MAVProxy\mavproxy.py --master=0.0.0.0:14550 --console
python.exe -m pip install --upgrade build . --user
python.exe .\MAVProxy\mavproxy.py --master=0.0.0.0:14550 --console
pause
4 changes: 2 additions & 2 deletions MAVProxy/MAVProxyWinUSB.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cd ..\
python setup.py build install --user
python .\MAVProxy\mavproxy.py --console
python.exe -m pip install --upgrade build . --user
python.exe .\MAVProxy\mavproxy.py --console
pause
27 changes: 16 additions & 11 deletions MAVProxy/modules/lib/grapher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
import sys, struct, time, os, datetime, platform
import math, re
import matplotlib
if platform.system() != "Darwin" and os.getenv("MPLBACKEND") is None:
if platform.system() == "Windows":
# wxAgg doesn't properly show the graph values in the lower right on Windows
matplotlib.use('TkAgg')
elif platform.system() != "Darwin" and os.getenv("MPLBACKEND") is None:
# on MacOS we can't set WxAgg here as it conflicts with the MacOS version
matplotlib.use('WXAgg')
from math import *
from pymavlink.mavextra import *
import pylab
import matplotlib.pyplot as plt
from pymavlink import mavutil
import threading
import numpy as np
Expand Down Expand Up @@ -266,8 +269,8 @@ def button_click(self, event):
def plotit(self, x, y, fields, colors=[], title=None, interactive=True):
'''plot a set of graphs using date for x axis'''
if interactive:
pylab.ion()
self.fig = pylab.figure(num=1, figsize=(12,6))
plt.ion()
self.fig = plt.figure(num=1, figsize=(12,6))
self.ax1 = self.fig.gca()
self.ax2 = None
for i in range(0, len(fields)):
Expand All @@ -287,6 +290,8 @@ def plotit(self, x, y, fields, colors=[], title=None, interactive=True):
self.fig.canvas.mpl_connect('draw_event', self.draw_event)
self.fig.canvas.mpl_connect('close_event', self.close_event)
self.fig.canvas.mpl_connect('button_press_event', self.button_click)
self.fig.canvas.get_default_filename = lambda: ''.join("graph" if self.title is None else
(x if x.isalnum() else '_' for x in self.title)) + '.png'
empty = True
ax1_labels = []
ax2_labels = []
Expand Down Expand Up @@ -379,7 +384,7 @@ def plotit(self, x, y, fields, colors=[], title=None, interactive=True):
empty = False

if self.grid:
pylab.grid()
plt.grid()

if self.show_flightmode != 0:
alpha = 0.3
Expand All @@ -401,7 +406,7 @@ def plotit(self, x, y, fields, colors=[], title=None, interactive=True):
return

if title is not None:
pylab.title(title)
plt.title(title)
else:
title = fields[0]
if self.fig.canvas.manager is not None:
Expand All @@ -417,10 +422,10 @@ def plotit(self, x, y, fields, colors=[], title=None, interactive=True):
label=mode, alpha=alpha*1.5))
labels = [patch.get_label() for patch in mode_patches]
if ax1_labels != [] and self.show_flightmode != 2:
patches_legend = matplotlib.pyplot.legend(mode_patches, labels, loc=self.legend_flightmode)
patches_legend = plt.legend(mode_patches, labels, loc=self.legend_flightmode)
self.fig.gca().add_artist(patches_legend)
else:
pylab.legend(mode_patches, labels)
plt.legend(mode_patches, labels)

if ax1_labels != []:
self.ax1.legend(ax1_labels,loc=self.legend)
Expand Down Expand Up @@ -674,16 +679,16 @@ def show(self, lenmavlist, block=True, xlim_pipe=None, output=None):
self.xlim_t.start()

if output is None:
pylab.draw()
pylab.show(block=block)
plt.draw()
plt.show(block=block)
elif output.endswith(".html"):
import mpld3
html = mpld3.fig_to_html(self.fig)
f_out = open(output, 'w')
f_out.write(html)
f_out.close()
else:
pylab.savefig(output, bbox_inches='tight', dpi=200)
plt.savefig(output, bbox_inches='tight', dpi=200)

if __name__ == "__main__":
from argparse import ArgumentParser
Expand Down
4 changes: 3 additions & 1 deletion MAVProxy/modules/lib/magfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from MAVProxy.modules.lib import wx_processguard
from MAVProxy.modules.lib.wx_loader import wx

import sys, time, os, math, copy
import sys, time, os, math, copy, platform

from pymavlink import mavutil
from pymavlink import mavextra
Expand All @@ -18,6 +18,8 @@
from MAVProxy.modules.lib.multiproc_util import MPDataLogChildTask

import matplotlib
if platform.system() == "Windows":
matplotlib.use('wxagg')
import matplotlib.pyplot as pyplot
import numpy
import datetime
Expand Down
2 changes: 1 addition & 1 deletion MAVProxy/modules/lib/param_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self):
def param_help_download(self):
'''download XML files for parameters'''
files = []
for vehicle in ['Rover', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker', 'Blimp']:
for vehicle in ['Rover', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker', 'Blimp', 'Heli']:
url = 'http://autotest.ardupilot.org/Parameters/%s/apm.pdef.xml.gz' % vehicle
path = mp_util.dot_mavproxy("%s.xml" % vehicle)
files.append((url, path))
Expand Down
2 changes: 1 addition & 1 deletion MAVProxy/modules/mavproxy_paramedit/param_editor_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def ParamChanged(self, event): # wxGlade: ParamEditor.<event_handler>
def param_help_download(self):
'''download XML files for parameters'''
files = []
for vehicle in ['APMrover2', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker']:
for vehicle in ['APMrover2', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker', 'Heli']:
url = 'http://autotest.ardupilot.org/Parameters/%s/apm.pdef.xml' % vehicle
path = mp_util.dot_mavproxy("%s.xml" % vehicle)
files.append((url, path))
Expand Down
4 changes: 2 additions & 2 deletions MAVProxy/tools/MAVExplorer.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cd ..\..\
python setup.py build install --user
python .\MAVProxy\tools\MAVExplorer.py
python.exe -m pip install --upgrade build . --user
python.exe .\MAVProxy\tools\MAVExplorer.py
pause
3 changes: 2 additions & 1 deletion MAVProxy/tools/MAVExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ def load_graphs():
continue
# skip parameter files. They specify an encoding, and under
# Python3 this leads to a warning from etree
if os.path.basename(file) in ["ArduSub.xml", "ArduPlane.xml", "APMrover2.xml", "ArduCopter.xml", "AntennaTracker.xml", "Blimp.xml", "Rover.xml"]:
if os.path.basename(file) in ["ArduSub.xml", "ArduPlane.xml", "APMrover2.xml", "ArduCopter.xml",
"AntennaTracker.xml", "Blimp.xml", "Rover.xml", "Heli.xml"]:
continue
graphs = load_graph_xml(open(file).read(), file)
if graphs:
Expand Down
1 change: 1 addition & 0 deletions windows/MAVProxyWinBuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ powershell.exe "Start-BitsTransfer -Source 'http://autotest.ardupilot.org/Parame
powershell.exe "Start-BitsTransfer -Source 'http://autotest.ardupilot.org/Parameters/ArduPlane/apm.pdef.xml' -Destination 'Parameters\ArduPlane.xml'"
powershell.exe "Start-BitsTransfer -Source 'http://autotest.ardupilot.org/Parameters/ArduSub/apm.pdef.xml' -Destination 'Parameters\ArduSub.xml'"
powershell.exe "Start-BitsTransfer -Source 'http://autotest.ardupilot.org/Parameters/AntennaTracker/apm.pdef.xml' -Destination 'Parameters\AntennaTracker.xml'"
powershell.exe "Start-BitsTransfer -Source 'http://autotest.ardupilot.org/Parameters/Heli/apm.pdef.xml' -Destination 'Parameters\Heli.xml'"

rem -----Build the Installer-----
cd .\windows
Expand Down
2 changes: 1 addition & 1 deletion windows/mavproxy.spec
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ MAVExpAny = Analysis(['.\\tools\\MAVExplorer.py'],
datas= [ ('tools\\graphs\\*.*', 'MAVProxy\\tools\\graphs' ) ],
hookspath=None,
runtime_hooks=None,
excludes= ['sphinx', 'docutils', 'alabaster', 'FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'])
excludes= ['sphinx', 'docutils', 'alabaster', 'FixTk', 'tcl', 'tk', 'Tkinter'])
MAVPicViewerAny = Analysis(['.\\tools\\mavpicviewer\\mavpicviewer.py'],
pathex=[os.path.abspath('.')],
# for some unknown reason these hidden imports don't pull in
Expand Down