Commit af4b4687 authored by Valentin Platzgummer's avatar Valentin Platzgummer

wima planer issues solve, progress indicator added

parent dfceedc3
...@@ -63,8 +63,8 @@ execute_process( ...@@ -63,8 +63,8 @@ execute_process(
) )
add_definitions( add_definitions(
-DQGC_APPLICATION_NAME="QGroundControl" -DQGC_APPLICATION_NAME="QGCWima"
-DQGC_ORG_NAME="QGroundControl.org" -DQGC_ORG_NAME="QGCWima.org"
-DQGC_ORG_DOMAIN="org.qgroundcontrol" -DQGC_ORG_DOMAIN="org.qgroundcontrol"
) )
......
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
<qresource prefix="/qml"> <qresource prefix="/qml">
<file alias="QGroundControl/Controls/HackFileDialog.qml">src/QmlControls/HackFileDialog.qml</file> <file alias="QGroundControl/Controls/HackFileDialog.qml">src/QmlControls/HackFileDialog.qml</file>
</qresource> </qresource>
<qresource prefix="/"/>
</RCC> </RCC>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -29,6 +29,7 @@ DebugBuild { ...@@ -29,6 +29,7 @@ DebugBuild {
DESTDIR = $${OUT_PWD}/debug DESTDIR = $${OUT_PWD}/debug
DEFINES += DEBUG DEFINES += DEBUG
DEFINES += SNAKE_SHOW_TIME DEFINES += SNAKE_SHOW_TIME
DEFINES += DEBUG_SRTL
#DEFINES += SNAKE_DEBUG #DEFINES += SNAKE_DEBUG
DEFINES += SHOW_CIRCULAR_SURVEY_TIME DEFINES += SHOW_CIRCULAR_SURVEY_TIME
DEFINES += DEBUG_CIRCULAR_SURVEY DEFINES += DEBUG_CIRCULAR_SURVEY
...@@ -37,7 +38,9 @@ DebugBuild { ...@@ -37,7 +38,9 @@ DebugBuild {
else { else {
DESTDIR = $${OUT_PWD}/release DESTDIR = $${OUT_PWD}/release
#DEFINES += ROS_BRIDGE_DEBUG #DEFINES += ROS_BRIDGE_DEBUG
DEFINES += SNAKE_SHOW_TIME #DEFINES += SHOW_CIRCULAR_SURVEY_TIME
#DEFINES += SNAKE_SHOW_TIME
DEFINES += DEBUG_SRTL
DEFINES += NDEBUG DEFINES += NDEBUG
} }
...@@ -66,9 +69,9 @@ WindowsBuild { ...@@ -66,9 +69,9 @@ WindowsBuild {
# Branding # Branding
# #
QGC_APP_NAME = "QGroundControl" QGC_APP_NAME = "QGCWima"
QGC_ORG_NAME = "QGroundControl.org" QGC_ORG_NAME = "QGCWima.org"
QGC_ORG_DOMAIN = "org.qgroundcontrol" QGC_ORG_DOMAIN = "org.qgcwima"
QGC_APP_DESCRIPTION = "Open source ground control app provided by QGroundControl dev team" QGC_APP_DESCRIPTION = "Open source ground control app provided by QGroundControl dev team"
QGC_APP_COPYRIGHT = "Copyright (C) 2017 QGroundControl Development Team. All rights reserved." QGC_APP_COPYRIGHT = "Copyright (C) 2017 QGroundControl Development Team. All rights reserved."
...@@ -317,9 +320,9 @@ CustomBuild { ...@@ -317,9 +320,9 @@ CustomBuild {
RESOURCES += $$PWD/qgcresources.qrc RESOURCES += $$PWD/qgcresources.qrc
} }
} else { } else {
DEFINES += QGC_APPLICATION_NAME=\"\\\"QGroundControl\\\"\" DEFINES += QGC_APPLICATION_NAME=\"\\\"QGCWima\\\"\"
DEFINES += QGC_ORG_NAME=\"\\\"QGroundControl.org\\\"\" DEFINES += QGC_ORG_NAME=\"\\\"QGCWima.org\\\"\"
DEFINES += QGC_ORG_DOMAIN=\"\\\"org.qgroundcontrol\\\"\" DEFINES += QGC_ORG_DOMAIN=\"\\\"org.qgcwima\\\"\"
RESOURCES += \ RESOURCES += \
$$PWD/qgroundcontrol.qrc \ $$PWD/qgroundcontrol.qrc \
$$PWD/qgcresources.qrc $$PWD/qgcresources.qrc
...@@ -413,9 +416,9 @@ FORMS += \ ...@@ -413,9 +416,9 @@ FORMS += \
# #
HEADERS += \ HEADERS += \
src/Wima/CSWorker.h \
src/Wima/CircularSurvey.h \ src/Wima/CircularSurvey.h \
src/Wima/Geometry/GenericCircle.h \ src/Wima/Geometry/GenericCircle.h \
src/Wima/RoutingThread.h \
src/Wima/Snake/clipper/clipper.hpp \ src/Wima/Snake/clipper/clipper.hpp \
src/Wima/Snake/mapbox/feature.hpp \ src/Wima/Snake/mapbox/feature.hpp \
src/Wima/Snake/mapbox/geometry.hpp \ src/Wima/Snake/mapbox/geometry.hpp \
...@@ -503,8 +506,8 @@ HEADERS += \ ...@@ -503,8 +506,8 @@ HEADERS += \
src/comm/ros_bridge/include/topic_subscriber.h \ src/comm/ros_bridge/include/topic_subscriber.h \
src/comm/utilities.h src/comm/utilities.h
SOURCES += \ SOURCES += \
src/Wima/CSWorker.cpp \
src/Wima/CircularSurvey.cc \ src/Wima/CircularSurvey.cc \
src/Wima/RoutingThread.cpp \
src/Wima/Snake/clipper/clipper.cpp \ src/Wima/Snake/clipper/clipper.cpp \
src/Wima/Snake/snake.cpp \ src/Wima/Snake/snake.cpp \
src/Wima/Geometry/GeoPoint3D.cpp \ src/Wima/Geometry/GeoPoint3D.cpp \
......
...@@ -231,6 +231,7 @@ ...@@ -231,6 +231,7 @@
<file alias="QGroundControl/FlightDisplay/FlightDisplayWimaMenu.qml">src/FlightDisplay/FlightDisplayWimaMenu.qml</file> <file alias="QGroundControl/FlightDisplay/FlightDisplayWimaMenu.qml">src/FlightDisplay/FlightDisplayWimaMenu.qml</file>
<file alias="QGroundControl/Controls/CircularSurveyMapVisual.qml">src/WimaView/CircularSurveyMapVisual.qml</file> <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/FlightDisplay/SmallValue.qml">src/FlightDisplay/SmallValue.qml</file>
<file alias="QGroundControl/Controls/ProgressIndicator.qml">src/WimaView/ProgressIndicator.qml</file>
</qresource> </qresource>
<qresource prefix="/json"> <qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file> <file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......
...@@ -247,22 +247,20 @@ FlightMap { ...@@ -247,22 +247,20 @@ FlightMap {
&& wimaController.enableSnake.value && wimaController.enableSnake.value
model: _enable ? wimaController.snakeTileCenterPoints : 0 model: _enable ? wimaController.snakeTileCenterPoints : 0
delegate: MapCircle{ delegate: ProgressIndicator{
center: modelData coordinate: modelData
border.color: "transparent" currentValue: getProgress()
border.width: 1 width: 10
color: getColor(wimaController.nemoProgress[index]) height: 10
radius: 0.6
opacity: 1
z: 1 z: 1
function getColor(progress) { function getProgress() {
if (progress < 50) var progress = wimaController.nemoProgress[index]
return "red" if (progress < 0)
if (progress < 100) progress = 0
return "orange" if (progress > 100)
progress = 100
return "green" return progress
} }
} }
} }
......
...@@ -100,5 +100,6 @@ CircularSurveyMapVisual 1.0 CircularSurveyMapVisual.qml ...@@ -100,5 +100,6 @@ CircularSurveyMapVisual 1.0 CircularSurveyMapVisual.qml
DragCoordinate 1.0 DragCoordinate.qml DragCoordinate 1.0 DragCoordinate.qml
CoordinateIndicator 1.0 CoordinateIndicator.qml CoordinateIndicator 1.0 CoordinateIndicator.qml
CoordinateIndicatorDrag 1.0 CoordinateIndicatorDrag.qml CoordinateIndicatorDrag 1.0 CoordinateIndicatorDrag.qml
ProgressIndicator 1.0 ProgressIndicator.qml
...@@ -7,85 +7,90 @@ ...@@ -7,85 +7,90 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef QmlObjectListModel_H #ifndef QmlObjectListModel_H
#define QmlObjectListModel_H #define QmlObjectListModel_H
#include <QAbstractListModel> #include <QAbstractListModel>
class QmlObjectListModel : public QAbstractListModel class QmlObjectListModel : public QAbstractListModel {
{ Q_OBJECT
Q_OBJECT
public: public:
QmlObjectListModel(QObject* parent = NULL); QmlObjectListModel(QObject *parent = NULL);
~QmlObjectListModel(); ~QmlObjectListModel();
Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(int count READ count NOTIFY countChanged)
/// Returns true if any of the items in the list are dirty. Requires each object to have /// Returns true if any of the items in the list are dirty. Requires each
/// a dirty property and dirtyChanged signal. /// object to have a dirty property and dirtyChanged signal.
Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged) Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged)
Q_INVOKABLE QObject* get(int index) { return _objectList[index]; } Q_INVOKABLE QObject *get(int index) { return _objectList[index]; }
Q_INVOKABLE const QObject *get(int index) const { return _objectList[index]; }
// Property accessors
// Property accessors
int count () const;
bool dirty () const { return _dirty; } int count() const;
void setDirty (bool dirty); bool dirty() const { return _dirty; }
void append (QObject* object); void setDirty(bool dirty);
void append (QList<QObject*> objects); void append(QObject *object);
QObjectList swapObjectList (const QObjectList& newlist); void append(QList<QObject *> objects);
void clear (); QObjectList swapObjectList(const QObjectList &newlist);
QObject* removeAt (int i); void clear();
QObject* removeOne (QObject* object) { return removeAt(indexOf(object)); } QObject *removeAt(int i);
void insert (int i, QObject* object); QObject *removeOne(QObject *object) { return removeAt(indexOf(object)); }
void insert (int i, QList<QObject*> objects); void insert(int i, QObject *object);
bool contains (QObject* object) { return _objectList.indexOf(object) != -1; } void insert(int i, QList<QObject *> objects);
int indexOf (QObject* object) { return _objectList.indexOf(object); } bool contains(QObject *object) { return _objectList.indexOf(object) != -1; }
int indexOf(QObject *object) { return _objectList.indexOf(object); }
QObject* operator[] (int i);
const QObject* operator[] (int i) const; QObject *operator[](int i);
template<class T> T value (int index) const { return qobject_cast<T>(_objectList[index]); } const QObject *operator[](int i) const;
QList<QObject*>* objectList () { return &_objectList; } template <class T> T value(int index) const {
return qobject_cast<T>(_objectList[index]);
/// Calls deleteLater on all items and this itself. }
void deleteListAndContents (); QList<QObject *> *objectList() { return &_objectList; }
/// Clears the list and calls deleteLater on each entry /// Calls deleteLater on all items and this itself.
void clearAndDeleteContents (); void deleteListAndContents();
void beginReset () { beginResetModel(); } /// Clears the list and calls deleteLater on each entry
void endReset () { endResetModel(); } void clearAndDeleteContents();
// Friends void beginReset() { beginResetModel(); }
friend void swap(QmlObjectListModel& list1, QmlObjectListModel& list2); void endReset() { endResetModel(); }
// Friends
friend void swap(QmlObjectListModel &list1, QmlObjectListModel &list2);
signals: signals:
void countChanged (int count); void countChanged(int count);
void dirtyChanged (bool dirtyChanged); void dirtyChanged(bool dirtyChanged);
private slots: private slots:
void _childDirtyChanged (bool dirty); void _childDirtyChanged(bool dirty);
private: private:
// Overrides from QAbstractListModel // Overrides from QAbstractListModel
int rowCount (const QModelIndex & parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index,
bool insertRows (int position, int rows, const QModelIndex &index = QModelIndex()) override; int role = Qt::DisplayRole) const override;
bool removeRows (int position, int rows, const QModelIndex &index = QModelIndex()) override; bool insertRows(int position, int rows,
bool setData (const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; const QModelIndex &index = QModelIndex()) override;
QHash<int, QByteArray> roleNames(void) const override; bool removeRows(int position, int rows,
const QModelIndex &index = QModelIndex()) override;
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole) override;
QHash<int, QByteArray> roleNames(void) const override;
private: private:
QList<QObject*> _objectList; QList<QObject *> _objectList;
bool _dirty; bool _dirty;
bool _skipDirtyFirstItem; bool _skipDirtyFirstItem;
static const int ObjectRole; static const int ObjectRole;
static const int TextRole; static const int TextRole;
}; };
#endif #endif
#include "CircularSurvey.h" #include "CircularSurvey.h"
#include "CSWorker.h" #include "RoutingThread.h"
// QGC // QGC
#include "JsonHelper.h" #include "JsonHelper.h"
#include "QGCApplication.h" #include "QGCApplication.h"
...@@ -60,7 +60,7 @@ CircularSurvey::CircularSurvey(Vehicle *vehicle, bool flyView, ...@@ -60,7 +60,7 @@ CircularSurvey::CircularSurvey(Vehicle *vehicle, bool flyView,
_alpha(settingsGroup, _metaDataMap[alphaName]), _alpha(settingsGroup, _metaDataMap[alphaName]),
_minLength(settingsGroup, _metaDataMap[minLengthName]), _minLength(settingsGroup, _metaDataMap[minLengthName]),
_type(settingsGroup, _metaDataMap[typeName]), _type(settingsGroup, _metaDataMap[typeName]),
_pWorker(std::make_unique<RoutingWorker>()), _needsStoring(false), _pWorker(std::make_unique<RoutingThread>()), _needsStoring(false),
_needsReversal(false), _hidePolygon(false) { _needsReversal(false), _hidePolygon(false) {
Q_UNUSED(kmlOrShpFile) Q_UNUSED(kmlOrShpFile)
_editorQml = "qrc:/qml/CircularSurveyItemEditor.qml"; _editorQml = "qrc:/qml/CircularSurveyItemEditor.qml";
...@@ -81,9 +81,9 @@ CircularSurvey::CircularSurvey(Vehicle *vehicle, bool flyView, ...@@ -81,9 +81,9 @@ CircularSurvey::CircularSurvey(Vehicle *vehicle, bool flyView,
connect(&this->_type, &Fact::rawValueChanged, this, connect(&this->_type, &Fact::rawValueChanged, this,
&CircularSurvey::_rebuildTransects); &CircularSurvey::_rebuildTransects);
// Connect worker. // Connect worker.
connect(this->_pWorker.get(), &RoutingWorker::result, this, connect(this->_pWorker.get(), &RoutingThread::result, this,
&CircularSurvey::_setTransects); &CircularSurvey::_setTransects);
connect(this->_pWorker.get(), &RoutingWorker::calculatingChanged, this, connect(this->_pWorker.get(), &RoutingThread::calculatingChanged, this,
&CircularSurvey::calculatingChanged); &CircularSurvey::calculatingChanged);
this->_transectsDirty = false; this->_transectsDirty = false;
} }
...@@ -287,7 +287,7 @@ void CircularSurvey::_appendLoadedMissionItems(QList<MissionItem *> &items, ...@@ -287,7 +287,7 @@ void CircularSurvey::_appendLoadedMissionItems(QList<MissionItem *> &items,
void CircularSurvey::_buildAndAppendMissionItems(QList<MissionItem *> &items, void CircularSurvey::_buildAndAppendMissionItems(QList<MissionItem *> &items,
QObject *missionItemParent) { QObject *missionItemParent) {
if (_transectsDirty) if (_transectsDirty || _transects.count() == 0)
return; return;
MissionItem *item; MissionItem *item;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "SettingsFact.h" #include "SettingsFact.h"
#include "TransectStyleComplexItem.h" #include "TransectStyleComplexItem.h"
class RoutingWorker; class RoutingThread;
class RoutingData; class RoutingData;
class CircularSurvey : public TransectStyleComplexItem { class CircularSurvey : public TransectStyleComplexItem {
...@@ -119,7 +119,7 @@ private: ...@@ -119,7 +119,7 @@ private:
SettingsFact _type; SettingsFact _type;
// Worker // Worker
using PtrWorker = std::shared_ptr<RoutingWorker>; using PtrWorker = std::shared_ptr<RoutingThread>;
PtrWorker _pWorker; PtrWorker _pWorker;
PtrRoutingData _workerOutput; PtrRoutingData _workerOutput;
QList<QList<QGeoCoordinate>> _rawTransects; QList<QList<QGeoCoordinate>> _rawTransects;
......
#include "CSWorker.h" #include "RoutingThread.h"
// std // std
#include <chrono> #include <chrono>
// Qt // Qt
#include <QDebug> #include <QDebug>
RoutingWorker::RoutingWorker(QObject *parent) RoutingThread::RoutingThread(QObject *parent)
: QThread(parent), _calculating(false), _stop(false), _restart(false) { : QThread(parent), _calculating(false), _stop(false), _restart(false) {
static std::once_flag flag; static std::once_flag flag;
...@@ -12,7 +12,7 @@ RoutingWorker::RoutingWorker(QObject *parent) ...@@ -12,7 +12,7 @@ RoutingWorker::RoutingWorker(QObject *parent)
[] { qRegisterMetaType<PtrRoutingData>("PtrRoutingData"); }); [] { qRegisterMetaType<PtrRoutingData>("PtrRoutingData"); });
} }
RoutingWorker::~RoutingWorker() { RoutingThread::~RoutingThread() {
this->_stop = true; this->_stop = true;
Lock lk(this->_mutex); Lock lk(this->_mutex);
this->_restart = true; this->_restart = true;
...@@ -21,10 +21,10 @@ RoutingWorker::~RoutingWorker() { ...@@ -21,10 +21,10 @@ RoutingWorker::~RoutingWorker() {
this->wait(); this->wait();
} }
bool RoutingWorker::calculating() { return this->_calculating; } bool RoutingThread::calculating() { return this->_calculating; }
void RoutingWorker::route(const snake::BoostPolygon &safeArea, void RoutingThread::route(const snake::BoostPolygon &safeArea,
const RoutingWorker::Generator &generator) { const RoutingThread::Generator &generator) {
// Sample input. // Sample input.
Lock lk(this->_mutex); Lock lk(this->_mutex);
this->_safeArea = safeArea; this->_safeArea = safeArea;
...@@ -40,7 +40,7 @@ void RoutingWorker::route(const snake::BoostPolygon &safeArea, ...@@ -40,7 +40,7 @@ void RoutingWorker::route(const snake::BoostPolygon &safeArea,
} }
} }
void RoutingWorker::run() { void RoutingThread::run() {
qWarning() << "RoutingWorker::run(): thread start."; qWarning() << "RoutingWorker::run(): thread start.";
while (!this->_stop) { while (!this->_stop) {
#ifdef DEBUG_CIRCULAR_SURVEY #ifdef DEBUG_CIRCULAR_SURVEY
......
...@@ -20,7 +20,7 @@ struct RoutingData { ...@@ -20,7 +20,7 @@ struct RoutingData {
//! \brief The CSWorker class //! \brief The CSWorker class
//! \note Don't call QThread::start, QThread::quit, etc. onyl use Worker //! \note Don't call QThread::start, QThread::quit, etc. onyl use Worker
//! members! //! members!
class RoutingWorker : public QThread { class RoutingThread : public QThread {
Q_OBJECT Q_OBJECT
using Lock = std::unique_lock<std::mutex>; using Lock = std::unique_lock<std::mutex>;
...@@ -28,8 +28,8 @@ public: ...@@ -28,8 +28,8 @@ public:
using PtrRoutingData = QSharedPointer<RoutingData>; using PtrRoutingData = QSharedPointer<RoutingData>;
using Generator = std::function<bool(snake::Transects &)>; using Generator = std::function<bool(snake::Transects &)>;
RoutingWorker(QObject *parent = nullptr); RoutingThread(QObject *parent = nullptr);
~RoutingWorker() override; ~RoutingThread() override;
bool calculating(); bool calculating();
......
...@@ -326,7 +326,7 @@ bool dijkstraAlgorithm( ...@@ -326,7 +326,7 @@ bool dijkstraAlgorithm(
return true; return true;
} }
void toDistanceMatrix(Matrix<double> &graph) { bool toDistanceMatrix(Matrix<double> &graph) {
size_t n = graph.getN(); size_t n = graph.getN();
auto distance = [graph](size_t i, size_t j) { return graph.get(i, j); }; auto distance = [graph](size_t i, size_t j) { return graph.get(i, j); };
...@@ -338,9 +338,9 @@ void toDistanceMatrix(Matrix<double> &graph) { ...@@ -338,9 +338,9 @@ void toDistanceMatrix(Matrix<double> &graph) {
if (!std::isinf(d)) if (!std::isinf(d))
continue; continue;
path.clear(); path.clear();
bool ret = dijkstraAlgorithm(n, i, j, path, distance); if (!dijkstraAlgorithm(n, i, j, path, distance)) {
assert(ret); return false;
(void)ret; }
// cout << "(" << i << "," << j << ") d: " << d << endl; // cout << "(" << i << "," << j << ") d: " << d << endl;
// cout << "Path size: " << path.size() << endl; // cout << "Path size: " << path.size() << endl;
// for (auto idx : path) // for (auto idx : path)
...@@ -360,6 +360,7 @@ void toDistanceMatrix(Matrix<double> &graph) { ...@@ -360,6 +360,7 @@ void toDistanceMatrix(Matrix<double> &graph) {
graph.set(j, i, d); graph.set(j, i, d);
} }
} }
return true;
} }
void shortestPathFromGraph(const Matrix<double> &graph, size_t startIndex, void shortestPathFromGraph(const Matrix<double> &graph, size_t startIndex,
...@@ -740,7 +741,7 @@ struct RoutingDataModel { ...@@ -740,7 +741,7 @@ struct RoutingDataModel {
RoutingIndexManager::NodeIndex depot; RoutingIndexManager::NodeIndex depot;
}; };
void generateRoutingModel(const BoostLineString &vertices, bool generateRoutingModel(const BoostLineString &vertices,
const BoostPolygon &polygonOffset, size_t n0, const BoostPolygon &polygonOffset, size_t n0,
RoutingDataModel &dataModel, Matrix<double> &graph) { RoutingDataModel &dataModel, Matrix<double> &graph) {
...@@ -758,7 +759,9 @@ void generateRoutingModel(const BoostLineString &vertices, ...@@ -758,7 +759,9 @@ void generateRoutingModel(const BoostLineString &vertices,
#ifdef SNAKE_SHOW_TIME #ifdef SNAKE_SHOW_TIME
start = std::chrono::high_resolution_clock::now(); start = std::chrono::high_resolution_clock::now();
#endif #endif
toDistanceMatrix(distanceMatrix); if (!toDistanceMatrix(distanceMatrix)) {
return false;
}
#ifdef SNAKE_SHOW_TIME #ifdef SNAKE_SHOW_TIME
delta = std::chrono::duration_cast<std::chrono::milliseconds>( delta = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - start); std::chrono::high_resolution_clock::now() - start);
...@@ -778,6 +781,7 @@ void generateRoutingModel(const BoostLineString &vertices, ...@@ -778,6 +781,7 @@ void generateRoutingModel(const BoostLineString &vertices,
} }
dataModel.numVehicles = 1; dataModel.numVehicles = 1;
dataModel.depot = 0; dataModel.depot = 0;
return true;
} }
bool route(const BoostPolygon &area, const Transects &transects, bool route(const BoostPolygon &area, const Transects &transects,
...@@ -836,7 +840,11 @@ bool route(const BoostPolygon &area, const Transects &transects, ...@@ -836,7 +840,11 @@ bool route(const BoostPolygon &area, const Transects &transects,
#ifdef SNAKE_SHOW_TIME #ifdef SNAKE_SHOW_TIME
auto start = std::chrono::high_resolution_clock::now(); auto start = std::chrono::high_resolution_clock::now();
#endif #endif
generateRoutingModel(vertices, areaOffset, n0, dataModel, connectionGraph); if (!generateRoutingModel(vertices, areaOffset, n0, dataModel,
connectionGraph)) {
errorString = "Routing model generation failed.";
return false;
}
#ifdef SNAKE_SHOW_TIME #ifdef SNAKE_SHOW_TIME
auto delta = std::chrono::duration_cast<std::chrono::milliseconds>( auto delta = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - start); std::chrono::high_resolution_clock::now() - start);
......
...@@ -149,7 +149,7 @@ void offsetPolygon(const BoostPolygon &polygon, BoostPolygon &polygonOffset, ...@@ -149,7 +149,7 @@ void offsetPolygon(const BoostPolygon &polygon, BoostPolygon &polygonOffset,
double offset); double offset);
void graphFromPolygon(const BoostPolygon &polygon, void graphFromPolygon(const BoostPolygon &polygon,
const BoostLineString &vertices, Matrix<double> &graph); const BoostLineString &vertices, Matrix<double> &graph);
void toDistanceMatrix(Matrix<double> &graph); bool toDistanceMatrix(Matrix<double> &graph);
bool dijkstraAlgorithm( bool dijkstraAlgorithm(
const size_t numElements, size_t startIndex, size_t endIndex, const size_t numElements, size_t startIndex, size_t endIndex,
std::vector<size_t> &elementPath, std::vector<size_t> &elementPath,
......
This diff is collapsed.
This diff is collapsed.
...@@ -138,7 +138,6 @@ public: ...@@ -138,7 +138,6 @@ public:
QString nemoStatusString(void) const; QString nemoStatusString(void) const;
bool snakeCalcInProgress(void) const; bool snakeCalcInProgress(void) const;
// Smart RTL.
bool uploadOverrideRequired(void) const; bool uploadOverrideRequired(void) const;
bool vehicleHasLowBattery(void) const; bool vehicleHasLowBattery(void) const;
// Waypoint statistics. // Waypoint statistics.
...@@ -234,7 +233,7 @@ private slots: ...@@ -234,7 +233,7 @@ private slots:
void _setPhaseDuration(double duration); void _setPhaseDuration(double duration);
// SMART RTL // SMART RTL
void _checkBatteryLevel(void); void _checkBatteryLevel(void);
bool _checkSmartRTLPreCondition(QString &errorString); bool _SRTLPrecondition(QString &errorString);
void _initSmartRTL(); void _initSmartRTL();
void _smartRTLCleanUp(bool flying); void _smartRTLCleanUp(bool flying);
// Snake. // Snake.
......
...@@ -742,12 +742,14 @@ QSharedPointer<WimaPlanData> WimaPlaner::toPlanData() { ...@@ -742,12 +742,14 @@ QSharedPointer<WimaPlanData> WimaPlaner::toPlanData() {
// convert mission items to mavlink commands // convert mission items to mavlink commands
QList<MissionItem *> missionItems; QList<MissionItem *> missionItems;
_TSComplexItem->appendMissionItems(missionItems, nullptr); if (_missionController && _missionController->visualItems()) {
// store mavlink commands int surveyIndex =
qWarning() << "WimaPlaner"; _missionController->visualItems()->indexOf(_TSComplexItem);
for (auto *item : missionItems) { if (surveyIndex > 0) {
qWarning() << item->coordinate(); _TSComplexItem->appendMissionItems(missionItems, nullptr);
}
} }
// store mavlink commands
planData->append(missionItems); planData->append(missionItems);
return planData; return planData;
} }
......
import QtQml 2.2
import QtQuick 2.0
import QtLocation 5.3
MapQuickItem {
id: root
width: 20
height: 20
anchorPoint.x: width/2
anchorPoint.y: height/2
property color primaryColor: "orange"
property color secondaryColor: "lightblue"
property real centerWidth: width / 2
property real centerHeight: height / 2
property real radius: Math.min(canvas.width, canvas.height) / 2
property real minimumValue: 0
property real maximumValue: 100
property real currentValue: 33
// this is the angle that splits the circle in two arcs
// first arc is drawn from 0 radians to angle radians
// second arc is angle radians to 2*PI radians
property real angle: (currentValue - minimumValue) / (maximumValue - minimumValue) * 2 * Math.PI
// we want both circle to start / end at 12 o'clock
// without this offset we would start / end at 9 o'clock
property real angleOffset: -Math.PI / 2
property string text: ""
signal clicked()
onPrimaryColorChanged: canvas.requestPaint()
onSecondaryColorChanged: canvas.requestPaint()
onMinimumValueChanged: canvas.requestPaint()
onMaximumValueChanged: canvas.requestPaint()
onCurrentValueChanged: canvas.requestPaint()
// draws two arcs (portion of a circle)
// fills the circle with a lighter secondary color
// when pressed
sourceItem: Canvas {
id: canvas
width: root.width
height: root.height
antialiasing: true
onPaint: {
var ctx = getContext("2d");
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
// fills the mouse area when pressed
// the fill color is a lighter version of the
// secondary color
if (mouseArea.pressed) {
ctx.beginPath();
ctx.lineWidth = 1;
ctx.fillStyle = Qt.lighter(root.secondaryColor, 1.25);
ctx.arc(root.centerWidth,
root.centerHeight,
root.radius,
0,
2*Math.PI);
ctx.fill();
}
// First, thinner arc
// From angle to 2*PI
ctx.beginPath();
ctx.lineWidth = 1;
ctx.strokeStyle = primaryColor;
ctx.arc(root.centerWidth,
root.centerHeight,
root.radius,
angleOffset + root.angle,
angleOffset + 2*Math.PI);
ctx.stroke();
// Second, thicker arc
// From 0 to angle
ctx.beginPath();
ctx.lineWidth = 3;
ctx.strokeStyle = root.secondaryColor;
ctx.arc(root.centerWidth,
root.centerHeight,
root.radius,
root.angleOffset,
root.angleOffset + root.angle);
ctx.stroke();
ctx.restore();
}
Text {
anchors.centerIn: parent
text: root.text
color: root.primaryColor
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: root.clicked()
onPressedChanged: canvas.requestPaint()
}
}
}
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