Commit 8b16b196 authored by Valentin Platzgummer's avatar Valentin Platzgummer

temp

parent 990aa5eb
...@@ -434,6 +434,7 @@ HEADERS += \ ...@@ -434,6 +434,7 @@ HEADERS += \
src/Wima/Geometry/GenericPolygon.h \ src/Wima/Geometry/GenericPolygon.h \
src/Wima/Geometry/GenericPolygonArray.h \ src/Wima/Geometry/GenericPolygonArray.h \
src/Wima/Geometry/GeoPoint3D.h \ src/Wima/Geometry/GeoPoint3D.h \
src/Wima/Snake/NemoInterface.h \
src/Wima/Snake/QNemoHeartbeat.h \ src/Wima/Snake/QNemoHeartbeat.h \
src/Wima/Snake/QNemoProgress.h \ src/Wima/Snake/QNemoProgress.h \
src/Wima/Snake/QNemoProgress.h \ src/Wima/Snake/QNemoProgress.h \
...@@ -500,6 +501,7 @@ SOURCES += \ ...@@ -500,6 +501,7 @@ SOURCES += \
src/Snake/clipper/clipper.cpp \ src/Snake/clipper/clipper.cpp \
src/Snake/snake.cpp \ src/Snake/snake.cpp \
src/Wima/Geometry/GeoPoint3D.cpp \ src/Wima/Geometry/GeoPoint3D.cpp \
src/Wima/Snake/NemoInterface.cpp \
src/Wima/Snake/QNemoProgress.cc \ src/Wima/Snake/QNemoProgress.cc \
src/Wima/Snake/SnakeDataManager.cc \ src/Wima/Snake/SnakeDataManager.cc \
src/Wima/Snake/SnakeTile.cpp \ src/Wima/Snake/SnakeTile.cpp \
......
...@@ -454,7 +454,7 @@ bool Scenario::update() { ...@@ -454,7 +454,7 @@ bool Scenario::update() {
return true; return true;
} }
bool Scenario::_calculateBoundingBox() { bool Scenario::_calculateBoundingBox() const {
return minimalBoundingBox(_mArea, _mAreaBoundingBox); return minimalBoundingBox(_mArea, _mAreaBoundingBox);
} }
...@@ -474,7 +474,7 @@ bool Scenario::_calculateBoundingBox() { ...@@ -474,7 +474,7 @@ bool Scenario::_calculateBoundingBox() {
* *
* @return Returns true if successful. * @return Returns true if successful.
*/ */
bool Scenario::_calculateTiles() { bool Scenario::_calculateTiles() const {
_tiles.clear(); _tiles.clear();
_tileCenterPoints.clear(); _tileCenterPoints.clear();
...@@ -571,7 +571,7 @@ bool Scenario::_calculateTiles() { ...@@ -571,7 +571,7 @@ bool Scenario::_calculateTiles() {
return true; return true;
} }
bool Scenario::_calculateJoinedArea() { bool Scenario::_calculateJoinedArea() const {
_jArea.clear(); _jArea.clear();
// Measurement area and service area overlapping? // Measurement area and service area overlapping?
bool overlapingSerMeas = bg::intersects(_mArea, _sArea) ? true : false; bool overlapingSerMeas = bg::intersects(_mArea, _sArea) ? true : false;
...@@ -775,7 +775,7 @@ bool flight_plan::transectsFromScenario(Length distance, Length minLength, ...@@ -775,7 +775,7 @@ bool flight_plan::transectsFromScenario(Length distance, Length minLength,
ClipperLib::PolyTree clippedTransecs; ClipperLib::PolyTree clippedTransecs;
clipper.Execute(ClipperLib::ctIntersection, clippedTransecs, clipper.Execute(ClipperLib::ctIntersection, clippedTransecs,
ClipperLib::pftNonZero, ClipperLib::pftNonZero); ClipperLib::pftNonZero, ClipperLib::pftNonZero);
auto &transects = clippedTransecs; const auto *transects = &clippedTransecs;
bool ignoreProgress = p.size() != scenario.tiles().size(); bool ignoreProgress = p.size() != scenario.tiles().size();
ClipperLib::PolyTree clippedTransecs2; ClipperLib::PolyTree clippedTransecs2;
...@@ -793,9 +793,9 @@ bool flight_plan::transectsFromScenario(Length distance, Length minLength, ...@@ -793,9 +793,9 @@ bool flight_plan::transectsFromScenario(Length distance, Length minLength,
if (processedTiles.size() != numTiles) { if (processedTiles.size() != numTiles) {
vector<ClipperLib::Path> processedTilesClipper; vector<ClipperLib::Path> processedTilesClipper;
for (auto t : processedTiles) { for (const auto &t : processedTiles) {
ClipperLib::Path path; ClipperLib::Path path;
for (auto vertex : t.outer()) { for (const auto &vertex : t.outer()) {
path.push_back(ClipperLib::IntPoint{ path.push_back(ClipperLib::IntPoint{
static_cast<ClipperLib::cInt>(vertex.get<0>() * CLIPPER_SCALE), static_cast<ClipperLib::cInt>(vertex.get<0>() * CLIPPER_SCALE),
static_cast<ClipperLib::cInt>(vertex.get<1>() * CLIPPER_SCALE)}); static_cast<ClipperLib::cInt>(vertex.get<1>() * CLIPPER_SCALE)});
...@@ -805,26 +805,31 @@ bool flight_plan::transectsFromScenario(Length distance, Length minLength, ...@@ -805,26 +805,31 @@ bool flight_plan::transectsFromScenario(Length distance, Length minLength,
// Subtract holes (tiles with measurement_progress == 100) from transects. // Subtract holes (tiles with measurement_progress == 100) from transects.
clipper.Clear(); clipper.Clear();
for (auto &child : clippedTransecs.Childs) for (const auto &child : clippedTransecs.Childs) {
clipper.AddPath(child->Contour, ClipperLib::ptSubject, false); clipper.AddPath(child->Contour, ClipperLib::ptSubject, false);
}
clipper.AddPaths(processedTilesClipper, ClipperLib::ptClip, true); clipper.AddPaths(processedTilesClipper, ClipperLib::ptClip, true);
clipper.Execute(ClipperLib::ctDifference, clippedTransecs2, clipper.Execute(ClipperLib::ctDifference, clippedTransecs2,
ClipperLib::pftNonZero, ClipperLib::pftNonZero); ClipperLib::pftNonZero, ClipperLib::pftNonZero);
transects = clippedTransecs2; transects = &clippedTransecs2;
} else {
// All tiles processed (t.size() not changed).
return true;
} }
} }
// Extract transects from PolyTree and convert them to BoostLineString // Extract transects from PolyTree and convert them to BoostLineString
for (auto &child : transects.Childs) { for (const auto &child : transects->Childs) {
auto &clipperTransect = child->Contour; const auto &clipperTransect = child->Contour;
BoostPoint v1{static_cast<double>(clipperTransect[0].X) / CLIPPER_SCALE, BoostPoint v1{static_cast<double>(clipperTransect[0].X) / CLIPPER_SCALE,
static_cast<double>(clipperTransect[0].Y) / CLIPPER_SCALE}; static_cast<double>(clipperTransect[0].Y) / CLIPPER_SCALE};
BoostPoint v2{static_cast<double>(clipperTransect[1].X) / CLIPPER_SCALE, BoostPoint v2{static_cast<double>(clipperTransect[1].X) / CLIPPER_SCALE,
static_cast<double>(clipperTransect[1].Y) / CLIPPER_SCALE}; static_cast<double>(clipperTransect[1].Y) / CLIPPER_SCALE};
BoostLineString transect{v1, v2}; BoostLineString transect{v1, v2};
if (bg::length(transect) >= minLength.value()) if (bg::length(transect) >= minLength.value()) {
t.push_back(transect); t.push_back(transect);
}
} }
if (t.size() == 0) { if (t.size() == 0) {
......
...@@ -173,14 +173,14 @@ public: ...@@ -173,14 +173,14 @@ public:
const BoundingBox &measurementAreaBBox() const; const BoundingBox &measurementAreaBBox() const;
const BoostPoint &homePositon() const; const BoostPoint &homePositon() const;
bool update(); bool update() const;
string errorString; mutable string errorString;
private: private:
bool _calculateBoundingBox(); bool _calculateBoundingBox() const;
bool _calculateTiles(); bool _calculateTiles() const;
bool _calculateJoinedArea(); bool _calculateJoinedArea() const;
Length _tileWidth; Length _tileWidth;
Length _tileHeight; Length _tileHeight;
...@@ -191,12 +191,12 @@ private: ...@@ -191,12 +191,12 @@ private:
BoostPolygon _mArea; BoostPolygon _mArea;
BoostPolygon _sArea; BoostPolygon _sArea;
BoostPolygon _corridor; BoostPolygon _corridor;
BoostPolygon _jArea; mutable BoostPolygon _jArea;
BoundingBox _mAreaBoundingBox; mutable BoundingBox _mAreaBoundingBox;
vector<BoostPolygon> _tiles; mutable vector<BoostPolygon> _tiles;
BoostLineString _tileCenterPoints; mutable BoostLineString _tileCenterPoints;
BoostPoint _homePosition; mutable BoostPoint _homePosition;
}; };
template <class GeoPoint, template <class, class...> class Container> template <class GeoPoint, template <class, class...> class Container>
......
This diff is collapsed.
#pragma once
#include <QGeoCoordinate>
#include <QObject>
#include "SnakeTilesLocal.h"
#include <memory>
class NemoInterface : public QObject {
Q_OBJECT
class Impl;
using PImpl = std::unique_ptr<Impl>;
public:
enum class NemoStatus {
NotConnected = 0,
Connected = 1,
Timeout = -1,
InvalidHeartbeat = -2
};
explicit NemoInterface(QObject *parent = nullptr);
void start();
void stop();
void setTilesENU(const SnakeTilesLocal &tilesENU);
void setENUOrigin(const QGeoCoordinate &ENUOrigin);
NemoStatus status();
QVector<int> progress();
signals:
void statusChanged();
void progressChanged();
private:
PImpl pImpl;
};
This diff is collapsed.
...@@ -15,13 +15,6 @@ using namespace boost::units; ...@@ -15,13 +15,6 @@ using namespace boost::units;
using Length = quantity<si::length>; using Length = quantity<si::length>;
using Area = quantity<si::area>; using Area = quantity<si::area>;
enum class NemoStatus {
NotConnected = 0,
Connected = 1,
Timeout = -1,
InvalidHeartbeat = -2
};
class SnakeDataManager : public QThread { class SnakeDataManager : public QThread {
Q_OBJECT Q_OBJECT
...@@ -39,7 +32,6 @@ public: ...@@ -39,7 +32,6 @@ public:
const QmlObjectListModel *tiles() const; const QmlObjectListModel *tiles() const;
QVariantList tileCenterPoints() const; QVariantList tileCenterPoints() const;
QNemoProgress nemoProgress() const; QNemoProgress nemoProgress() const;
int nemoStatus() const;
bool calcInProgress() const; bool calcInProgress() const;
QString errorMessage() const; QString errorMessage() const;
bool success() const; bool success() const;
...@@ -63,12 +55,7 @@ public: ...@@ -63,12 +55,7 @@ public:
Length tileWidth() const; Length tileWidth() const;
void setTileWidth(Length tileWidth); void setTileWidth(Length tileWidth);
void enableRosBridge();
void disableRosBride();
signals: signals:
void nemoProgressChanged();
void nemoStatusChanged(int status);
void calcInProgressChanged(bool inProgress); void calcInProgressChanged(bool inProgress);
protected: protected:
......
This diff is collapsed.
...@@ -121,6 +121,8 @@ WimaController::WimaController(QObject *parent) ...@@ -121,6 +121,8 @@ WimaController::WimaController(QObject *parent)
&WimaController::nemoStatusChanged); &WimaController::nemoStatusChanged);
connect(_currentDM, &SnakeDataManager::nemoStatusChanged, this, connect(_currentDM, &SnakeDataManager::nemoStatusChanged, this,
&WimaController::nemoStatusStringChanged); &WimaController::nemoStatusStringChanged);
connect(_currentDM, &SnakeDataManager::calcInProgressChanged, this,
&WimaController::snakeCalcInProgressChanged);
connect(this, &QObject::destroyed, &this->_snakeDM, &SnakeDataManager::quit); connect(this, &QObject::destroyed, &this->_snakeDM, &SnakeDataManager::quit);
connect(this, &QObject::destroyed, &this->_emptyDM, &SnakeDataManager::quit); connect(this, &QObject::destroyed, &this->_emptyDM, &SnakeDataManager::quit);
...@@ -726,15 +728,15 @@ void WimaController::_DMFinishedHandler() { ...@@ -726,15 +728,15 @@ void WimaController::_DMFinishedHandler() {
} }
// Do update. // Do update.
auto fut = QtConcurrent::run([this] { this->_snakeWM.update(); // this can take a while (ca. 200ms)
this->_snakeWM.update(); // this can take a while (ca. 200ms)
emit this->missionItemsChanged(); emit snakeTilesChanged();
emit this->currentMissionItemsChanged(); emit snakeTileCenterPointsChanged();
emit this->currentWaypointPathChanged(); emit nemoProgressChanged();
emit this->waypointPathChanged(); emit missionItemsChanged();
}); emit currentMissionItemsChanged();
(void)fut; emit currentWaypointPathChanged();
emit waypointPathChanged();
} }
void WimaController::_switchToSnakeWaypointManager(QVariant variant) { void WimaController::_switchToSnakeWaypointManager(QVariant variant) {
...@@ -756,6 +758,8 @@ void WimaController::_switchDataManager(SnakeDataManager &dataManager) { ...@@ -756,6 +758,8 @@ void WimaController::_switchDataManager(SnakeDataManager &dataManager) {
&WimaController::nemoStatusChanged); &WimaController::nemoStatusChanged);
disconnect(_currentDM, &SnakeDataManager::nemoStatusChanged, this, disconnect(_currentDM, &SnakeDataManager::nemoStatusChanged, this,
&WimaController::nemoStatusStringChanged); &WimaController::nemoStatusStringChanged);
disconnect(_currentDM, &SnakeDataManager::calcInProgressChanged, this,
&WimaController::snakeCalcInProgressChanged);
_currentDM = &dataManager; _currentDM = &dataManager;
...@@ -767,8 +771,9 @@ void WimaController::_switchDataManager(SnakeDataManager &dataManager) { ...@@ -767,8 +771,9 @@ void WimaController::_switchDataManager(SnakeDataManager &dataManager) {
&WimaController::nemoStatusChanged); &WimaController::nemoStatusChanged);
connect(_currentDM, &SnakeDataManager::nemoStatusChanged, this, connect(_currentDM, &SnakeDataManager::nemoStatusChanged, this,
&WimaController::nemoStatusStringChanged); &WimaController::nemoStatusStringChanged);
connect(_currentDM, &SnakeDataManager::calcInProgressChanged, this,
&WimaController::snakeCalcInProgressChanged);
emit snakeConnectionStatusChanged();
emit snakeCalcInProgressChanged(); emit snakeCalcInProgressChanged();
emit snakeTilesChanged(); emit snakeTilesChanged();
emit snakeTileCenterPointsChanged(); emit snakeTileCenterPointsChanged();
...@@ -778,16 +783,13 @@ void WimaController::_switchDataManager(SnakeDataManager &dataManager) { ...@@ -778,16 +783,13 @@ void WimaController::_switchDataManager(SnakeDataManager &dataManager) {
} }
} }
void WimaController::_progressChangedHandler() { void WimaController::_progressChangedHandler() { _snakeDM.start(); }
emit this->nemoProgressChanged();
this->_currentDM->start();
}
void WimaController::_enableSnakeChangedHandler() { void WimaController::_enableSnakeChangedHandler() {
if (this->_enableSnake.rawValue().toBool()) { if (this->_enableSnake.rawValue().toBool()) {
qDebug() << "WimaController: enabling snake."; qDebug() << "WimaController: enabling snake.";
_switchDataManager(this->_snakeDM);
this->_snakeDM.enableRosBridge(); this->_snakeDM.enableRosBridge();
_switchDataManager(_snakeDM);
_currentDM->start(); _currentDM->start();
} else { } else {
qDebug() << "WimaController: disabling snake."; qDebug() << "WimaController: disabling snake.";
......
...@@ -205,7 +205,6 @@ signals: ...@@ -205,7 +205,6 @@ signals:
void phaseDistanceChanged(void); void phaseDistanceChanged(void);
void phaseDurationChanged(void); void phaseDurationChanged(void);
// Snake. // Snake.
void snakeConnectionStatusChanged(void);
void snakeCalcInProgressChanged(void); void snakeCalcInProgressChanged(void);
void snakeTilesChanged(void); void snakeTilesChanged(void);
void snakeTileCenterPointsChanged(void); void snakeTileCenterPointsChanged(void);
......
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