Commit eb3eb94a authored by dogmaphobic's avatar dogmaphobic

Primary Flight Display

New version using QtQuick along with an experimental Map Background
parent a251c07d
......@@ -264,6 +264,7 @@ INCLUDEPATH += \
src/ui/px4_configuration \
src/ui/main \
src/ui/toolbar \
src/ui/flightdisplay \
src/VehicleSetup \
src/AutoPilotPlugins \
src/QmlControls
......@@ -490,7 +491,8 @@ HEADERS += \
src/uas/UASMessageHandler.h \
src/ui/toolbar/MainToolBar.h \
src/QmlControls/ScreenTools.h \
src/QGCLoggingCategory.h
src/QGCLoggingCategory.h \
src/ui/flightdisplay/QGCFlightDisplay.h
SOURCES += \
src/main.cc \
......@@ -631,7 +633,8 @@ SOURCES += \
src/uas/UASMessageHandler.cc \
src/ui/toolbar/MainToolBar.cc \
src/QmlControls/ScreenTools.cc \
src/QGCLoggingCategory.cc
src/QGCLoggingCategory.cc \
src/ui/flightdisplay/QGCFlightDisplay.cc
#
# Unit Test specific configuration goes here
......
......@@ -305,6 +305,21 @@
<file alias="PowerComponentBattery_05cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_05cell.svg</file>
<file alias="PowerComponentBattery_06cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_06cell.svg</file>
<file alias="MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file>
<file alias="FlightDisplay.qml">src/ui/flightdisplay/FlightDisplay.qml</file>
<file alias="QGroundControl/HUDControls/qmldir">src/ui/flightdisplay/components/qmldir</file>
<file alias="QGroundControl/HUDControls/QGCAltitudeWidget.qml">src/ui/flightdisplay/components/QGCAltitudeWidget.qml</file>
<file alias="QGroundControl/HUDControls/QGCAttitudeWidget.qml">src/ui/flightdisplay/components/QGCAttitudeWidget.qml</file>
<file alias="QGroundControl/HUDControls/QGCCompass.qml">src/ui/flightdisplay/components/QGCCompass.qml</file>
<file alias="QGroundControl/HUDControls/QGCCurrentAltitude.qml">src/ui/flightdisplay/components/QGCCurrentAltitude.qml</file>
<file alias="QGroundControl/HUDControls/QGCCurrentSpeed.qml">src/ui/flightdisplay/components/QGCCurrentSpeed.qml</file>
<file alias="QGroundControl/HUDControls/QGCMapBackground.qml">src/ui/flightdisplay/components/QGCMapBackground.qml</file>
<file alias="QGroundControl/HUDControls/QGCPitchWidget.qml">src/ui/flightdisplay/components/QGCPitchWidget.qml</file>
<file alias="QGroundControl/HUDControls/QGCSpeedWidget.qml">src/ui/flightdisplay/components/QGCSpeedWidget.qml</file>
<file alias="compass.svg">src/ui/flightdisplay/components/compass.svg</file>
<file alias="compassNeedle.svg">src/ui/flightdisplay/components/compassNeedle.svg</file>
<file alias="crossHair.svg">src/ui/flightdisplay/components/crossHair.svg</file>
<file alias="rollDial.svg">src/ui/flightdisplay/components/rollDial.svg</file>
<file alias="rollPointer.svg">src/ui/flightdisplay/components/rollPointer.svg</file>
</qresource>
<qresource prefix="/AutoPilotPlugins/PX4">
<file alias="ParameterFactMetaData.xml">src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml</file>
......
......@@ -49,6 +49,7 @@ public:
// Implemented UASInterface overrides
virtual int getSystemType(void) { return _systemType; }
virtual int getUASID(void) const { return _systemId; }
virtual bool isAirplane() { return false; }
virtual QGCUASParamManagerInterface* getParamManager() { return &_paramManager; };
// sendMessage is only supported if a mavlink plugin is installed.
......
......@@ -2673,6 +2673,21 @@ int UAS::getSystemType()
return this->type;
}
/** @brief Is it an airplane (or like one)?,..)*/
bool UAS::isAirplane()
{
switch(this->type) {
case MAV_TYPE_GENERIC:
case MAV_TYPE_FIXED_WING:
case MAV_TYPE_AIRSHIP:
case MAV_TYPE_FLAPPING_WING:
return true;
default:
break;
}
return false;
}
/**
* Halt the uas.
*/
......
......@@ -508,7 +508,8 @@ public:
}
int getSystemType();
int getSystemType();
bool isAirplane();
/**
* @brief Returns true for systems that can reverse. If the system has no control over position, it returns false as
......
......@@ -213,6 +213,8 @@ public:
/** @brief Get the type of the system (airplane, quadrotor, helicopter,..)*/
virtual int getSystemType() = 0;
/** @brief Is it an airplane (or like one)?,..)*/
virtual bool isAirplane() = 0;
/** @brief Indicates whether this system is capable of controlling a reverse velocity.
* Used for, among other things, altering joystick input to either -1:1 or 0:1 range.
*/
......
......@@ -60,6 +60,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCTabbedInfoView.h"
#include "UASRawStatusView.h"
#include "PrimaryFlightDisplay.h"
#include "QGCFlightDisplay.h"
#include "SetupView.h"
#include "SerialSettingsDialog.h"
#include "terminalconsole.h"
......@@ -447,7 +448,8 @@ void MainWindow::_buildPlannerView(void)
void MainWindow::_buildPilotView(void)
{
if (!_pilotView) {
_pilotView = new PrimaryFlightDisplay(this);
//_pilotView = new PrimaryFlightDisplay(this);
_pilotView = new QGCFlightDisplay(this);
_pilotView->setVisible(false);
}
}
......@@ -560,7 +562,8 @@ void MainWindow::_createInnerDockWidget(const QString& widgetName)
widget = hddisplay;
} else if (widgetName == _pfdDockWidgetName) {
widget = new PrimaryFlightDisplay(this);
widget = new QGCFlightDisplay(this);
//widget = new PrimaryFlightDisplay(this);
} else if (widgetName == _hudDockWidgetName) {
widget = new HUD(320,240,this);
} else if (widgetName == _uasInfoViewDockWidgetName) {
......
This diff is collapsed.
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC Main Flight Display
* @author Gus Grubba <mavlink@grubba.com>
*/
#ifndef QGCFLIGHTDISPLAY_H
#define QGCFLIGHTDISPLAY_H
#include "QGCQmlWidgetHolder.h"
class UASInterface;
class QGCFlightDisplay : public QGCQmlWidgetHolder
{
Q_OBJECT
public:
QGCFlightDisplay(QWidget* parent = NULL);
~QGCFlightDisplay();
Q_PROPERTY(float roll READ roll NOTIFY rollChanged)
Q_PROPERTY(float pitch READ pitch NOTIFY pitchChanged)
Q_PROPERTY(float heading READ heading NOTIFY headingChanged)
Q_PROPERTY(float groundSpeed READ groundSpeed NOTIFY groundSpeedChanged)
Q_PROPERTY(float airSpeed READ airSpeed NOTIFY airSpeedChanged)
Q_PROPERTY(float climbRate READ climbRate NOTIFY climbRateChanged)
Q_PROPERTY(float altitudeRelative READ altitudeRelative NOTIFY altitudeRelativeChanged)
Q_PROPERTY(float altitudeWGS84 READ altitudeWGS84 NOTIFY altitudeWGS84Changed)
Q_PROPERTY(float altitudeAMSL READ altitudeAMSL NOTIFY altitudeAMSLChanged)
Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged)
Q_PROPERTY(float latitude READ latitude NOTIFY latitudeChanged)
Q_PROPERTY(float longitude READ longitude NOTIFY longitudeChanged)
Q_INVOKABLE void saveSetting (const QString &key, bool value);
Q_INVOKABLE bool loadSetting (const QString &key, bool defaultValue);
float roll () { return _roll; }
float pitch () { return _pitch; }
float heading () { return _heading; }
float groundSpeed () { return _groundSpeed; }
float airSpeed () { return _airSpeed; }
float climbRate () { return _climbRate; }
float altitudeRelative () { return _altitudeRelative; }
float altitudeWGS84 () { return _altitudeWGS84; }
float altitudeAMSL () { return _altitudeAMSL; }
float latitude () { return _latitude; }
float longitude () { return _longitude; }
bool repaintRequested () { return true; }
/** @brief Start updating widget */
void showEvent(QShowEvent* event);
/** @brief Stop updating widget */
void hideEvent(QHideEvent* event);
signals:
void rollChanged ();
void pitchChanged ();
void headingChanged ();
void groundSpeedChanged ();
void airSpeedChanged ();
void climbRateChanged ();
void altitudeRelativeChanged();
void altitudeWGS84Changed ();
void altitudeAMSLChanged ();
void repaintRequestedChanged();
void latitudeChanged ();
void longitudeChanged ();
private slots:
/** @brief Attitude from main autopilot / system state */
void _updateAttitude (UASInterface* uas, double roll, double pitch, double yaw, quint64 timestamp);
/** @brief Attitude from one specific component / redundant autopilot */
void _updateAttitude (UASInterface* uas, int component, double roll, double pitch, double yaw, quint64 timestamp);
/** @brief Speed */
void _updateSpeed (UASInterface* uas, double _groundSpeed, double _airSpeed, quint64 timestamp);
/** @brief Altitude */
void _updateAltitude (UASInterface* uas, double _altitudeAMSL, double _altitudeWGS84, double _altitudeRelative, double _climbRate, quint64 timestamp);
void _updateNavigationControllerErrors (UASInterface* uas, double altitudeError, double speedError, double xtrackError);
void _updateNavigationControllerData (UASInterface *uas, float navRoll, float navPitch, float navBearing, float targetBearing, float targetDistance);
void _forgetUAS (UASInterface* uas);
void _setActiveUAS (UASInterface* uas);
void _checkUpdate ();
private:
bool _isAirplane ();
bool _shouldDisplayNavigationData ();
private:
UASInterface* _mav;
float _roll;
float _pitch;
float _heading;
float _altitudeAMSL;
float _altitudeWGS84;
float _altitudeRelative;
float _groundSpeed;
float _airSpeed;
float _climbRate;
float _navigationAltitudeError;
float _navigationSpeedError;
float _navigationCrosstrackError;
float _navigationTargetBearing;
float _latitude;
float _longitude;
QTimer* _refreshTimer;
bool _valuesChanged;
quint64 _valuesLastPainted;
};
#endif // QGCFLIGHTDISPLAY_H
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC Altitude Indicator
* @author Gus Grubba <mavlink@grubba.com>
*/
// TODO: This is temporary until I find a better way to display a large range of numbers
import QtQuick 2.4
Rectangle {
id: root
property real altitude: 50
property real _reticleSpacing: 29
property real _reticleHeight: 1
property real _reticleSlot: _reticleSpacing + _reticleHeight
property var _speedArray: []
property int _currentCenter: 0
property int _currentStart: -100
function updateArray() {
var tmpArray = [];
_currentCenter = Math.floor(altitude / 5) * 5;
_currentStart = _currentCenter + 100;
for(var i = 0; i < 40; i++) {
tmpArray[i] = _currentStart - (i * 5);
}
_speedArray = tmpArray;
}
Component.onCompleted:
{
updateArray() ;
}
onAltitudeChanged: {
if(Math.abs(_currentCenter - altitude) > 50) {
updateArray() ;
}
}
anchors.verticalCenter: parent.verticalCenter
height: parent.height * 0.75 > 280 ? 280 : parent.height * 0.75
clip: true
smooth: true
border.color: Qt.rgba(1,1,1,0.25)
gradient: Gradient {
GradientStop { position: 0.0; color: Qt.rgba(0,0,0,0.35) }
GradientStop { position: 0.5; color: Qt.rgba(0,0,0,0.15) }
GradientStop { position: 1.0; color: Qt.rgba(0,0,0,0.35) }
}
Column{
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
spacing: _reticleSpacing
Repeater {
model: _speedArray
Rectangle {
width: root.width
height: _reticleHeight
color: Qt.rgba(1,1,1,0.1)
Text {
property real _alt: modelData
visible: (_alt % 10 === 0)
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
font.weight: _alt < 0 ? Font.Light : Font.DemiBold
text: _alt < 0 ? -_alt : _alt
color: _alt < 0 ? "#ef2526" : "white"
style: Text.Outline
styleColor: Qt.rgba(0,0,0,0.25)
}
}
}
transform: Translate {
y: ((altitude - _currentCenter) * _reticleSlot / 5) - (_reticleSlot / 2)
}
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC Main Flight Display
* @author Gus Grubba <mavlink@grubba.com>
*/
import QtQuick 2.4
Item {
id: root
property real rollAngle : 0
property real pitchAngle: 0
property real backgroundOpacity: 1
property bool displayBackground: true
anchors.fill: parent
Item {
id: background
width: parent.width * 4
height: parent.height * 4
anchors.centerIn: parent
Rectangle {
anchors.fill: parent
color: Qt.rgba(0,0,0,0)
visible: displayBackground
Rectangle {
id: sky
visible: displayBackground
anchors.fill: parent
smooth: true
antialiasing: true
gradient: Gradient {
GradientStop { position: 0.25; color: Qt.hsla(0.6, 1.0, 0.25, backgroundOpacity) }
GradientStop { position: 0.5; color: Qt.hsla(0.6, 0.5, 0.75, backgroundOpacity) }
}
}
Rectangle {
id: ground
visible: displayBackground
height: sky.height / 2
anchors {
left: sky.left;
right: sky.right;
bottom: sky.bottom
}
smooth: true
antialiasing: true
gradient: Gradient {
GradientStop { position: 0.0; color: Qt.hsla(0.25, 0.5, 0.45, backgroundOpacity) }
GradientStop { position: 0.25; color: Qt.hsla(0.25, 0.75, 0.25, backgroundOpacity) }
}
}
transform: [
Translate {
y: (root.visible && root.displayBackground) ? pitchAngle * 4 : 0
},
Rotation {
origin.x: background.width / 2
origin.y: background.height / 2
angle: (root.visible && root.displayBackground) ? -rollAngle : 0
}]
}
}
Image {
id: rollDial
anchors { bottom: root.verticalCenter; horizontalCenter: parent.horizontalCenter}
source: "/qml/rollDial.svg"
mipmap: true
width: 250
fillMode: Image.PreserveAspectFit
transform: Rotation {
origin.x: rollDial.width / 2
origin.y: rollDial.height
angle: -rollAngle
}
}
Image {
id: pointer
anchors { bottom: root.verticalCenter; horizontalCenter: parent.horizontalCenter}
source: "/qml/rollPointer.svg"
smooth: true
width: rollDial.width
fillMode: Image.PreserveAspectFit
}
Image {
anchors.centerIn: parent
source: "/qml/crossHair.svg"
mipmap: true
width: rollDial.width
fillMode: Image.PreserveAspectFit
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC Compass
* @author Gus Grubba <mavlink@grubba.com>
*/
import QtQuick 2.4
Item {
id: root
width: parent.width * 0.25 > 150 ? parent.width * 0.25 : 150
height: width
property real heading : 0
Image {
id: compass
anchors.centerIn: parent
source: "/qml/compass.svg"
mipmap: true
width: root.width
fillMode: Image.PreserveAspectFit
transform: Rotation {
origin.x: compass.width / 2
origin.y: compass.height / 2
angle: -heading
}
}
Image {
id: pointer
anchors.bottom: compass.top
anchors.horizontalCenter: root.horizontalCenter
source: "/qml/compassNeedle.svg"
smooth: true
width: compass.width * 0.1
fillMode: Image.PreserveAspectFit
}
Rectangle {
anchors.centerIn: compass
width: 40
height: 25
border.color: Qt.rgba(1,1,1,0.25)
color: Qt.rgba(1,1,1,0.1)
Text {
text: heading.toFixed(0)
font.weight: Font.DemiBold
color: "white"
anchors.centerIn: parent
}
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC Current Altitude Indicator
* @author Gus Grubba <mavlink@grubba.com>
*/
import QtQuick 2.1
Rectangle {
id: root
property real altitude: 0
property real vertZ: 0
property bool showAltitude: true
property bool showClimbRate: true
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: (showAltitude && showClimbRate) ? 50 : 25
color: "black"
border.color: Qt.rgba(1,1,1,0.25)
opacity: 1.0
Column{
anchors.centerIn: parent
spacing: 4
Text {
text: 'h: ' + altitude.toFixed(1)
font.weight: Font.DemiBold
color: "white"
anchors.right: parent.right
visible: showAltitude
}
Text {
text: 'vZ: ' + vertZ.toFixed(1)
color: "white"
font.weight: showAltitude ? Font.Normal : Font.DemiBold
anchors.right: parent.right
visible: showClimbRate
}
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC Current Speed Indicator
* @author Gus Grubba <mavlink@grubba.com>
*/
import QtQuick 2.1
Rectangle {
id: root
property real airspeed: 0
property real groundspeed: 0
property bool showAirSpeed: true
property bool showGroundSpeed: true
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: (showAirSpeed && showGroundSpeed) ? 50 : 25
color: "black"
border.color: Qt.rgba(1,1,1,0.25)
opacity: 1.0
Column{
anchors.centerIn: parent
spacing: 4
Text {
text: 'GS: ' + groundspeed.toFixed(1)
font.weight: Font.DemiBold
color: "white"
anchors.right: parent.right
visible: showGroundSpeed
}
Text {
text: 'AS: ' + airspeed.toFixed(1)
color: "white"
anchors.right: parent.right
font.weight: showAirSpeed ? Font.Normal : Font.DemiBold
visible: showAirSpeed
}
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station