Commit d1eac7fe authored by Valentin Platzgummer's avatar Valentin Platzgummer

wima planer and wima controller edited

parent a0e0f804
......@@ -457,6 +457,7 @@ HEADERS += \
src/Wima/StateMachine.h \
src/Wima/WaypointManager/AreaInterface.h \
src/Wima/WaypointManager/DefaultManager.h \
src/Wima/WaypointManager/EmptyManager.h \
src/Wima/WaypointManager/GenericWaypointManager.h \
src/Wima/WaypointManager/RTLManager.h \
src/Wima/WaypointManager/Settings.h \
......@@ -519,6 +520,7 @@ SOURCES += \
src/Wima/StateMachine.cpp \
src/Wima/WaypointManager/AreaInterface.cpp \
src/Wima/WaypointManager/DefaultManager.cpp \
src/Wima/WaypointManager/EmptyManager.cpp \
src/Wima/WaypointManager/GenericWaypointManager.cpp \
src/Wima/WaypointManager/RTLManager.cpp \
src/Wima/WaypointManager/Settings.cpp \
......
......@@ -232,6 +232,11 @@
<file alias="QGroundControl/Controls/CircularSurveyMapVisual.qml">src/WimaView/CircularSurveyMapVisual.qml</file>
<file alias="QGroundControl/FlightDisplay/SmallValue.qml">src/FlightDisplay/SmallValue.qml</file>
<file alias="QGroundControl/Controls/ProgressIndicator.qml">src/WimaView/ProgressIndicator.qml</file>
<file alias="QGroundControl/Controls/WimaServiceAreaDataVisual.qml">src/WimaView/WimaServiceAreaDataVisual.qml</file>
<file alias="QGroundControl/Controls/WimaCorridorDataVisual.qml">src/WimaView/WimaCorridorDataVisual.qml</file>
<file alias="QGroundControl/Controls/WimaJoinedAreaDataVisual.qml">src/WimaView/WimaJoinedAreaDataVisual.qml</file>
<file alias="QGroundControl/Controls/WimaAreaNoVisual.qml">src/Wima/Snake/WimaAreaNoVisual.qml</file>
<file alias="QGroundControl/Controls/WimaMeasurementAreaDataVisual.qml">src/WimaView/WimaMeasurementAreaDataVisual.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......
......@@ -59,8 +59,6 @@ FlightMap {
property bool _keepVehicleCentered: _mainIsMap ? false : true
property bool _wimaEnabled: wimaController.enableWimaController.value
property bool _showAllWimaItems: wimaController.showAllMissionItems.value
property bool _showCurrentWimaItems: wimaController.showCurrentMissionItems.value
function updateAirspace(reset) {
if(_airspaceEnabled) {
......@@ -200,109 +198,29 @@ FlightMap {
}
// Add wima Areas to the Map
MapItemView {
Repeater {
property bool _enableWima: wimaController.enableWimaController.value
model: _enableWima ? wimaController.visualItems : 0
delegate: MapPolygon{
path: object.path;
border.color: "black"
color: object.type === "WimaJoinedAreaData" ? "gray"
: object.type === "WimaServiceAreaData" ? "yellow"
: object.type === "WimaMeasurementAreaData" ? "green"
: "transparent"
opacity: 0.25
z: 0
delegate: WimaMapVisual{
map: flightMap
qgcView: flightMap.qgcView
visible: true
}
}
// Add mission items generated by wima planer to the map
// Add missionItems generated by wima planer to the map
// all Items
WimaPlanMapItems {
map: flightMap
largeMapView: _mainIsMap
missionItems: wimaController.missionItems
path: wimaController.waypointPath
showItems: _wimaEnabled && _showAllWimaItems
showItems: _wimaEnabled
zOrderWP: QGroundControl.zOrderWimaAllWaypointIndicators
zOrderLines: QGroundControl.zOrderWimaAllWaypointLines
color: "gray"
}
// current Items
WimaPlanMapItems {
map: flightMap
largeMapView: _mainIsMap
missionItems: wimaController.currentMissionItems
path: wimaController.currentWaypointPath
showItems: _wimaEnabled && _showCurrentWimaItems
zOrderWP: QGroundControl.zOrderWimaCurrentWaypointIndicators
zOrderLines: QGroundControl.zOrderWimaCurrentWaypointLines
color: "green"
}
// // Add Snake tile center points to the map
// MapItemView {
// id:progressView
// property bool _enable: wimaController.enableWimaController.value
// && wimaController.enableSnake.value
// property bool valid: wimaController.snakeTileCenterPoints.length
// === wimaController.nemoProgress.length
// model: _enable ? wimaController.snakeTileCenterPoints : 0
// delegate: ProgressIndicator{
// coordinate: modelData
// currentValue: getProgress()
// z: 1
// function getProgress() {
// var progress = 0
// if (progressView.valid){
// progress = wimaController.nemoProgress[index]
// }
// if (progress < 0)
// progress = 0
// if (progress > 100)
// progress = 100
// return progress
// }
// }
// }
// Add Snake tiles to the map
MapItemView {
id: tileView
property bool _enable: wimaController.enableWimaController.value
property bool valid: wimaController.snakeTileCenterPoints.length
=== wimaController.nemoProgress.length
model: _enable ? wimaController.snakeTiles : 0
delegate: MapPolygon{
path: object.path;
border.color: "black"
border.width: 1
color: getColor()
opacity: 0.6
z: 2
function getColor() {
var progress = 0
if (tileView.valid){
progress = wimaController.nemoProgress[index]
}
if (progress < 25)
return "transparent"
if (progress < 50)
return "orange"
if (progress < 75)
return "yellow"
if (progress < 100)
return "greenyellow"
return "limegreen"
}
}
}
// Add trajectory points to the map
MapItemView {
model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0
......
......@@ -171,11 +171,11 @@ Item {
id: mainColumn
spacing: ScreenTools.defaultFontPixelHeight * 0.3
SectionHeader{
id: vehicleHeader
text: qsTr("Vehicle")
}
GridLayout {
columns: 2
rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5
......@@ -183,6 +183,17 @@ Item {
visible: vehicleHeader.checked
width: parent.width
QGCButton {
id: buttonUpload
text: qsTr("Upload")
onClicked: {
if (!planMasterController.offline) {
wimaController.upload()
}
}
Layout.fillWidth: true
}
QGCButton {
id: buttonRemoveFromVehicle
text: qsTr("Remove")
......@@ -194,6 +205,7 @@ Item {
id: buttonSmartRTL
text: qsTr("Smart RTL")
onClicked: wimaController.requestSmartRTL();
Layout.columnSpan: 2
Layout.fillWidth: true
}
......@@ -204,7 +216,32 @@ Item {
Layout.columnSpan: 2
Layout.fillWidth: true
}
}
GridLayout {
columns: 2
rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5
columnSpacing: ScreenTools.defaultFontPixelHeight * 0.5
visible: vehicleHeader.checked
width: parent.width
QGCLabel {
text: qsTr("Speed")
Layout.fillWidth: true
}
FactTextField {
fact: wimaController.flightSpeed
Layout.fillWidth: true
}
QGCLabel {
text: qsTr("Altitude")
Layout.fillWidth: true
}
FactTextField {
fact: wimaController.altitude
Layout.fillWidth: true
}
// progess bar
Rectangle {
......@@ -223,7 +260,7 @@ Item {
Layout.columnSpan: 2
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: "Upload Complete"
text: "Done"
visible: false
Layout.fillWidth: true
}
......@@ -233,7 +270,6 @@ Item {
id: statsHeader
text: qsTr("Statistics")
}
GridLayout {
columns: 3
rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5
......
......@@ -13,6 +13,7 @@ class WimaAreaData
public:
Q_PROPERTY(const QVariantList path READ path NOTIFY pathChanged)
Q_PROPERTY(QString type READ type CONSTANT)
Q_PROPERTY(QString mapVisualQML READ mapVisualQML CONSTANT)
WimaAreaData(QObject *parent = nullptr);
~WimaAreaData();
......@@ -23,6 +24,8 @@ public:
bool operator==(const WimaAreaData &data) const;
bool operator!=(const WimaAreaData &data) const;
virtual QString mapVisualQML(void) const = 0;
QVariantList path() const;
QGeoCoordinate center() const;
const QList<QGeoCoordinate> &coordinateList() const;
......
......@@ -2,22 +2,17 @@
const char *WimaCorridorData::typeString = "WimaCorridorData";
WimaCorridorData::WimaCorridorData(QObject *parent)
:WimaAreaData (parent)
{
WimaCorridorData::WimaCorridorData(QObject *parent) : WimaAreaData(parent) {}
}
WimaCorridorData::WimaCorridorData(const WimaCorridorData &other, QObject *parent)
: WimaAreaData (parent)
{
*this = other;
WimaCorridorData::WimaCorridorData(const WimaCorridorData &other,
QObject *parent)
: WimaAreaData(parent) {
*this = other;
}
WimaCorridorData::WimaCorridorData(const WimaCorridor &other, QObject *parent)
: WimaAreaData (parent)
{
*this = other;
: WimaAreaData(parent) {
*this = other;
}
/*!
......@@ -25,11 +20,10 @@ WimaCorridorData::WimaCorridorData(const WimaCorridor &other, QObject *parent)
*
* Assigns \a other to the invoking object.
*/
WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other)
{
this->assign(other);
WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other) {
this->assign(other);
return *this;
return *this;
}
/*!
......@@ -37,36 +31,34 @@ WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other)
*
* Assigns \a other to the invoking object.
*/
WimaCorridorData &WimaCorridorData::operator=(const WimaCorridor &other)
{
this->assign(other);
WimaCorridorData &WimaCorridorData::operator=(const WimaCorridor &other) {
this->assign(other);
return *this;
return *this;
}
QString WimaCorridorData::type() const
{
return this->typeString;
QString WimaCorridorData::mapVisualQML() const {
return QStringLiteral("WimaAreaDataVisual.qml");
}
void WimaCorridorData::assign(const WimaCorridorData &corridorData)
{
WimaAreaData::assign(corridorData);
}
QString WimaCorridorData::type() const { return this->typeString; }
void WimaCorridorData::assign(const WimaCorridor &corridor)
{
WimaAreaData::assign(corridor);
void WimaCorridorData::assign(const WimaCorridorData &corridorData) {
WimaAreaData::assign(corridorData);
}
void WimaCorridorData::assign(const WimaCorridor &corridor) {
WimaAreaData::assign(corridor);
}
/*!
* \class WimaAreaData::WimaCorridorData
* \brief Class to store and exchange data of a \c WimaCorridorData Object.
* Class to store and exchange data of a \c WimaCorridor Object. In contrast to \c WimaCorridor this class
* does not provied any interface to a grafical user interface, neiter it uses the QGC Fact System.
* It is designed to exchange data between the \c WimaPlaner and the \c WimaController class. And it
* is the derived from WimaAreaData.
* Class to store and exchange data of a \c WimaCorridor Object. In contrast to
* \c WimaCorridor this class does not provied any interface to a grafical user
* interface, neiter it uses the QGC Fact System. It is designed to exchange
* data between the \c WimaPlaner and the \c WimaController class. And it is the
* derived from WimaAreaData.
*
* \sa WimaCorridor, WimaAreaData
*/
......@@ -7,31 +7,30 @@
#include "QGeoCoordinate"
class WimaCorridorData : public WimaAreaData
{
Q_OBJECT
class WimaCorridorData : public WimaAreaData {
Q_OBJECT
public:
WimaCorridorData(QObject *parent = nullptr);
WimaCorridorData(const WimaCorridorData &other, QObject *parent = nullptr);
WimaCorridorData(const WimaCorridor &other, QObject *parent = nullptr);
WimaCorridorData &operator=(const WimaCorridorData &other);
WimaCorridorData &operator=(const WimaCorridor &other);
WimaCorridorData(QObject *parent = nullptr);
WimaCorridorData(const WimaCorridorData &other, QObject *parent = nullptr);
WimaCorridorData(const WimaCorridor &other, QObject *parent = nullptr);
WimaCorridorData &operator=(const WimaCorridorData &other);
WimaCorridorData &operator=(const WimaCorridor &other);
QString type() const;
WimaCorridorData *Clone() const {return new WimaCorridorData(*this);}
virtual QString mapVisualQML() const override;
static const char* typeString;
QString type() const;
WimaCorridorData *Clone() const { return new WimaCorridorData(*this); }
static const char *typeString;
signals:
public slots:
protected:
void assign(const WimaCorridorData &corridorData);
void assign(const WimaCorridor &corridor);
void assign(const WimaCorridorData &corridorData);
void assign(const WimaCorridor &corridor);
private:
};
......@@ -39,6 +39,10 @@ WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedArea &other) {
return *this;
}
QString WimaJoinedAreaData::mapVisualQML() const {
return QStringLiteral("WimaJoinedAreaDataVisual.qml");
}
QString WimaJoinedAreaData::type() const { return this->typeString; }
void WimaJoinedAreaData::assign(const WimaJoinedAreaData &other) {
......
......@@ -7,26 +7,27 @@
#include "QGeoCoordinate"
class WimaJoinedAreaData : public WimaAreaData
{
Q_OBJECT
class WimaJoinedAreaData : public WimaAreaData {
Q_OBJECT
public:
WimaJoinedAreaData(QObject *parent = nullptr);
WimaJoinedAreaData(const WimaJoinedAreaData &other, QObject *parent = nullptr);
WimaJoinedAreaData(const WimaJoinedArea &other, QObject *parent = nullptr);
WimaJoinedAreaData &operator=(const WimaJoinedAreaData &other);
WimaJoinedAreaData &operator=(const WimaJoinedArea &other);
WimaJoinedAreaData(QObject *parent = nullptr);
WimaJoinedAreaData(const WimaJoinedAreaData &other,
QObject *parent = nullptr);
WimaJoinedAreaData(const WimaJoinedArea &other, QObject *parent = nullptr);
WimaJoinedAreaData &operator=(const WimaJoinedAreaData &other);
WimaJoinedAreaData &operator=(const WimaJoinedArea &other);
QString type() const;
WimaJoinedAreaData *Clone() const {return new WimaJoinedAreaData(*this);}
virtual QString mapVisualQML() const override;
static const char* typeString;
QString type() const;
WimaJoinedAreaData *Clone() const { return new WimaJoinedAreaData(*this); }
static const char *typeString;
protected:
void assign(const WimaJoinedAreaData &other);
void assign(const WimaJoinedArea &other);
void assign(const WimaJoinedAreaData &other);
void assign(const WimaJoinedArea &other);
private:
};
......@@ -30,6 +30,20 @@ operator!=(const WimaMeasurementAreaData &other) const {
return !(*this == other);
}
void WimaMeasurementAreaData::setTileData(const TileData &d) {
if (this->_tileData != d) {
this->_tileData = d;
emit tileDataChanged();
}
}
void WimaMeasurementAreaData::setProgress(const QVector<int> &d) {
if (this->_progress != d) {
this->_progress = d;
emit progressChanged();
}
}
/*!
* \overload operator=();
*
......@@ -54,6 +68,10 @@ operator=(const WimaMeasurementArea &other) {
return *this;
}
QString WimaMeasurementAreaData::mapVisualQML() const {
return QStringLiteral("WimaMeasurementAreaDataVisual.qml");
}
QString WimaMeasurementAreaData::type() const { return this->typeString; }
QmlObjectListModel *WimaMeasurementAreaData::tiles() {
......@@ -86,15 +104,15 @@ QVector<int> &WimaMeasurementAreaData::progress() { return this->_progress; }
void WimaMeasurementAreaData::assign(const WimaMeasurementAreaData &other) {
WimaAreaData::assign(other);
this->_tileData = other._tileData;
this->_progress = other._progress;
setTileData(other._tileData);
setProgress(other._progress);
}
void WimaMeasurementAreaData::assign(const WimaMeasurementArea &other) {
WimaAreaData::assign(other);
if (other.ready()) {
this->_tileData = other.tileData();
this->_progress = other.progress();
setTileData(other.tileData());
setProgress(other.progress());
} else {
qWarning()
<< "WimaMeasurementAreaData::assign(): WimaMeasurementArea not ready.";
......
......@@ -18,14 +18,23 @@ public:
WimaMeasurementAreaData &operator=(const WimaMeasurementAreaData &other);
WimaMeasurementAreaData &operator=(const WimaMeasurementArea &other);
Q_PROPERTY(QmlObjectListModel *tiles READ tiles NOTIFY tileDataChanged)
Q_PROPERTY(QVector<int> progress READ progress NOTIFY progressChanged)
virtual QString mapVisualQML() const override;
bool operator==(const WimaMeasurementAreaData &other) const;
bool operator!=(const WimaMeasurementAreaData &other) const;
// Property setters.
void setTileData(const TileData &d);
void setProgress(const QVector<int> &d);
// Property getters.
QString type() const;
WimaMeasurementAreaData *Clone() const {
return new WimaMeasurementAreaData(*this);
}
QmlObjectListModel *tiles();
const QmlObjectListModel *tiles() const;
const QVariantList &tileCenterPoints() const;
......@@ -37,6 +46,10 @@ public:
static const char *typeString;
signals:
void tileDataChanged();
void progressChanged();
protected:
void assign(const WimaMeasurementAreaData &other);
void assign(const WimaMeasurementArea &other);
......
......@@ -31,6 +31,10 @@ operator=(const WimaServiceArea &otherArea) {
return *this;
}
QString WimaServiceAreaData::mapVisualQML() const {
return QStringLiteral("WimaServiceAreaDataVisual.qml");
}
/*!
* \fn const QGeoCoordinate &WimaServiceAreaData::takeOffPosition() const
* Returns a constant reference to the takeOffPosition.
......
......@@ -17,6 +17,8 @@ public:
WimaServiceAreaData &operator=(const WimaServiceAreaData &otherData);
WimaServiceAreaData &operator=(const WimaServiceArea &otherArea);
virtual QString mapVisualQML() const override;
const QGeoCoordinate &depot() const;
QString type() const;
......
......@@ -9,6 +9,10 @@ SnakeTile::SnakeTile(const SnakeTile &other, QObject *parent)
SnakeTile::~SnakeTile() {}
QString SnakeTile::mapVisualQML() const {
return QStringLiteral("WimaAreaNoVisual.qml");
}
QString SnakeTile::type() const { return "Tile"; }
SnakeTile *SnakeTile::Clone() const { return new SnakeTile(*this); }
......
......@@ -9,6 +9,8 @@ public:
SnakeTile(const SnakeTile &other, QObject *parent = nullptr);
~SnakeTile();
virtual QString mapVisualQML() const override;
QString type() const override;
SnakeTile *Clone() const;
......
import QtQuick 2.3
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
Component.onCompleted: {
console.log("WimaAreaNoVisual.qml is a place holder and not meant to be instanciated.")
}
}
......@@ -253,7 +253,7 @@ void StateMachine::setState(STATE s) {
emit upToDateChanged();
}
if (surveyReady(oldState) != surveyReady(s)) {
emit surveyReady();
emit surveyReadyChanged();
}
qCDebug(WimaPlanerLog) << "StateMachine::setState():" << oldState << "->"
<< s;
......
#include "EmptyManager.h"
namespace WaypointManager {
WaypointManager::EmptyManager::EmptyManager(Settings &settings, AreaInterface &)
: ManagerBase(settings) {}
void WaypointManager::EmptyManager::clear() {}
bool WaypointManager::EmptyManager::update() {}
bool WaypointManager::EmptyManager::next() {}
bool WaypointManager::EmptyManager::previous() {}
bool WaypointManager::EmptyManager::reset() {}
} // namespace WaypointManager
#pragma once
#include <QGeoCoordinate>
#include <QVector>
#include "AreaInterface.h"
#include "GenericWaypointManager.h"
#include "QmlObjectListModel.h"
#include "Settings.h"
namespace WaypointManager {
typedef GenericWaypointManager<QGeoCoordinate, QVector, QmlObjectListModel,
Settings>
ManagerBase;
//!
//! \brief The EmptyManager is a place holder and does noting.
class EmptyManager : public ManagerBase {
public:
EmptyManager() = delete;
EmptyManager(Settings &settings, AreaInterface &);
void clear() override;
virtual bool update() override;
virtual bool next() override;
virtual bool previous() override;
virtual bool reset() override;
};
} // namespace WaypointManager
This diff is collapsed.
......@@ -18,7 +18,7 @@
#include "RoutingThread.h"
#include "Snake/NemoInterface.h"
#include "WaypointManager/DefaultManager.h"
#include "WaypointManager/EmptyManager.h"
#include "WaypointManager/RTLManager.h"
#include "utilities.h"
......@@ -42,42 +42,13 @@ public:
visualItemsChanged)
Q_PROPERTY(QmlObjectListModel *missionItems READ missionItems NOTIFY
missionItemsChanged)
Q_PROPERTY(QmlObjectListModel *currentMissionItems READ currentMissionItems
NOTIFY currentMissionItemsChanged)
Q_PROPERTY(
QVariantList waypointPath READ waypointPath NOTIFY waypointPathChanged)
Q_PROPERTY(QVariantList currentWaypointPath READ currentWaypointPath NOTIFY
currentWaypointPathChanged)
Q_PROPERTY(Fact *enableWimaController READ enableWimaController CONSTANT)
// Waypoint navigaton.
Q_PROPERTY(Fact *overlapWaypoints READ overlapWaypoints CONSTANT)
Q_PROPERTY(Fact *maxWaypointsPerPhase READ maxWaypointsPerPhase CONSTANT)
Q_PROPERTY(Fact *startWaypointIndex READ startWaypointIndex CONSTANT)
Q_PROPERTY(Fact *showAllMissionItems READ showAllMissionItems CONSTANT)
Q_PROPERTY(
Fact *showCurrentMissionItems READ showCurrentMissionItems CONSTANT)
// Waypoint settings.
Q_PROPERTY(Fact *flightSpeed READ flightSpeed CONSTANT)
Q_PROPERTY(Fact *altitude READ altitude CONSTANT)
Q_PROPERTY(Fact *arrivalReturnSpeed READ arrivalReturnSpeed CONSTANT)
// Waypoint statistics.
Q_PROPERTY(
double phaseDistance READ phaseDistance NOTIFY phaseDistanceChanged)
Q_PROPERTY(
double phaseDuration READ phaseDuration NOTIFY phaseDurationChanged)
// Snake
Q_PROPERTY(int nemoStatus READ nemoStatus NOTIFY nemoStatusChanged)
Q_PROPERTY(QString nemoStatusString READ nemoStatusString NOTIFY
nemoStatusStringChanged)
Q_PROPERTY(
QmlObjectListModel *snakeTiles READ snakeTiles NOTIFY snakeTilesChanged)
Q_PROPERTY(QVariantList snakeTileCenterPoints READ snakeTileCenterPoints
NOTIFY snakeTilesChanged)
Q_PROPERTY(
QVector<int> nemoProgress READ nemoProgress NOTIFY nemoProgressChanged)
// Property accessors
// Controllers.
PlanMasterController *masterController(void);
MissionController *missionController(void);
......@@ -86,31 +57,14 @@ public: