Skip to content

Commit

Permalink
New paparazzicenter in Python (#1811)
Browse files Browse the repository at this point in the history
This is the result of a student project to develop a new paparazzi center based on Python/Qt.
See http://wiki.paparazziuav.org/wiki/Paparazzi_Center/Evolutions for the main idea and development process.
It can be tested by running the main paparazzi launcher with the -python option. I more convenient way might be added later.
This PR is mostly a way to not loose this work, and other people are encourage to improve it in many aspects (HMI, functionalities, ...).
  • Loading branch information
gautierhattenberger authored and flixr committed Jul 19, 2016
1 parent 1ce9bcf commit 9763a70
Show file tree
Hide file tree
Showing 58 changed files with 10,571 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -23,6 +23,8 @@

*.gdb_history

.cache.xml

# Eclipse IDE project files
*.cproject
*.project
Expand Down
3 changes: 3 additions & 0 deletions paparazzi-python.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env /bin/sh
cd $PAPARAZZI_SRC/sw/supervision/python
./main.py
11 changes: 10 additions & 1 deletion src/paparazzi
Expand Up @@ -9,7 +9,16 @@ let env =
let value = if value = "." then Sys.getcwd () else value in
Printf.sprintf "%s=%s" var value)
[|"PAPARAZZI_SRC"; "PAPARAZZI_HOME"|]
let com = dirname // "sw/supervision/paparazzicenter";;
let com =
if Array.length (Sys.argv) > 1 then begin
Printf.printf "%d\n" (Array.length (Sys.argv));
if Sys.argv.(1) = "-python" then
dirname // "paparazzi-python.sh"
else
dirname // "sw/supervision/paparazzicenter"
end
else
dirname // "sw/supervision/paparazzicenter";;
Sys.argv.(0) <- com;;
let env = Array.append env (Unix.environment ());;
Unix.execve com Sys.argv env
44 changes: 44 additions & 0 deletions sw/supervision/python/.cache.dtd
@@ -0,0 +1,44 @@
<!ELEMENT cache (system|data)*>
<!ELEMENT system (window|filters)*>
<!ELEMENT window (x|y|width|height)*>
<!ELEMENT x (#PCDATA)>
<!ATTLIST x
value CDATA #REQUIRED>
<!ELEMENT y (#PCDATA)>
<!ATTLIST y
value CDATA #REQUIRED>
<!ELEMENT width (#PCDATA)>
<!ATTLIST width
value CDATA #REQUIRED>
<!ELEMENT height (#PCDATA)>
<!ATTLIST height
value CDATA #REQUIRED>
<!ELEMENT filters (level|info|warning|error)*>
<!ELEMENT level (#PCDATA)>
<!ATTLIST level
value CDATA #REQUIRED>
<!ELEMENT info (#PCDATA)>
<!ATTLIST info
value CDATA #REQUIRED>
<!ELEMENT warning (#PCDATA)>
<!ATTLIST warning
value CDATA #REQUIRED>
<!ELEMENT error (#PCDATA)>
<!ATTLIST error
value CDATA #REQUIRED>
<!ELEMENT data (set|config|target|device|session)*>
<!ELEMENT set (#PCDATA)>
<!ATTLIST set
value CDATA #REQUIRED>
<!ELEMENT config (#PCDATA)>
<!ATTLIST config
value CDATA #REQUIRED>
<!ELEMENT target (#PCDATA)>
<!ATTLIST target
value CDATA #REQUIRED>
<!ELEMENT device (#PCDATA)>
<!ATTLIST device
value CDATA #REQUIRED>
<!ELEMENT session (#PCDATA)>
<!ATTLIST session
value CDATA #REQUIRED>
69 changes: 69 additions & 0 deletions sw/supervision/python/README.md
@@ -0,0 +1,69 @@
###############################################################################
# Welcome in the future Paparazzi Center ! #
###############################################################################

1) Run instructions :

To run the new Paparazzi Center, you need :

> A Linux or IOS system
> A correctly installed version of Paparazzi UAV software
> Python 3.4 (install package 'python3')
> PyQt5 (install package 'python3-pyqt5')
First "git pull" my part of code or copy the current "./sw/supervision/python"
version into your own "./sw/supervision" directory. No installation nor
compilation is needed.
Then, make the 'main.py' file executable ('chmod +x main.py') and launch the
program in a terminal ('./main.py') or from the paparazzi launcher (soon).

###############################################################################

2) Feedback :

I'm an intern student at the ENAC and my mission is to reconceive the Paparazzi
Center in Python/Qt to make it more intuitive and 'maintainable' (that can
evolve easily). So I'd really like to have your feeling about my propositions !

If you have any question or comment about it, please contact me by
Github (my pseudo is 'floienac' and I use Gitter) or by mail
('f.bitard@gmail.com').
I'd be glad to be criticized, especially if you're directly concerned as a
final user or a developer of Paparazzi UAV.

Thanks by advance :)

Florian BITARD - intern student at the ENAC's drones lab
(February to June 2016)

http://wiki.paparazziuav.org/wiki/Paparazzi_Center/Evolutions
###############################################################################

3) GNU License :

As this new Paparazzi Center is a free and open source software part, feel
free to correct bugs, improve the functions and add new ones to it.

# Paparazzi center utilities
#
# Copyright (C) 2016 ENAC, Florian BITARD (intern student)
#
# This file is part of paparazzi.
#
# paparazzi 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 2, or (at your option)
# any later version.
#
# paparazzi 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 paparazzi; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
103 changes: 103 additions & 0 deletions sw/supervision/python/dialogs.py
@@ -0,0 +1,103 @@
# Paparazzi center utilities
#
# Copyright (C) 2016 ENAC, Florian BITARD (intern student)
#
# This file is part of paparazzi.
#
# paparazzi 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 2, or (at your option)
# any later version.
#
# paparazzi 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 paparazzi; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

###############################################################################
# [Imports]

import ui.set_manager as manager
import ui.popup as popup

import PyQt5.QtWidgets as Widgets
import logging
import os


###############################################################################
# [Constants]

LOGGER = logging.getLogger("[DIALOGS]")

UI_DIR = "ui"

DATA_CHANGED_POPUP_TYPE = "data changed"
DATA_CHANGED_POPUP_HTML = "data_changed.html"
CREDITS_POPUP_TYPE = "credits"
CREDITS_POPUP_HTML = "credits.html"
TUTORIAL_POPUP_TYPE = "tutorial"
TUTORIAL_POPUP_HTML = "tutorial.html"


###############################################################################
# [SettingsManager class]

class SettingsManager(Widgets.QDialog):
"""Class to manage the settings manager HMI."""
def __init__(self):
super(SettingsManager, self).__init__()
self.ui = manager.Ui_Dialog()
self.ui.setupUi(self)


###############################################################################
# [SettingsManager class]

class Popup(Widgets.QDialog):
"""Class to manage the settings manager HMI."""
def __init__(self, popup_type=None):
super(Popup, self).__init__()
self.ui = popup.Ui_Dialog()
self.ui.setupUi(self)
self.ui.textBrowser.setOpenExternalLinks(True)

self.type = popup_type

self.set_popup_details()

def set_popup_details(self):
"""
-> Set the title, the text and the dialog buttons of the popup window
according to its type.
"""
if self.type == DATA_CHANGED_POPUP_TYPE:
self.setWindowTitle("/!\ Some unsaved data found !")
self.ui.buttonBox.setStandardButtons(
Widgets.QDialogButtonBox.Cancel | Widgets.QDialogButtonBox.Save)
html_file = DATA_CHANGED_POPUP_HTML
elif self.type == CREDITS_POPUP_TYPE:
self.setWindowTitle("Paparazzi UAV Center credits "
"(Python/Qt version)")
self.ui.buttonBox.setStandardButtons(Widgets.QDialogButtonBox.Close)
html_file = CREDITS_POPUP_HTML
elif self.type == TUTORIAL_POPUP_TYPE:
self.setWindowTitle("Tutorials and documents")
self.ui.buttonBox.setStandardButtons(Widgets.QDialogButtonBox.Close)
html_file = TUTORIAL_POPUP_HTML
else:
self.setWindowTitle("Popup without specific type.")
html_file = "none.html"

try:
html_config_path = os.path.join(UI_DIR, html_file)
with open(html_config_path, 'r') as popup_html_content:
self.ui.textBrowser.setHtml(popup_html_content.read())
except FileNotFoundError:
print("Popup HTML configuration file not found ! "
"('%s' should be in 'ui' directory.)" % html_file)

0 comments on commit 9763a70

Please sign in to comment.