Commit aba85785 authored by Pritam Ghanghas's avatar Pritam Ghanghas

Merge branch 'master' into apm_support

parents 3a5a4692 f6121689
......@@ -141,6 +141,7 @@ INCLUDEPATH += \
src/AutoPilotPlugins \
src/comm \
src/FlightDisplay \
src/FlightMap \
src/input \
src/Joystick \
src/lib/qmapcontrol \
......@@ -239,6 +240,7 @@ HEADERS += \
src/comm/UDPLink.h \
src/FlightDisplay/FlightDisplayWidget.h \
src/FlightDisplay/FlightDisplayView.h \
src/FlightMap/FlightMapSettings.h \
src/GAudioOutput.h \
src/HomePositionManager.h \
src/Joystick/Joystick.h \
......@@ -374,6 +376,7 @@ SOURCES += \
src/comm/UDPLink.cc \
src/FlightDisplay/FlightDisplayWidget.cc \
src/FlightDisplay/FlightDisplayView.cc \
src/FlightMap/FlightMapSettings.cc \
src/GAudioOutput.cc \
src/HomePositionManager.cc \
src/Joystick/Joystick.cc \
......@@ -508,40 +511,44 @@ INCLUDEPATH += \
src/qgcunittest
HEADERS += \
src/qgcunittest/FlightGearTest.h \
src/qgcunittest/MultiSignalSpy.h \
src/qgcunittest/TCPLinkTest.h \
src/qgcunittest/TCPLoopBackServer.h \
src/FactSystem/FactSystemTestBase.h \
src/FactSystem/FactSystemTestGeneric.h \
src/FactSystem/FactSystemTestPX4.h \
src/MissionItemTest.h \
src/MissionManager/MissionManagerTest.h \
src/qgcunittest/FileDialogTest.h \
src/qgcunittest/FileManagerTest.h \
src/qgcunittest/FlightGearTest.h \
src/qgcunittest/LinkManagerTest.h \
src/qgcunittest/MainWindowTest.h \
src/qgcunittest/MavlinkLogTest.h \
src/qgcunittest/MessageBoxTest.h \
src/qgcunittest/MultiSignalSpy.h \
src/qgcunittest/PX4RCCalibrationTest.h \
src/qgcunittest/TCPLinkTest.h \
src/qgcunittest/TCPLoopBackServer.h \
src/qgcunittest/UnitTest.h \
src/VehicleSetup/SetupViewTest.h \
src/qgcunittest/FileManagerTest.h \
src/qgcunittest/PX4RCCalibrationTest.h \
SOURCES += \
src/qgcunittest/FlightGearTest.cc \
src/qgcunittest/MultiSignalSpy.cc \
src/qgcunittest/TCPLinkTest.cc \
src/qgcunittest/TCPLoopBackServer.cc \
src/FactSystem/FactSystemTestBase.cc \
src/FactSystem/FactSystemTestGeneric.cc \
src/FactSystem/FactSystemTestPX4.cc \
src/MissionItemTest.cc \
src/MissionManager/MissionManagerTest.cc \
src/qgcunittest/FileDialogTest.cc \
src/qgcunittest/FileManagerTest.cc \
src/qgcunittest/FlightGearTest.cc \
src/qgcunittest/LinkManagerTest.cc \
src/qgcunittest/MainWindowTest.cc \
src/qgcunittest/MavlinkLogTest.cc \
src/qgcunittest/MessageBoxTest.cc \
src/qgcunittest/MultiSignalSpy.cc \
src/qgcunittest/PX4RCCalibrationTest.cc \
src/qgcunittest/TCPLinkTest.cc \
src/qgcunittest/TCPLoopBackServer.cc \
src/qgcunittest/UnitTest.cc \
src/VehicleSetup/SetupViewTest.cc \
src/qgcunittest/FileManagerTest.cc \
src/qgcunittest/PX4RCCalibrationTest.cc \
} # DebugBuild|WindowsDebugAndRelease
} # MobileBuild
......
......@@ -43,6 +43,7 @@
<file alias="PowerComponentBattery_04cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_04cell.svg</file>
<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="attitudeDial.svg">src/FlightMap/Images/attitudeDial.svg</file>
<file alias="attitudeInstrument.svg">src/FlightMap/Images/attitudeInstrument.svg</file>
<file alias="attitudePointer.svg">src//FlightMap/Images/attitudePointer.svg</file>
......@@ -61,6 +62,10 @@
<file alias="scale_end.png">src/FlightMap/Images/scale_end.png</file>
<file alias="airplaneOutline.svg">src/FlightMap/Images/airplaneOutline.svg</file>
<file alias="airplaneOpaque.svg">src/FlightMap/Images/airplaneOpaque.svg</file>
<file alias="MapType.svg">src/FlightMap/Images/MapType.svg</file>
<file alias="MapCenter.svg">src/FlightMap/Images/MapCenter.svg</file>
<file alias="ZoomPlus.svg">src/FlightMap/Images/ZoomPlus.svg</file>
<file alias="ZoomMinus.svg">src/FlightMap/Images/ZoomMinus.svg</file>
</qresource>
<qresource prefix="/qml">
<file alias="test.qml">src/test.qml</file>
......@@ -102,6 +107,7 @@
<file alias="QGroundControl/Controls/MissionItemSummary.qml">src/QmlControls/MissionItemSummary.qml</file>
<file alias="QGroundControl/Controls/MissionItemEditor.qml">src/QmlControls/MissionItemEditor.qml</file>
<file alias="QGroundControl/Controls/DropButton.qml">src/QmlControls/DropButton.qml</file>
<file alias="QGroundControl/Controls/QGCCanvas.qml">src/QmlControls/QGCCanvas.qml</file>
<!-- Vehicle Setup -->
<file alias="SetupView.qml">src/VehicleSetup/SetupView.qml</file>
......
......@@ -91,19 +91,3 @@ FlightDisplayView::FlightDisplayView(QWidget *parent)
FlightDisplayView::~FlightDisplayView()
{
}
void FlightDisplayView::saveSetting(const QString &name, const QString& value)
{
QSettings settings;
QString key(kMainFlightDisplayViewGroup);
key += "/" + name;
settings.setValue(key, value);
}
QString FlightDisplayView::loadSetting(const QString &name, const QString& defaultValue)
{
QSettings settings;
QString key(kMainFlightDisplayViewGroup);
key += "/" + name;
return settings.value(key, defaultValue).toString();
}
......@@ -38,9 +38,6 @@ public:
Q_PROPERTY(bool hasVideo READ hasVideo CONSTANT)
Q_INVOKABLE void saveSetting (const QString &key, const QString& value);
Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue);
#if defined(QGC_GST_STREAMING)
bool hasVideo () { return true; }
#else
......
......@@ -26,7 +26,9 @@ import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QtLocation 5.3
import QtPositioning 5.2
import QGroundControl 1.0
import QGroundControl.FlightMap 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
......@@ -66,7 +68,7 @@ Item {
property real _airSpeed: _activeVehicle ? _activeVehicle.airSpeed : _defaultAirSpeed
property real _climbRate: _activeVehicle ? _activeVehicle.climbRate : _defaultClimbRate
property bool _showMap: getBool(multiVehicleManager.loadSetting(_mapName + _showMapBackgroundKey, "1"))
property bool _showMap: getBool(QGroundControl.flightMapSettings.loadMapSetting(flightMap.mapName, _showMapBackgroundKey, "1"))
// Validate _showMap setting
Component.onCompleted: _setShowMap(_showMap)
......@@ -81,7 +83,7 @@ Item {
function _setShowMap(showMap) {
_showMap = flightDisplay.hasVideo ? showMap : true
multiVehicleManager.saveSetting(_mapName + _showMapBackgroundKey, setBool(_showMap))
QGroundControl.flightMapSettings.saveMapSetting(flightMap.mapName, _showMapBackgroundKey, setBool(_showMap))
}
FlightMap {
......@@ -92,6 +94,13 @@ Item {
longitude: parent._longitude
visible: _showMap
// Home position
MissionItemIndicator {
label: "H"
coordinate: (_activeVehicle && _activeVehicle.homePositionAvailable) ? _activeVehicle.homePosition : QtPositioning.coordinate(0, 0)
visible: _activeVehicle ? _activeVehicle.homePositionAvailable : false
}
// Add the vehicles to the map
MapItemView {
model: multiVehicleManager.vehicles
......@@ -141,7 +150,6 @@ Item {
size: ScreenTools.defaultFontPixelSize * (13.3)
heading: _heading
active: multiVehicleManager.activeVehicleAvailable
z: flightMap.z + 2
}
QGCAttitudeWidget {
......@@ -152,8 +160,39 @@ Item {
rollAngle: _roll
pitchAngle: _pitch
active: multiVehicleManager.activeVehicleAvailable
z: flightMap.z + 2
}
DropButton {
id: mapTypeButton
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.top: parent.top
anchors.right: parent.right
dropDirection: dropDown
buttonImage: "/qmlimages/MapType.svg"
viewportMargins: ScreenTools.defaultFontPixelWidth / 2
dropDownComponent: Component {
Row {
spacing: ScreenTools.defaultFontPixelWidth
Repeater {
model: QGroundControl.flightMapSettings.mapTypes
QGCButton {
checkable: true
checked: flightMap.mapType == text
text: modelData
onClicked: {
flightMap.mapType = text
mapTypeButton.hideDropDown()
}
}
}
}
}
}
} // Flight Map
QGCVideoBackground {
......@@ -280,8 +319,6 @@ Item {
MenuSeparator {
visible: flightDisplay.hasVideo && _showMap
}
Component.onCompleted: flightMap.addMapMenuItems(optionsMenu)
}
}
}
......@@ -32,6 +32,7 @@ import QtQuick.Controls 1.3
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
import QGroundControl.ScreenTools 1.0
......@@ -47,6 +48,7 @@ Map {
property real heading: 0
property bool interactive: true
property string mapName: 'defaultMap'
property string mapType: QGroundControl.flightMapSettings.mapTypeForMapName(mapName)
property alias mapWidgets: controlWidgets
property bool isSatelliteMap: false
......@@ -61,45 +63,20 @@ Map {
plugin: Plugin { name: "QGroundControl" }
ExclusiveGroup { id: mapTypeGroup }
// Map type selection MenuItem
Component {
id: menuItemComponent
MenuItem {
checkable: true
checked: text == _map.activeMapType.name
exclusiveGroup: mapTypeGroup
visible: _map.visible
onTriggered: setCurrentMap(text)
}
}
// Set the current map type to the specified type name
function setCurrentMap(name) {
Component.onCompleted: onMapTypeChanged
onMapTypeChanged: {
QGroundControl.flightMapSettings.setMapTypeForMapName(mapName, mapType)
var fullMapName = QGroundControl.flightMapSettings.mapProvider + " " + mapType
for (var i = 0; i < _map.supportedMapTypes.length; i++) {
if (name === _map.supportedMapTypes[i].name) {
if (fullMapName === _map.supportedMapTypes[i].name) {
_map.activeMapType = _map.supportedMapTypes[i]
multiVehicleManager.saveSetting(_map.mapName + "/currentMapType", name);
return;
return
}
}
}
// Add menu map types to the specified menu and sets the current map type from settings
function addMapMenuItems(menu) {
var savedMapName = multiVehicleManager.loadSetting(_map.mapName + "/currentMapType", "")
setCurrentMap(savedMapName)
for (var i = 0; i < _map.supportedMapTypes.length; i++) {
var menuItem = menuItemComponent.createObject()
menuItem.text = _map.supportedMapTypes[i].name
menu.insertItem(menu.items.length, menuItem)
}
}
/// Map control widgets
Column {
id: controlWidgets
......@@ -137,6 +114,7 @@ Map {
QGCButton {
width: parent._buttonWidth
//iconSource: "/qmlimages/ZoomPlus.svg"
text: "+"
onClicked: {
......@@ -152,6 +130,7 @@ Map {
QGCButton {
width: parent._buttonWidth
//iconSource: "/qmlimages/ZoomMinus.svg"
text: "-"
onClicked: {
......
/*=====================================================================
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/>.
======================================================================*/
#include "FlightMapSettings.h"
#include <QSettings>
#include <QtQml>
IMPLEMENT_QGC_SINGLETON(FlightMapSettings, FlightMapSettings)
const char* FlightMapSettings::_defaultMapProvider = "Bing"; // Bing is default since it support full street/satellite/hybrid set
const char* FlightMapSettings::_settingsGroup = "FlightMapSettings";
const char* FlightMapSettings::_mapProviderKey = "MapProvider";
const char* FlightMapSettings::_mapTypeKey = "MapType";
FlightMapSettings::FlightMapSettings(QObject* parent)
: QObject(parent)
, _mapProvider(_defaultMapProvider)
{
qmlRegisterUncreatableType<FlightMapSettings> ("QGroundControl", 1, 0, "FlightMapSetting", "Reference only");
_supportedMapProviders << "Bing" << "Google" << "Open";
_loadSettings();
}
FlightMapSettings::~FlightMapSettings()
{
}
void FlightMapSettings::_storeSettings(void)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.setValue(_mapProviderKey, _supportedMapProviders.contains(_mapProvider) ? _mapProvider : _defaultMapProvider);
}
void FlightMapSettings::_loadSettings(void)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
_mapProvider = settings.value(_mapProviderKey, _defaultMapProvider).toString();
if (!_supportedMapProviders.contains(_mapProvider)) {
_mapProvider = _defaultMapProvider;
}
_setMapTypesForCurrentProvider();
}
QString FlightMapSettings::mapProvider(void)
{
return _mapProvider;
}
void FlightMapSettings::setMapProvider(const QString& mapProvider)
{
if (_supportedMapProviders.contains(mapProvider)) {
_mapProvider = mapProvider;
_storeSettings();
_setMapTypesForCurrentProvider();
emit mapProviderChanged(mapProvider);
}
}
void FlightMapSettings::_setMapTypesForCurrentProvider(void)
{
_mapTypes.clear();
if (_mapProvider == "Bing") {
_mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map";
} else if (_mapProvider == "Google") {
_mapTypes << "Street Map" << "Satellite Map" << "Terrain Map";
} else if (_mapProvider == "Open") {
_mapTypes << "Street Map";
}
emit mapTypesChanged(_mapTypes);
}
QString FlightMapSettings::mapTypeForMapName(const QString& mapName)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName);
settings.beginGroup(_mapProvider);
return settings.value(_mapTypeKey, "Street Map").toString();
}
void FlightMapSettings::setMapTypeForMapName(const QString& mapName, const QString& mapType)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName);
settings.beginGroup(_mapProvider);
settings.setValue(_mapTypeKey, mapType);
}
void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& key, const QString& value)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName);
settings.setValue(key, value);
}
QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName);
return settings.value(key, defaultValue).toString();
}
/*=====================================================================
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/>.
======================================================================*/
#ifndef FlightMapSettings_H
#define FlightMapSettings_H
#include "QGCSingleton.h"
#include <QStringList>
class FlightMapSettings : public QObject
{
Q_OBJECT
DECLARE_QGC_SINGLETON(FlightMapSettings, FlightMapSettings)
public:
/// mapProvider is either Bing, Google or Open to specify to set of maps available
Q_PROPERTY(QString mapProvider READ mapProvider WRITE setMapProvider NOTIFY mapProviderChanged)
/// Map types associated with current map provider
Q_PROPERTY(QStringList mapTypes MEMBER _mapTypes NOTIFY mapTypesChanged)
Q_INVOKABLE QString mapTypeForMapName(const QString& mapName);
Q_INVOKABLE void setMapTypeForMapName(const QString& mapName, const QString& mapType);
Q_INVOKABLE void saveMapSetting (const QString &mapName, const QString& key, const QString& value);
Q_INVOKABLE QString loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue);
// Property accessors
QString mapProvider(void);
void setMapProvider(const QString& mapProvider);
signals:
void mapProviderChanged(const QString& mapProvider);
void mapTypesChanged(const QStringList& mapTypes);
private:
/// @brief All access to FlightMapSettings singleton is through FlightMapSettings::instance
FlightMapSettings(QObject* parent = NULL);
~FlightMapSettings();
void _storeSettings(void);
void _loadSettings(void);
void _setMapTypesForCurrentProvider(void);
QString _mapProvider; ///< Current map provider
QStringList _supportedMapProviders;
QStringList _mapTypes; ///< Map types associated with current map provider
static const char* _defaultMapProvider;
static const char* _settingsGroup;
static const char* _mapProviderKey;
static const char* _mapTypeKey;
};
#endif
......@@ -2,12 +2,12 @@
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 72 72" enable-background="new 0 0 72 72" xml:space="preserve">
<circle opacity="0.75" cx="36" cy="36" r="34.2"/>
<circle opacity="0.95" cx="36" cy="36" r="34.2"/>
<g>
<circle fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" cx="36" cy="36" r="27"/>
<line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="8.899" y1="35.97" x2="22.219" y2="36.03"/>
<line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="35.97" y1="63.101" x2="36.03" y2="49.781"/>
<line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="63.101" y1="36.03" x2="49.781" y2="35.97"/>
<line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="36.03" y1="8.899" x2="35.97" y2="22.219"/>
<circle fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" cx="36" cy="36" r="22.38"/>
<line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="13.536" y1="35.975" x2="24.577" y2="36.025"/>
<line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="35.975" y1="58.464" x2="36.025" y2="47.423"/>
<line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="58.464" y1="36.025" x2="47.423" y2="35.975"/>
<line fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" x1="36.025" y1="13.536" x2="35.975" y2="24.577"/>
</g>
</svg>
......@@ -2,9 +2,9 @@
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 72 72" enable-background="new 0 0 72 72" xml:space="preserve">
<circle opacity="0.75" cx="36" cy="36" r="34.2"/>
<circle opacity="0.95" cx="36" cy="36" r="34.2"/>
<g>
<polygon fill="#414042" stroke="#FFFFFF" stroke-miterlimit="10" points="63,39.345 36,59.4 9,39.345 36,19.291 "/>
<polygon fill="#414042" stroke="#FFFFFF" stroke-miterlimit="10" points="63,32.655 36,52.709 9,32.655 36,12.6 "/>
<polygon stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" points="58.5,38.788 36,55.5 13.5,38.788 36,22.076 "/>
<polygon stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" points="58.5,33.212 36,49.924 13.5,33.212 36,16.5 "/>
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 72 72" enable-background="new 0 0 72 72" xml:space="preserve">
<path opacity="0.85" d="M0,72V0l72,0C72,39.797,39.797,72,0,72z"/>
<g>
<rect x="14.4" y="15.401" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" width="36" height="27"/>
<rect x="5.4" y="6.401" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" width="36" height="27"/>
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 72 72" enable-background="new 0 0 72 72" xml:space="preserve">
<circle fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" cx="29.573" cy="30.04" r="22.416"/>
<line fill="none" stroke="#FFFFFF" stroke-width="3" stroke-miterlimit="10" x1="64.8" y1="64.83" x2="45.801" y2="45.765"/>
<line fill="none" x1="16.973" y1="30.04" x2="42.173" y2="30.04"/>
<line fill="none" stroke="#FFFFFF" stroke-width="5" stroke-miterlimit="10" x1="16.973" y1="30.134" x2="42.173" y2="29.946"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 72 72" enable-background="new 0 0 72 72" xml:space="preserve">
<circle fill="none" stroke="#FFFFFF" stroke-width="2" stroke-miterlimit="10" cx="29.573" cy="30.04" r="22.416"/>
<line fill="none" stroke="#FFFFFF" stroke-width="3" stroke-miterlimit="10" x1="64.8" y1="64.83" x2="45.801" y2="45.765"/>
<path fill="#FFFFFF" d="M27.36,42.653V32.187H16.973v-4.374H27.36V17.426h4.426v10.387h10.387v4.374H31.786v10.466H27.36z"/>
</svg>
......@@ -25,6 +25,7 @@
#include <QApplication>
#include <QTimer>
#include <QSettings>
#include <QtQml>
#include "UAS.h"
#include "UASInterface.h"
......@@ -51,6 +52,8 @@ HomePositionManager::HomePositionManager(QObject* parent)
, homeLon(8.549444)
, homeAlt(470.0)
{
qmlRegisterUncreatableType<HomePositionManager> ("QGroundControl", 1, 0, "HomePositionManager", "Reference only");
_loadSettings();
}
......
......@@ -104,7 +104,8 @@ int MissionEditor::addMissionItem(QGeoCoordinate coordinate)
qWarning() << "addMissionItem called with _canEdit == false";
}
MissionItem * newItem = new MissionItem(this, _missionItems->count(), coordinate);
MissionItem * newItem = new MissionItem(this, _missionItems->count(), coordinate, MAV_CMD_NAV_WAYPOINT);
newItem->setAltitude(30);
if (_missionItems->count() == 0) {
newItem->setCommand(MavlinkQmlSingleton::MAV_CMD_NAV_TAKEOFF);
}
......
......@@ -104,7 +104,7 @@ QGCView {
anchors.right: mapTypeButton.left
anchors.top: mapTypeButton.top
dropDirection: dropDown
label: "C"
buttonImage: "/qmlimages/MapCenter.svg"
viewportMargins: ScreenTools.defaultFontPixelWidth / 2
dropDownComponent: Component {
......@@ -114,14 +114,48 @@ QGCView {
QGCButton {
text: "Home"
onClicked: centerMapButton.hideDropDown()
onClicked: {
centerMapButton.hideDropDown()
editorMap.center = QtPositioning.coordinate(_homePositionCoordinate.latitude, _homePositionCoordinate.longitude)
_showHomePositionManager = true
}
}
/*
This code will need to wait for Qml 5.5 support since Map.visibleRegion is only in Qt 5.5
QGCButton {
text: "All Items"
onClicked: centerMapButton.hideDropDown()
onClicked: {
centerMapButton.hideDropDown()
// Begin with only the home position in the region
var region = QtPositioning.rectangle(QtPositioning.coordinate(_homePositionCoordinate.latitude, _homePositionCoordinate.longitude),
QtPositioning.coordinate(_homePositionCoordinate.latitude, _homePositionCoordinate.longitude))
// Now expand the region to include all mission items
for (var i=0; i<_missionItems.count; i++) {
var missionItem = _missionItems.get(i)
region.topLeft.latitude = Math.max(missionItem.coordinate.latitude, region.topLeft.latitude)
region.topLeft.longitude = Math.min(missionItem.coordinate.longitude, region.topLeft.longitude)
region.topRight.latitude = Math.max(missionItem.coordinate.latitude, region.topRight.latitude)
region.topRight.longitude = Math.max(missionItem.coordinate.longitude, region.topRight.longitude)
region.bottomLeft.latitude = Math.min(missionItem.coordinate.latitude, region.bottomLeft.latitude)
region.bottomLeft.longitude = Math.min(missionItem.coordinate.longitude, region.bottomLeft.longitude)
region.bottomRight.latitude = Math.min(missionItem.coordinate.latitude, region.bottomRight.latitude)
region.bottomRight.longitude = Math.max(missionItem.coordinate.longitude, region.bottomRight.longitude)
}
editorMap.visibleRegion = region
}
}
*/
}
}
}
......@@ -132,29 +166,26 @@ QGCView {
anchors.top: parent.top
anchors.right: parent.right
dropDirection: dropDown
label: "M"
buttonImage: "/qmlimages/MapType.svg"
viewportMargins: ScreenTools.defaultFontPixelWidth / 2
dropDownComponent: Component {
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCButton {
text: "Street"
onClicked: mapTypeButton.hideDropDown()
}
QGCButton {
text: "Satellite"
onClicked: mapTypeButton.hideDropDown()
}
Repeater {
model: QGroundControl.flightMapSettings.mapTypes
QGCButton {
text: "Hybrid"
QGCButton {
checkable: true
checked: editorMap.mapType == text
text: modelData
onClicked: mapTypeButton.hideDropDown()
onClicked: {
editorMap.mapType = text
mapTypeButton.hideDropDown()
}
}
}
}
}
......
......@@ -67,16 +67,17 @@ const MissionItem::MavCmd2Name_t MissionItem::_rgMavCmd2Name[_cMavCmd2Name] = {
MissionItem::MissionItem(QObject* parent,
int sequenceNumber,
QGeoCoordinate coordinate,
int command,
double param1,
double param2,
double param3,
double param4,
bool autocontinue,
bool isCurrentItem,
int frame,
int command)
int frame)
: QObject(parent)
, _sequenceNumber(sequenceNumber)
, _frame(-1) // Forces set of _altitudeRelativeToHomeFact
, _command((MavlinkQmlSingleton::Qml_MAV_CMD)command)
, _autocontinue(autocontinue)
, _isCurrentItem(isCurrentItem)
......@@ -219,7 +220,7 @@ void MissionItem::save(QTextStream &saveStream)
position = position.arg(y(), 0, 'g', 18);
position = position.arg(z(), 0, 'g', 18);
QString parameters("%1\t%2\t%3\t%4");
parameters = parameters.arg(param2(), 0, 'g', 18).arg(param2(), 0, 'g', 18).arg(loiterOrbitRadius(), 0, 'g', 18).arg(yawRadians(), 0, 'g', 18);
parameters = parameters.arg(param1(), 0, 'g', 18).arg(param2(), 0, 'g', 18).arg(loiterOrbitRadius(), 0, 'g', 18).arg(yawRadians(), 0, 'g', 18);
// FORMAT: <INDEX> <CURRENT WP> <COORD FRAME> <COMMAND> <PARAM1> <PARAM2> <PARAM3> <PARAM4> <PARAM5/X/LONGITUDE> <PARAM6/Y/LATITUDE> <PARAM7/Z/ALTITUDE> <AUTOCONTINUE> <DESCRIPTION>
// as documented here: http://qgroundcontrol.org/waypoint_protocol
saveStream << this->sequenceNumber() << "\t" << this->isCurrentItem() << "\t" << this->frame() << "\t" << this->command() << "\t" << parameters << "\t" << position << "\t" << this->autoContinue() << "\r\n"; //"\t" << this->getDescription() << "\r\n";
......@@ -280,7 +281,7 @@ void MissionItem::setZ(double z)
void MissionItem::setLatitude(double lat)
{
if (_latitudeFact->value().toDouble() != lat && ((_frame == MAV_FRAME_GLOBAL) || (_frame == MAV_FRAME_GLOBAL_RELATIVE_ALT)))
if (_latitudeFact->value().toDouble() != lat)
{
_latitudeFact->setValue(lat);
emit changed(this);
......@@ -290,7 +291,7 @@ void MissionItem::setLatitude(double lat)
void MissionItem::setLongitude(double lon)
{
if (_longitudeFact->value().toDouble() != lon && ((_frame == MAV_FRAME_GLOBAL) || (_frame == MAV_FRAME_GLOBAL_RELATIVE_ALT)))
if (_longitudeFact->value().toDouble() != lon)
{
_longitudeFact->setValue(lon);
emit changed(this);
......@@ -300,7 +301,7 @@ void MissionItem::setLongitude(double lon)
void MissionItem::setAltitude(double altitude)
{
if (_altitudeFact->value().toDouble() != altitude && ((_frame == MAV_FRAME_GLOBAL) || (_frame == MAV_FRAME_GLOBAL_RELATIVE_ALT)))
if (_altitudeFact->value().toDouble() != altitude)
{
_altitudeFact->setValue(altitude);
emit changed(this);
......@@ -349,7 +350,7 @@ int MissionItem::frame(void) const
void MissionItem::setFrame(int /*MAV_FRAME*/ frame)
{
if (_frame != frame) {
_altitudeRelativeToHomeFact->setValue(_frame == MAV_FRAME_GLOBAL_RELATIVE_ALT);
_altitudeRelativeToHomeFact->setValue(frame == MAV_FRAME_GLOBAL_RELATIVE_ALT);
_frame = frame;
emit changed(this);
}
......
......@@ -47,14 +47,14 @@ public:
MissionItem(QObject *parent = 0,
int sequenceNumber = 0,
QGeoCoordinate coordiante = QGeoCoordinate(),
int action = MAV_CMD_NAV_WAYPOINT,
double param1 = 0.0,
double param2 = 0.0,
double param3 = 0.0,
double param4 = 0.0,
bool autocontinue = true,
bool isCurrentItem = false,
int frame = MAV_FRAME_GLOBAL,
int action = MAV_CMD_NAV_WAYPOINT);
int frame = MAV_FRAME_GLOBAL_RELATIVE_ALT);
MissionItem(const MissionItem& other, QObject* parent = NULL);
~MissionItem();
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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/>.
======================================================================*/
#include "MissionItemTest.h"
UT_REGISTER_TEST(MissionItemTest)
const MissionItemTest::ItemInfo_t MissionItemTest::_rgItemInfo[] = {
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_WAYPOINT, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_UNLIM, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_TURNS, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_TIME, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LAND, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_TAKEOFF, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_CONDITION_DELAY, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_MISSION },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_DO_JUMP, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_MISSION },
};
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesWaypoint[] = {
{ "Latitude:", -10.0 },
{ "Longitude:", -20.0 },
{ "Altitude:", -30.0 },
{ "Heading:", 40.0 },
{ "Radius:", 20.0 },
{ "Hold:", 10.0 },
};
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterUnlim[] = {
{ "Latitude:", -10.0 },
{ "Longitude:", -20.0 },
{ "Altitude:", -30.0 },
{ "Heading:", 40.0 },
{ "Radius:", 30.0 },
};
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterTurns[] = {
{ "Latitude:", -10.0 },
{ "Longitude:", -20.0 },
{ "Altitude:", -30.0 },
{ "Heading:", 40.0 },
{ "Radius:", 30.0 },
{ "Turns:", 10.0 },
};
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLoiterTime[] = {
{ "Latitude:", -10.0 },
{ "Longitude:", -20.0 },
{ "Altitude:", -30.0 },
{ "Heading:", 40.0 },
{ "Radius:", 30.0 },
{ "Seconds:", 10.0 },
};
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesLand[] = {
{ "Latitude:", -10.0 },
{ "Longitude:", -20.0 },
{ "Altitude:", -30.0 },
{ "Heading:", 40.0 },
};
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesTakeoff[] = {
{ "Latitude:", -10.0 },
{ "Longitude:", -20.0 },
{ "Altitude:", -30.0 },
{ "Heading:", 40.0 },
{ "Pitch:", 10.0 },
};
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesConditionDelay[] = {
{ "Seconds:", 10.0 },
};
const MissionItemTest::FactValue_t MissionItemTest::_rgFactValuesDoJump[] = {
{ "Seq #:", 10.0 },
{ "Repeat:", 20.0 },
};
const MissionItemTest::ItemExpected_t MissionItemTest::_rgItemExpected[] = {
{ "1\t0\t3\t16\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesWaypoint)/sizeof(MissionItemTest::_rgFactValuesWaypoint[0]), MissionItemTest::_rgFactValuesWaypoint },
{ "1\t0\t3\t17\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLoiterUnlim)/sizeof(MissionItemTest::_rgFactValuesLoiterUnlim[0]), MissionItemTest::_rgFactValuesLoiterUnlim },
{ "1\t0\t3\t18\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLoiterTurns)/sizeof(MissionItemTest::_rgFactValuesLoiterTurns[0]), MissionItemTest::_rgFactValuesLoiterTurns },
{ "1\t0\t3\t19\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLoiterTime)/sizeof(MissionItemTest::_rgFactValuesLoiterTime[0]), MissionItemTest::_rgFactValuesLoiterTime },
{ "1\t0\t3\t21\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesLand)/sizeof(MissionItemTest::_rgFactValuesLand[0]), MissionItemTest::_rgFactValuesLand },
{ "1\t0\t3\t22\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesTakeoff)/sizeof(MissionItemTest::_rgFactValuesTakeoff[0]), MissionItemTest::_rgFactValuesTakeoff },
{ "1\t0\t2\t112\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesConditionDelay)/sizeof(MissionItemTest::_rgFactValuesConditionDelay[0]), MissionItemTest::_rgFactValuesConditionDelay },
{ "1\t0\t2\t177\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", sizeof(MissionItemTest::_rgFactValuesDoJump)/sizeof(MissionItemTest::_rgFactValuesDoJump[0]), MissionItemTest::_rgFactValuesDoJump },
};
MissionItemTest::MissionItemTest(void)
{
}
void MissionItemTest::_test(void)
{
for (size_t i=0; i<sizeof(_rgItemInfo)/sizeof(_rgItemInfo[0]); i++) {
const ItemInfo_t* info = &_rgItemInfo[i];
const ItemExpected_t* expected = &_rgItemExpected[i];
qDebug() << "Command:" << info->command;
MissionItem* item = new MissionItem(NULL,
info->sequenceNumber,
info->coordinate,
info->command,
info->param1,
info->param2,
info->param3,
info->param4,
info->autocontinue,
info->isCurrentItem,
info->frame);
// Validate the saving is working correctly
QString savedItemString;
QTextStream saveStream(&savedItemString, QIODevice::WriteOnly);
item->save(saveStream);
QCOMPARE(savedItemString, QString(expected->streamString));
// Validate that the fact values are correctly returned
size_t factCount = 0;
for (int i=0; i<item->textFieldFacts()->count(); i++) {
Fact* fact = qobject_cast<Fact*>(item->textFieldFacts()->get(i));
bool found = false;
for (size_t j=0; j<expected->cFactValues; j++) {
const FactValue_t* factValue = &expected->rgFactValues[j];
if (factValue->name == fact->name()) {
qDebug() << factValue->name;
QCOMPARE(fact->value().toDouble(), factValue->value);
factCount ++;
found = true;
break;
}
}
QVERIFY(found);
}
QCOMPARE(factCount, expected->cFactValues);
// Validate that loading is working correctly
MissionItem* loadedItem = new MissionItem();
QTextStream loadStream(&savedItemString, QIODevice::ReadOnly);
QVERIFY(loadedItem->load(loadStream));
//qDebug() << savedItemString;
QCOMPARE(loadedItem->coordinate().latitude(), item->coordinate().latitude());
QCOMPARE(loadedItem->coordinate().longitude(), item->coordinate().longitude());
QCOMPARE(loadedItem->coordinate().altitude(), item->coordinate().altitude());
QCOMPARE(loadedItem->command(), item->command());
QCOMPARE(loadedItem->param1(), item->param1());
QCOMPARE(loadedItem->param2(), item->param2());
QCOMPARE(loadedItem->param3(), item->param3());
QCOMPARE(loadedItem->param4(), item->param4());
QCOMPARE(loadedItem->autoContinue(), item->autoContinue());
QCOMPARE(loadedItem->isCurrentItem(), item->isCurrentItem());
QCOMPARE(loadedItem->frame(), item->frame());
delete item;
delete loadedItem;
}
}
/*=====================================================================
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/>.
======================================================================*/
#ifndef MissionItemTest_H
#define MissionItemTest_H
#include "UnitTest.h"
#include "TCPLink.h"
#include "MultiSignalSpy.h"
/// @file
/// @brief FlightGear HIL Simulation unit tests
///
/// @author Don Gagne <don@thegagnes.com>
class MissionItemTest : public UnitTest
{
Q_OBJECT
public:
MissionItemTest(void);
private slots:
void _test(void);
private:
typedef struct {
int sequenceNumber;
QGeoCoordinate coordinate;
int command;
double param1;
double param2;
double param3;
double param4;
bool autocontinue;
bool isCurrentItem;
int frame;
} ItemInfo_t;
typedef struct {
const char* name;
double value;
} FactValue_t;
typedef struct {
const char* streamString;
size_t cFactValues;
const FactValue_t* rgFactValues;
} ItemExpected_t;
static const ItemInfo_t _rgItemInfo[];
static const ItemExpected_t _rgItemExpected[];
static const FactValue_t _rgFactValuesWaypoint[];
static const FactValue_t _rgFactValuesLoiterUnlim[];
static const FactValue_t _rgFactValuesLoiterTurns[];
static const FactValue_t _rgFactValuesLoiterTime[];
static const FactValue_t _rgFactValuesLand[];
static const FactValue_t _rgFactValuesTakeoff[];
static const FactValue_t _rgFactValuesConditionDelay[];
static const FactValue_t _rgFactValuesDoJump[];
};
#endif
......@@ -79,11 +79,12 @@ void MissionManager::writeMissionItems(const QmlObjectListModel& missionItems)
_vehicle->sendMessage(message);
_startAckTimeout(AckMissionRequest, message);
emit inProgressChanged(true);
}
void MissionManager::requestMissionItems(void)
{
qCDebug(MissionManagerLog) << "_requestMissionItems";
qCDebug(MissionManagerLog) << "requestMissionItems read sequence";
mavlink_message_t message;
mavlink_mission_request_list_t request;
......@@ -97,6 +98,7 @@ void MissionManager::requestMissionItems(void)
_vehicle->sendMessage(message);
_startAckTimeout(AckMissionCount, message);
emit inProgressChanged(true);
}
void MissionManager::_ackTimeout(void)
......@@ -157,6 +159,7 @@ void MissionManager::_sendTransactionComplete(void)
_vehicle->sendMessage(message);
emit newMissionItemsAvailable();
emit inProgressChanged(false);
}
void MissionManager::_handleMissionCount(const mavlink_message_t& message)
......@@ -174,6 +177,7 @@ void MissionManager::_handleMissionCount(const mavlink_message_t& message)
if (_cMissionItems == 0) {
emit newMissionItemsAvailable();
emit inProgressChanged(false);
} else {
_requestNextMissionItem(0);
}
......@@ -222,14 +226,14 @@ void MissionManager::_handleMissionItem(const mavlink_message_t& message)
MissionItem* item = new MissionItem(this,
missionItem.seq,
QGeoCoordinate(missionItem.x, missionItem.y, missionItem.z),
missionItem.command,
missionItem.param1,
missionItem.param2,
missionItem.param3,
missionItem.param3,
missionItem.param4,
missionItem.autocontinue,
missionItem.current,
missionItem.frame,
missionItem.command);
missionItem.frame);
_missionItems.append(item);
if (!item->canEdit()) {
......@@ -308,8 +312,11 @@ void MissionManager::_handleMissionAck(const mavlink_message_t& message)
if (missionAck.type == MAV_MISSION_ACCEPTED) {
qCDebug(MissionManagerLog) << "_handleMissionAck write sequence complete";
} else {
_missionItems.clear();
emit newMissionItemsAvailable();
qCDebug(MissionManagerLog) << "_handleMissionAck ack error:" << missionAck.type;
}
emit inProgressChanged(false);
}
/// Called when a new mavlink message for out vehicle is received
......
......@@ -47,7 +47,7 @@ public:
MissionManager(Vehicle* vehicle);
~MissionManager();
Q_PROPERTY(bool inProgress READ inProgress CONSTANT)
Q_PROPERTY(bool inProgress READ inProgress NOTIFY inProgressChanged)
Q_PROPERTY(QmlObjectListModel* missionItems READ missionItems CONSTANT)
Q_PROPERTY(bool canEdit READ canEdit NOTIFY canEditChanged)
......@@ -72,6 +72,7 @@ signals:
// Public signals
void canEditChanged(bool canEdit);
void newMissionItemsAvailable(void);
void inProgressChanged(bool inProgress);
private slots:
void _mavlinkMessageReceived(const mavlink_message_t& message);
......
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/>.
======================================================================*/
#ifndef MissionManagerTest_H
#define MissionManagerTest_H
#include "UnitTest.h"
#include "MockLink.h"
#include "MissionManager.h"
#include "MultiSignalSpy.h"
class MissionManagerTest : public UnitTest
{
Q_OBJECT
public:
MissionManagerTest(void);
private slots:
void init(void);
void cleanup(void);
void _readEmptyVehicle(void);
void _roundTripItems(void);
private:
void _checkInProgressValues(bool inProgress);
MockLink* _mockLink;
MissionManager* _missionManager;
enum {
canEditChangedSignalIndex = 0,
newMissionItemsAvailableSignalIndex,
inProgressChangedSignalIndex,
maxSignalIndex
};
enum {
canEditChangedSignalMask = 1 << canEditChangedSignalIndex,
newMissionItemsAvailableSignalMask = 1 << newMissionItemsAvailableSignalIndex,
inProgressChangedSignalMask = 1 << inProgressChangedSignalIndex,
};
MultiSignalSpy* _multiSpy;
static const size_t _cSignals = maxSignalIndex;
const char* _rgSignals[_cSignals];
typedef struct {
int sequenceNumber;
QGeoCoordinate coordinate;
int command;
double param1;
double param2;
double param3;
double param4;
bool autocontinue;
bool isCurrentItem;
int frame;
} ItemInfo_t;
typedef struct {
const char* itemStream;
const ItemInfo_t expectedItem;
} TestCase_t;
static const TestCase_t _rgTestCases[];
};
#endif
......@@ -83,6 +83,7 @@
#include "MissionManager.h"
#include "QGroundControlQmlGlobal.h"
#include "HomePositionManager.h"
#include "FlightMapSettings.h"
#ifndef __ios__
#include "SerialLink.h"
......@@ -161,7 +162,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
, _runningUnitTests(unitTesting)
, _styleIsDark(true)
, _fakeMobile(false)
, _useNewMissionEditor(false)
#ifdef UNITTEST_BUILD
, _useNewMissionEditor(true) // Unit Tests run new mission editor
#endif
#ifdef QT_DEBUG
, _testHighDPI(false)
#endif
......@@ -313,7 +316,6 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType<JoystickManager> ("QGroundControl.JoystickManager", 1, 0, "JoystickManager", "Reference only");
qmlRegisterUncreatableType<Joystick> ("QGroundControl.JoystickManager", 1, 0, "Joystick", "Reference only");
qmlRegisterUncreatableType<QmlObjectListModel> ("QGroundControl", 1, 0, "QmlObjectListModel", "Reference only");
qmlRegisterUncreatableType<HomePositionManager> ("QGroundControl", 1, 0, "HomePositionManager", "Reference only");
qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<ParameterEditorController> ("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
......@@ -550,6 +552,16 @@ void QGCApplication::_createSingletons(void)
{
// The order here is important since the singletons reference each other
// No dependencies
FlightMapSettings* flightMapSettings = FlightMapSettings::_createSingleton();
Q_UNUSED(flightMapSettings);
Q_ASSERT(flightMapSettings);
// No dependencies
HomePositionManager* homePositionManager = HomePositionManager::_createSingleton();
Q_UNUSED(homePositionManager);
Q_ASSERT(homePositionManager);
// No dependencies
FirmwarePlugin* firmwarePlugin = GenericFirmwarePlugin::_createSingleton();
Q_UNUSED(firmwarePlugin);
......@@ -584,22 +596,17 @@ void QGCApplication::_createSingletons(void)
Q_UNUSED(linkManager);
Q_ASSERT(linkManager);
// Needs LinkManager
HomePositionManager* uasManager = HomePositionManager::_createSingleton();
Q_UNUSED(uasManager);
Q_ASSERT(uasManager);
// Need HomePositionManager
// Need MultiVehicleManager
AutoPilotPluginManager* pluginManager = AutoPilotPluginManager::_createSingleton();
Q_UNUSED(pluginManager);
Q_ASSERT(pluginManager);
// Need HomePositionManager
// Need MultiVehicleManager
UASMessageHandler* messageHandler = UASMessageHandler::_createSingleton();
Q_UNUSED(messageHandler);
Q_ASSERT(messageHandler);
// Needs HomePositionManager
// Needs MultiVehicleManager
FactSystem* factSystem = FactSystem::_createSingleton();
Q_UNUSED(factSystem);
Q_ASSERT(factSystem);
......@@ -631,7 +638,6 @@ void QGCApplication::_destroySingletons(void)
FactSystem::_deleteSingleton();
UASMessageHandler::_deleteSingleton();
AutoPilotPluginManager::_deleteSingleton();
HomePositionManager::_deleteSingleton();
LinkManager::_deleteSingleton();
GAudioOutput::_deleteSingleton();
JoystickManager::_deleteSingleton();
......@@ -640,6 +646,8 @@ void QGCApplication::_destroySingletons(void)
GenericFirmwarePlugin::_deleteSingleton();
PX4FirmwarePlugin::_deleteSingleton();
APMFirmwarePlugin::_deleteSingleton();
HomePositionManager::_deleteSingleton();
FlightMapSettings::_deleteSingleton();
}
void QGCApplication::informationMessageBoxOnMainThread(const QString& title, const QString& msg)
......
import QtQuick 2.2
import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
......@@ -8,8 +8,8 @@ import QGroundControl.Palette 1.0
Item {
id: _root
property alias label: buttonLabel.text
property alias radius: button.radius
property alias buttonImage: button.source
property real radius: (ScreenTools.defaultFontPixelHeight * 3) / 2
property int dropDirection: dropDown
property alias dropDownComponent: dropDownLoader.sourceComponent
property real viewportMargins: 0
......@@ -144,33 +144,25 @@ Item {
}
// Button
Rectangle {
Image {
id: button
anchors.fill: parent
radius: (ScreenTools.defaultFontPixelHeight * 3) / 2
color: qgcPal.button
fillMode: Image.PreserveAspectFit
opacity: _showDropDown ? 1.0 : 0.75
QGCLabel {
id: buttonLabel
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: "white"
}
mipmap: true
smooth: true
MouseArea {
anchors.fill: parent
onClicked: _showDropDown = !_showDropDown
}
} // Rectangle - button
} // Image - button
Item {
id: dropDownItem
visible: _showDropDown
Canvas {
QGCCanvas {
id: arrowCanvas
anchors.fill: parent
......@@ -224,6 +216,13 @@ Item {
id: dropDownLoader
x: _dropMargin
y: _dropMargin
Connections {
target: dropDownLoader.item
onWidthChanged: _calcPositions()
onHeightChanged: _calcPositions()
}
}
}
} // Item - dropDownItem
......
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
/// Canvas has some sort of bug in it which can cause it to not paint when top level Views
/// are switched. In order to fix this we ahve a signal hacked into ScreenTools to force
/// a repaint.
Canvas {
Connections {
target: ScreenTools
onRepaintRequested: arrowCanvas.requestPaint()
}
}
......@@ -9,6 +9,7 @@ QGCComboBox 1.0 QGCComboBox.qml
QGCColoredImage 1.0 QGCColoredImage.qml
QGCToolBarButton 1.0 QGCToolBarButton.qml
QGCMovableItem 1.0 QGCMovableItem.qml
QGCCanvas 1.0 QGCCanvas.qml
SubMenuButton 1.0 SubMenuButton.qml
IndicatorButton 1.0 IndicatorButton.qml
......
......@@ -29,6 +29,7 @@
QGroundControlQmlGlobal::QGroundControlQmlGlobal(QObject* parent)
: QObject(parent)
, _homePositionManager(HomePositionManager::instance())
, _flightMapSettings(FlightMapSettings::instance())
{
}
......
......@@ -30,6 +30,7 @@
#include <QObject>
#include "HomePositionManager.h"
#include "FlightMapSettings.h"
class QGroundControlQmlGlobal : public QObject
{
......@@ -39,14 +40,17 @@ public:
QGroundControlQmlGlobal(QObject* parent = NULL);
~QGroundControlQmlGlobal();
Q_PROPERTY(HomePositionManager* homePositionManager READ homePositionManager CONSTANT)
Q_PROPERTY(HomePositionManager* homePositionManager READ homePositionManager CONSTANT)
Q_PROPERTY(FlightMapSettings* flightMapSettings READ flightMapSettings CONSTANT)
// Property accesors
HomePositionManager* homePositionManager(void) { return _homePositionManager; }
HomePositionManager* homePositionManager(void) { return _homePositionManager; }
FlightMapSettings* flightMapSettings(void) { return _flightMapSettings; }
private:
HomePositionManager* _homePositionManager;
FlightMapSettings* _flightMapSettings;
};
#endif
......@@ -51,6 +51,7 @@ Vehicle::Vehicle(LinkInterface* link, int vehicleId, MAV_AUTOPILOT firmwareType)
, _joystickMode(JoystickModeRC)
, _joystickEnabled(false)
, _uas(NULL)
, _homePositionAvailable(false)
, _mav(NULL)
, _currentMessageCount(0)
, _messageCount(0)
......@@ -203,6 +204,20 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
// Give the plugin a change to adjust the message contents
_firmwarePlugin->adjustMavlinkMessage(&message);
if (message.msgid == MAVLINK_MSG_ID_HOME_POSITION) {
mavlink_home_position_t homePos;
mavlink_msg_home_position_decode(&message, &homePos);
_homePosition.setLatitude(homePos.latitude / 10000000.0);
_homePosition.setLongitude(homePos.longitude / 10000000.0);
_homePosition.setAltitude(homePos.altitude / 1000.0);
_homePositionAvailable = true;
emit homePositionAvailableChanged(true);
emit homePositionChanged(_homePosition);
}
emit mavlinkMessageReceived(message);
_uas->receiveMessage(message);
......@@ -945,3 +960,17 @@ QmlObjectListModel* Vehicle::missionItemsModel(void)
return &_missionItems;
}
}
bool Vehicle::homePositionAvailable(void)
{
return _homePositionAvailable;
}
QGeoCoordinate Vehicle::homePosition(void)
{
if (!_homePositionAvailable) {
qWarning() << "Call to homePosition while _homePositionAvailable == false";
}
return _homePosition;
}
......@@ -59,6 +59,9 @@ public:
Q_PROPERTY(QGeoCoordinate coordinate MEMBER _geoCoordinate NOTIFY coordinateChanged)
Q_PROPERTY(MissionManager* missionManager MEMBER _missionManager CONSTANT)
Q_PROPERTY(bool homePositionAvailable READ homePositionAvailable NOTIFY homePositionAvailableChanged)
Q_PROPERTY(QGeoCoordinate homePosition READ homePosition NOTIFY homePositionChanged)
Q_INVOKABLE QString getMavIconColor();
//-- System Messages
......@@ -154,6 +157,9 @@ public:
MissionManager* missionManager(void) { return _missionManager; }
bool homePositionAvailable(void);
QGeoCoordinate homePosition(void);
typedef enum {
MessageNone,
MessageNormal,
......@@ -221,6 +227,8 @@ signals:
void joystickEnabledChanged(bool enabled);
void activeChanged(bool active);
void mavlinkMessageReceived(const mavlink_message_t& message);
void homePositionAvailableChanged(bool homePositionAvailable);
void homePositionChanged(const QGeoCoordinate& homePosition);
/// Used internally to move sendMessage call to main thread
void _sendMessageOnThread(mavlink_message_t message);
......@@ -318,6 +326,9 @@ private:
QGeoCoordinate _geoCoordinate;
bool _homePositionAvailable;
QGeoCoordinate _homePosition;
UASInterface* _mav;
int _currentMessageCount;
int _messageCount;
......
......@@ -183,6 +183,10 @@ bool PX4FirmwareUpgradeThreadWorker::_findBoardFromPorts(QSerialPortInfo& portIn
qCDebug(FirmwareUpgradeLog) << "Found PX4 FMU V1 (by name matching fallback)";
type = FoundBoardPX4FMUV1;
found = true;
} else if (info.description().startsWith("PX4 FMU")) {
qCDebug(FirmwareUpgradeLog) << "Found PX4 FMU, assuming V2 (by name matching fallback)";
type = FoundBoardPX4FMUV2;
found = true;
}
}
}
......
......@@ -88,7 +88,7 @@ MockLink::MockLink(MockConfiguration* config) :
_fileServer = new MockLinkFileServer(_vehicleSystemId, _vehicleComponentId, this);
Q_CHECK_PTR(_fileServer);
_missionItemHandler = new MockLinkMissionItemHandler(_vehicleSystemId, this);
_missionItemHandler = new MockLinkMissionItemHandler(this);
Q_CHECK_PTR(_missionItemHandler);
moveToThread(this);
......@@ -302,9 +302,11 @@ void MockLink::_handleIncomingMavlinkBytes(const uint8_t* bytes, int cBytes)
if (!mavlink_parse_char(getMavlinkChannel(), bytes[i], &msg, &comm)) {
continue;
}
Q_ASSERT(_missionItemHandler);
_missionItemHandler->handleMessage(msg);
if (_missionItemHandler->handleMessage(msg)) {
continue;
}
switch (msg.msgid) {
case MAVLINK_MSG_ID_HEARTBEAT:
......@@ -326,24 +328,6 @@ void MockLink::_handleIncomingMavlinkBytes(const uint8_t* bytes, int cBytes)
case MAVLINK_MSG_ID_PARAM_REQUEST_READ:
_handleParamRequestRead(msg);
break;
case MAVLINK_MSG_ID_MISSION_REQUEST_LIST:
_handleMissionRequestList(msg);
break;
case MAVLINK_MSG_ID_MISSION_REQUEST:
_handleMissionRequest(msg);
break;
case MAVLINK_MSG_ID_MISSION_ITEM:
_handleMissionItem(msg);
break;
#if 0
case MAVLINK_MSG_ID_MISSION_COUNT:
_handleMissionCount(msg);
break;
#endif
case MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL:
_handleFTP(msg);
......@@ -627,67 +611,6 @@ void MockLink::_handleParamRequestRead(const mavlink_message_t& msg)
respondWithMavlinkMessage(responseMsg);
}
void MockLink::_handleMissionRequestList(const mavlink_message_t& msg)
{
mavlink_mission_request_list_t request;
mavlink_msg_mission_request_list_decode(&msg, &request);
Q_ASSERT(request.target_system == _vehicleSystemId);
mavlink_message_t responseMsg;
mavlink_msg_mission_count_pack(_vehicleSystemId,
_vehicleComponentId,
&responseMsg, // Outgoing message
msg.sysid, // Target is original sender
msg.compid, // Target is original sender
_missionItems.count()); // Number of mission items
respondWithMavlinkMessage(responseMsg);
}
void MockLink::_handleMissionRequest(const mavlink_message_t& msg)
{
mavlink_mission_request_t request;
mavlink_msg_mission_request_decode(&msg, &request);
Q_ASSERT(request.target_system == _vehicleSystemId);
Q_ASSERT(request.seq < _missionItems.count());
mavlink_message_t responseMsg;
mavlink_mission_item_t item = _missionItems[request.seq];
mavlink_msg_mission_item_pack(_vehicleSystemId,
_vehicleComponentId,
&responseMsg, // Outgoing message
msg.sysid, // Target is original sender
msg.compid, // Target is original sender
request.seq, // Index of mission item being sent
item.frame,
item.command,
item.current,
item.autocontinue,
item.param1, item.param2, item.param3, item.param4,
item.x, item.y, item.z);
respondWithMavlinkMessage(responseMsg);
}
void MockLink::_handleMissionItem(const mavlink_message_t& msg)
{
mavlink_mission_item_t request;
mavlink_msg_mission_item_decode(&msg, &request);
Q_ASSERT(request.target_system == _vehicleSystemId);
// FIXME: What do you do with duplication sequence numbers?
Q_ASSERT(!_missionItems.contains(request.seq));
_missionItems[request.seq] = request;
}
void MockLink::emitRemoteControlChannelRawChanged(int channel, uint16_t raw)
{
uint16_t chanRaw[18];
......
......@@ -61,14 +61,8 @@ public:
MockLink(MockConfiguration* config = NULL);
~MockLink(void);
// Virtuals from LinkInterface
virtual QString getName(void) const { return _name; }
virtual void requestReset(void){ }
virtual bool isConnected(void) const { return _connected; }
virtual qint64 getConnectionSpeed(void) const { return 100000000; }
virtual qint64 bytesAvailable(void) { return 0; }
// MockLink methods
int vehicleId(void) { return _vehicleSystemId; }
MAV_AUTOPILOT getAutopilotType(void) { return _autopilotType; }
void setAutopilotType(MAV_AUTOPILOT autopilot) { _autopilotType = autopilot; }
void emitRemoteControlChannelRawChanged(int channel, uint16_t raw);
......@@ -78,6 +72,13 @@ public:
MockLinkFileServer* getFileServer(void) { return _fileServer; }
// Virtuals from LinkInterface
virtual QString getName(void) const { return _name; }
virtual void requestReset(void){ }
virtual bool isConnected(void) const { return _connected; }
virtual qint64 getConnectionSpeed(void) const { return 100000000; }
virtual qint64 bytesAvailable(void) { return 0; }
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
bool connect(void);
......@@ -120,9 +121,6 @@ private:
void _handleParamRequestList(const mavlink_message_t& msg);
void _handleParamSet(const mavlink_message_t& msg);
void _handleParamRequestRead(const mavlink_message_t& msg);
void _handleMissionRequestList(const mavlink_message_t& msg);
void _handleMissionRequest(const mavlink_message_t& msg);
void _handleMissionItem(const mavlink_message_t& msg);
void _handleFTP(const mavlink_message_t& msg);
void _handleCommandLong(const mavlink_message_t& msg);
float _floatUnionForParam(int componentId, const QString& paramName);
......@@ -142,9 +140,6 @@ private:
QMap<int, QMap<QString, QVariant> > _mapParamName2Value;
QMap<QString, MAV_PARAM_TYPE> _mapParamName2MavParamType;
typedef QMap<uint16_t, mavlink_mission_item_t> MissionList_t;
MissionList_t _missionItems;
uint8_t _mavBaseMode;
uint32_t _mavCustomMode;
uint8_t _mavState;
......
This diff is collapsed.
......@@ -21,90 +21,46 @@
======================================================================*/
#ifndef MOCKLINKMISSIONITEMHANDLER_H
#define MOCKLINKMISSIONITEMHANDLER_H
// FIXME: This file is a work in progress
#ifndef MockLinkMissionItemHandler_H
#define MockLinkMissionItemHandler_H
#include <QObject>
#include <vector>
#include <QMap>
#include "QGCMAVLink.h"
#include "QGCLoggingCategory.h"
/* Alreedy defined in MAVLinkSimulationLink.h above!
enum PX_WAYPOINTPLANNER_STATES {
PX_WPP_IDLE = 0,
PX_WPP_SENDLIST,
PX_WPP_SENDLIST_SENDWPS,
PX_WPP_GETLIST,
PX_WPP_GETLIST_GETWPS,
PX_WPP_GETLIST_GOTALL
};
*/
class MockLink;
Q_DECLARE_LOGGING_CATEGORY(MockLinkMissionItemHandlerLog)
class MockLinkMissionItemHandler : public QObject
{
Q_OBJECT
public:
MockLinkMissionItemHandler(uint16_t systemId, QObject* parent = NULL);
MockLinkMissionItemHandler(MockLink* mockLink);
/// @brief Called to handle mission item related messages. All messages should be passed to this method.
/// It will handle the appropriate set.
void handleMessage(const mavlink_message_t& msg);
#if 0
signals:
void messageSent(const mavlink_message_t& msg);
protected:
MAVLinkSimulationLink* link;
bool idle; ///< indicates if the system is following the waypoints or is waiting
uint16_t current_active_wp_id; ///< id of current waypoint
bool yawReached; ///< boolean for yaw attitude reached
bool posReached; ///< boolean for position reached
uint64_t timestamp_lastoutside_orbit;///< timestamp when the MAV was last outside the orbit or had the wrong yaw value
uint64_t timestamp_firstinside_orbit;///< timestamp when the MAV was the first time after a waypoint change inside the orbit and had the correct yaw value
std::vector<mavlink_mission_item_t*> waypoints1; ///< vector1 that holds the waypoints
std::vector<mavlink_mission_item_t*> waypoints2; ///< vector2 that holds the waypoints
std::vector<mavlink_mission_item_t*>* waypoints; ///< pointer to the currently active waypoint vector
std::vector<mavlink_mission_item_t*>* waypoints_receive_buffer; ///< pointer to the receive buffer waypoint vector
PX_WAYPOINTPLANNER_STATES current_state;
uint16_t protocol_current_wp_id;
uint16_t protocol_current_count;
uint8_t protocol_current_partner_systemid;
uint8_t protocol_current_partner_compid;
uint64_t protocol_timestamp_lastaction;
unsigned int protocol_timeout;
uint64_t timestamp_last_send_setpoint;
uint8_t systemid;
uint8_t compid;
unsigned int setpointDelay;
float yawTolerance;
bool verbose;
bool debug;
bool silent;
void send_waypoint_ack(uint8_t target_systemid, uint8_t target_compid, uint8_t type);
void send_waypoint_current(uint16_t seq);
void send_setpoint(uint16_t seq);
void send_waypoint_count(uint8_t target_systemid, uint8_t target_compid, uint16_t count);
void send_waypoint(uint8_t target_systemid, uint8_t target_compid, uint16_t seq);
void send_waypoint_request(uint8_t target_systemid, uint8_t target_compid, uint16_t seq);
void send_waypoint_reached(uint16_t seq);
float distanceToSegment(uint16_t seq, float x, float y, float z);
float distanceToPoint(uint16_t seq, float x, float y, float z);
float distanceToPoint(uint16_t seq, float x, float y);
void mavlink_handler(const mavlink_message_t* msg);
#endif
/// @return true: message handled
bool handleMessage(const mavlink_message_t& msg);
private:
uint16_t _vehicleSystemId; ///< System id of this vehicle
QList<mavlink_mission_item_t> _missionItems; ///< Current set of mission itemss
void _handleMissionRequestList(const mavlink_message_t& msg);
void _handleMissionRequest(const mavlink_message_t& msg);
void _handleMissionItem(const mavlink_message_t& msg);
void _handleMissionCount(const mavlink_message_t& msg);
void _requestNextMissionItem(int sequenceNumber);
private:
MockLink* _mockLink;
int _writeSequenceCount; ///< Numbers of items about to be written
int _writeSequenceIndex; ///< Current index being reqested
typedef QMap<uint16_t, mavlink_mission_item_t> MissionList_t;
MissionList_t _missionItems;
};
#endif // MAVLINKSIMULATIONWAYPOINTPLANNER_H
#endif
......@@ -223,10 +223,7 @@ bool MultiSignalSpy::waitForSignalByIndex(
Q_ASSERT(spy);
while (spy->count() == 0 && !_timeout) {
QCoreApplication::sendPostedEvents();
QCoreApplication::processEvents();
QCoreApplication::flush();
QTest::qSleep(100);
QTest::qWait(100);
}
// Clean up and return status
......
......@@ -199,14 +199,14 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
MissionItem *lwp_vo = new MissionItem(NULL,
wp->seq,
QGeoCoordinate(wp->x, wp->y, wp->z),
(MAV_CMD) wp->command,
wp->param1,
wp->param2,
wp->param3,
wp->param4,
wp->autocontinue,
wp->current,
(MAV_FRAME) wp->frame,
(MAV_CMD) wp->command);
(MAV_FRAME) wp->frame);
addWaypointViewOnly(lwp_vo);
......@@ -214,14 +214,14 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
MissionItem *lwp_ed = new MissionItem(NULL,
wp->seq,
QGeoCoordinate(wp->x, wp->y, wp->z),
(MAV_CMD) wp->command,
wp->param1,
wp->param2,
wp->param3,
wp->param4,
wp->autocontinue,
wp->current,
(MAV_FRAME) wp->frame,
(MAV_CMD) wp->command);
(MAV_FRAME) wp->frame);
addWaypointEditable(lwp_ed, false);
if (wp->current == 1) currentWaypointEditable = lwp_ed;
}
......@@ -256,14 +256,14 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
MissionItem *lwp_vo = new MissionItem(NULL,
wp->seq,
QGeoCoordinate(wp->x, wp->y, wp->z),
(MAV_CMD) wp->command,
wp->param1,
wp->param2,
wp->param3,
wp->param4,
wp->autocontinue,
wp->current,
(MAV_FRAME) wp->frame,
(MAV_CMD) wp->command);
(MAV_FRAME) wp->frame);
waypointsViewOnly.replace(wp->seq, lwp_vo);
emit waypointViewOnlyListChanged();
......
......@@ -37,6 +37,7 @@
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
#include "MainToolBar.h"
#include "FlightMapSettings.h"
SettingsDialog::SettingsDialog(QWidget *parent, int showTab, Qt::WindowFlags flags) :
QDialog(parent, flags),
......@@ -94,7 +95,18 @@ _ui(new Ui::SettingsDialog)
connect(_ui->styleChooser, SIGNAL(currentIndexChanged(int)), this, SLOT(styleChanged(int)));
connect(_ui->browseSavedFilesLocation, &QPushButton::clicked, this, &SettingsDialog::_selectSavedFilesDirectory);
connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::_validateBeforeClose);
// Flight Map settings
FlightMapSettings* fmSettings = FlightMapSettings::instance();
_ui->bingMapRadio->setChecked(fmSettings->mapProvider() == "Bing");
_ui->googleMapRadio->setChecked(fmSettings->mapProvider() == "Google");
_ui->openMapRadio->setChecked(fmSettings->mapProvider() == "Open");
connect(_ui->bingMapRadio, &QRadioButton::clicked, this, &SettingsDialog::_bingMapRadioClicked);
connect(_ui->googleMapRadio, &QRadioButton::clicked, this, &SettingsDialog::_googleMapRadioClicked);
connect(_ui->openMapRadio, &QRadioButton::clicked, this, &SettingsDialog::_openMapRadioClicked);
switch (showTab) {
case ShowCommLinks:
_ui->tabWidget->setCurrentWidget(pLinkConf);
......@@ -193,3 +205,24 @@ void SettingsDialog::on_showRSSI_clicked(bool checked)
{
_mainWindow->getMainToolBar()->viewStateChanged(TOOL_BAR_SHOW_RSSI, checked);
}
void SettingsDialog::_bingMapRadioClicked(bool checked)
{
if (checked) {
FlightMapSettings::instance()->setMapProvider("Bing");
}
}
void SettingsDialog::_googleMapRadioClicked(bool checked)
{
if (checked) {
FlightMapSettings::instance()->setMapProvider("Google");
}
}
void SettingsDialog::_openMapRadioClicked(bool checked)
{
if (checked) {
FlightMapSettings::instance()->setMapProvider("Open");
}
}
......@@ -62,6 +62,10 @@ private slots:
void on_showMav_clicked(bool checked);
void on_showRSSI_clicked(bool checked);
void _bingMapRadioClicked(bool checked);
void _googleMapRadioClicked(bool checked);
void _openMapRadioClicked(bool checked);
private:
MainWindow* _mainWindow;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>500</width>
<height>596</height>
<height>689</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -115,6 +115,36 @@
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Map Provider</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="bingMapRadio">
<property name="text">
<string>Bing</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="googleMapRadio">
<property name="text">
<string>Google</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="openMapRadio">
<property name="text">
<string>Open Streets</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
......
......@@ -304,9 +304,17 @@ void WaypointList::addEditable(bool onCurrentPosition)
} else {
updateStatusLabel(tr("Added default GLOBAL (Relative alt.) waypoint."));
}
wp = new MissionItem(NULL, 0,
wp = new MissionItem(NULL,
0,
QGeoCoordinate(uas->getLatitude(), uas->getLongitude(), uas->getAltitudeAMSL()),
0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT);
MAV_CMD_NAV_WAYPOINT,
0,
WPM->getAcceptanceRadiusRecommendation(),
0,
0,
true,
true,
(MAV_FRAME)WPM->getFrameRecommendation());
WPM->addWaypointEditable(wp);
} else {
......@@ -316,9 +324,17 @@ void WaypointList::addEditable(bool onCurrentPosition)
} else {
updateStatusLabel(tr("Added default GLOBAL (Relative alt.) waypoint."));
}
wp = new MissionItem(NULL, 0,
wp = new MissionItem(NULL,
0,
QGeoCoordinate(HomePositionManager::instance()->getHomeLatitude(), HomePositionManager::instance()->getHomeLongitude(), WPM->getAltitudeRecommendation()),
0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT);
MAV_CMD_NAV_WAYPOINT,
0,
WPM->getAcceptanceRadiusRecommendation(),
0,
0,
true,
true,
(MAV_FRAME)WPM->getFrameRecommendation());
WPM->addWaypointEditable(wp);
}
}
......@@ -327,15 +343,31 @@ void WaypointList::addEditable(bool onCurrentPosition)
if (onCurrentPosition)
{
updateStatusLabel(tr("Added default LOCAL (NED) waypoint."));
wp = new MissionItem(NULL, 0,
wp = new MissionItem(NULL,
0,
QGeoCoordinate(uas->getLocalX(), uas->getLocalY(), uas->getLocalZ()),
0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, MAV_FRAME_LOCAL_NED, MAV_CMD_NAV_WAYPOINT);
MAV_CMD_NAV_WAYPOINT,
0,
WPM->getAcceptanceRadiusRecommendation(),
0,
0,
true,
true,
MAV_FRAME_LOCAL_NED);
WPM->addWaypointEditable(wp);
} else {
updateStatusLabel(tr("Added default LOCAL (NED) waypoint."));
wp = new MissionItem(0, 0,
wp = new MissionItem(0,
0,
QGeoCoordinate(0, 0, -0.50),
0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, MAV_FRAME_LOCAL_NED, MAV_CMD_NAV_WAYPOINT);
MAV_CMD_NAV_WAYPOINT,
0,
WPM->getAcceptanceRadiusRecommendation(),
0,
0,
true,
true,
MAV_FRAME_LOCAL_NED);
WPM->addWaypointEditable(wp);
}
}
......@@ -343,9 +375,17 @@ void WaypointList::addEditable(bool onCurrentPosition)
{
// MAV connected, but position unknown, add default waypoint
updateStatusLabel(tr("WARNING: No position known. Adding default LOCAL (NED) waypoint"));
wp = new MissionItem(NULL, 0,
wp = new MissionItem(NULL,
0,
QGeoCoordinate(HomePositionManager::instance()->getHomeLatitude(), HomePositionManager::instance()->getHomeLongitude(), WPM->getAltitudeRecommendation()),
0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT);
MAV_CMD_NAV_WAYPOINT,
0,
WPM->getAcceptanceRadiusRecommendation(),
0,
0,
true,
true,
(MAV_FRAME)WPM->getFrameRecommendation());
WPM->addWaypointEditable(wp);
}
}
......@@ -353,9 +393,17 @@ void WaypointList::addEditable(bool onCurrentPosition)
{
//Since no UAV available, create first default waypoint.
updateStatusLabel(tr("No UAV connected. Adding default GLOBAL (NED) waypoint"));
wp = new MissionItem(NULL, 0,
wp = new MissionItem(NULL,
0,
QGeoCoordinate(HomePositionManager::instance()->getHomeLatitude(), HomePositionManager::instance()->getHomeLongitude(), WPM->getAltitudeRecommendation()),
0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT);
MAV_CMD_NAV_WAYPOINT,
0,
WPM->getAcceptanceRadiusRecommendation(),
0,
0,
true,
true,
(MAV_FRAME)WPM->getFrameRecommendation());
WPM->addWaypointEditable(wp);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment