Commit dedb0c51 authored by Valentin Platzgummer's avatar Valentin Platzgummer

nemo interface moved to wima planer

parent 529f7da8
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -273,7 +273,6 @@ FlightMap {
MapItemView {
id: tileView
property bool _enable: wimaController.enableWimaController.value
&& wimaController.enableSnake.value
property bool valid: wimaController.snakeTileCenterPoints.length
=== wimaController.nemoProgress.length
model: _enable ? wimaController.snakeTiles : 0
......
......@@ -46,7 +46,6 @@ Item {
// Use Settings to store menu appearance through different sessions.
Settings {
property alias snakeHeaderChecker: snakeHeader.checked
property alias missionHeaderChecker: missionHeader.checked
property alias navigateHeaderChecker: navigateHeader.checked
property alias vehicleHeaderChecker: vehicleHeader.checked
......@@ -98,7 +97,6 @@ Item {
property var enableWimaFact: wimaController.enableWimaController
property bool enableWimaBoolean: enableWimaFact.value
property var enableSnakeFact: wimaController.enableSnake
onAccept: {
if (enableWimaBoolean) {
......@@ -108,7 +106,6 @@ Item {
} else {
enableWimaFact.value = true
enableWimaMouseArea.enabled = false
enableSnakeCheckBox.checkedState = false;
timer.stop()
}
}
......@@ -176,56 +173,6 @@ Item {
id: mainColumn
spacing: ScreenTools.defaultFontPixelHeight * 0.3
SectionHeader{
id: snakeHeader
text: qsTr("Snake Settings")
}
Column {
visible: snakeHeader.checked
spacing: ScreenTools.defaultFontPixelHeight * 0.5
FactCheckBox {
id: enableSnakeCheckBox
text: wimaController.enableSnake.value ?
qsTr("Disable Snake")
: qsTr("Enable Snake")
fact: wimaController.enableSnake
}
// Spacer
Item {
height: 1
}
// Snake status and settings column.
GridLayout {
columns: 2
rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5
columnSpacing: ScreenTools.defaultFontPixelHeight * 0.5
visible: wimaController.enableSnake.value
// Snake connection status.
QGCLabel {
property int index: wimaController.nemoStatus
property string statusString: wimaController.nemoStatusString
text: "Status: " + statusString
Layout.fillWidth: true
}
// Snake calculation status.
QGCLabel {
property bool _calcInProgress: wimaController.snakeCalcInProgress
text: _calcInProgress === true ?
qsTr("Calculation: In Progress")
: qsTr("Calculation: Idle")
Layout.fillWidth: true
}
}
}
SectionHeader{
id: missionHeader
......
......@@ -143,7 +143,7 @@ Rectangle {
model: len
delegate: QGCRadioButton {
checked: index === variantRepeater.variant
text: variantRepeater.names[index]
text: variantRepeater.names[index] ? variantRepeater.names[index]: ""
onCheckedChanged: {
if (checked){
......
This diff is collapsed.
......@@ -146,6 +146,8 @@ QmlObjectListModel *WimaMeasurementArea::tiles() {
return &this->_tileData.tiles;
}
QVector<int> WimaMeasurementArea::progress() { return this->_progress; }
const QmlObjectListModel *WimaMeasurementArea::tiles() const {
return &this->_tileData.tiles;
}
......@@ -226,6 +228,17 @@ bool WimaMeasurementArea::loadFromJson(const QJsonObject &json,
return false;
}
}
bool WimaMeasurementArea::setProgress(const QVector<int> &p) {
if (!_calculating) {
if (p.size() == this->tiles()->count() && this->_progress != p) {
this->_progress = p;
emit progressChanged();
return true;
}
}
return false;
}
//!
//! \brief WimaMeasurementArea::doUpdate
//! \pre WimaMeasurementArea::deferUpdate must be called first, don't call
......@@ -312,6 +325,8 @@ void WimaMeasurementArea::deferUpdate() {
this->_timer.stop();
}
if (this->_tileData.size() > 0) {
this->_progress.clear();
emit this->progressChanged();
this->_tileData.clear();
emit this->tilesChanged();
}
......
......@@ -41,6 +41,7 @@ public:
Q_PROPERTY(Fact *showTiles READ showTiles CONSTANT)
Q_PROPERTY(QmlObjectListModel *tiles READ tiles NOTIFY tilesChanged)
Q_PROPERTY(int maxTiles READ maxTiles NOTIFY maxTilesChanged)
Q_PROPERTY(QVector<int> progress READ progress NOTIFY progressChanged)
// Overrides from WimaPolygon
QString mapVisualQML(void) const;
......@@ -53,6 +54,7 @@ public:
Fact *minTransectLength();
Fact *showTiles();
QmlObjectListModel *tiles();
QVector<int> progress();
const QmlObjectListModel *tiles() const;
const QVariantList &tileCenterPoints() const; // List of QGeoCoordinate
const TileData &tileData() const;
......@@ -80,8 +82,10 @@ public:
signals:
void tilesChanged();
void maxTilesChanged();
void progressChanged();
public slots:
bool setProgress(const QVector<int> &p);
private slots:
void doUpdate();
......@@ -108,4 +112,6 @@ private:
TileData _tileData;
QFutureWatcher<DataPtr> _watcher;
bool _calculating;
QVector<int> _progress;
};
This diff is collapsed.
......@@ -13,28 +13,48 @@ class NemoInterface : public QObject {
using PImpl = std::unique_ptr<Impl>;
public:
enum class NemoStatus {
NotConnected = 0,
Connected = 1,
Timeout = -1,
InvalidHeartbeat = -2
enum class STATUS {
NOT_CONNECTED = 0,
HEARTBEAT_DETECTED = 1,
WEBSOCKET_DETECTED = 2,
TIMEOUT = -1,
INVALID_HEARTBEAT = -2
};
explicit NemoInterface(QObject *parent = nullptr);
~NemoInterface() override;
void start();
void stop();
Q_PROPERTY(int status READ status NOTIFY statusChanged)
Q_PROPERTY(QString statusString READ statusString NOTIFY statusChanged)
Q_PROPERTY(QVector<int> progress READ progress NOTIFY progressChanged)
Q_PROPERTY(QString editorQml READ editorQml CONSTANT)
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
Q_PROPERTY(bool holdProgress READ holdProgress WRITE setHoldProgress NOTIFY
holdProgressChanged)
void publishTileData(const TileData &tileData);
Q_INVOKABLE void start();
Q_INVOKABLE void stop();
Q_INVOKABLE void publishTileData();
Q_INVOKABLE void requestProgress();
void setTileData(const TileData &tileData);
bool hasTileData(const TileData &tileData) const;
void setAutoPublish(bool ap);
void setHoldProgress(bool hp);
NemoStatus status() const;
int status() const;
STATUS statusEnum() const;
QString statusString() const;
QVector<int> progress() const;
QString editorQml();
bool running();
bool holdProgress();
signals:
void statusChanged();
void progressChanged();
void runningChanged();
void holdProgressChanged();
private:
PImpl pImpl;
......
This diff is collapsed.
......@@ -67,12 +67,9 @@ public:
double phaseDuration READ phaseDuration NOTIFY phaseDurationChanged)
// Snake
Q_PROPERTY(Fact *enableSnake READ enableSnake CONSTANT)
Q_PROPERTY(int nemoStatus READ nemoStatus NOTIFY nemoStatusChanged)
Q_PROPERTY(QString nemoStatusString READ nemoStatusString NOTIFY
nemoStatusStringChanged)
Q_PROPERTY(bool snakeCalcInProgress READ snakeCalcInProgress NOTIFY
snakeCalcInProgressChanged)
Q_PROPERTY(
QmlObjectListModel *snakeTiles READ snakeTiles NOTIFY snakeTilesChanged)
Q_PROPERTY(QVariantList snakeTileCenterPoints READ snakeTileCenterPoints
......@@ -102,15 +99,12 @@ public:
Fact *flightSpeed(void);
Fact *arrivalReturnSpeed(void);
Fact *altitude(void);
// Snake settings facts.
Fact *enableSnake(void) { return &_enableSnake; }
// Snake data.
QmlObjectListModel *snakeTiles(void);
QVariantList snakeTileCenterPoints(void);
QVector<int> nemoProgress(void);
int nemoStatus(void) const;
QString nemoStatusString(void) const;
bool snakeCalcInProgress(void) const;
bool uploadOverrideRequired(void) const;
bool vehicleHasLowBattery(void) const;
......@@ -153,8 +147,6 @@ public:
static const char *flightSpeedName;
static const char *arrivalReturnSpeedName;
static const char *altitudeName;
static const char *snakeLineDistanceName;
static const char *snakeMinTransectLengthName;
signals:
// Controllers.
......@@ -176,7 +168,6 @@ signals:
void phaseDistanceChanged(void);
void phaseDurationChanged(void);
// Snake.
void snakeCalcInProgressChanged(void);
void snakeTilesChanged(void);
void nemoProgressChanged(void);
void nemoStatusChanged(void);
......@@ -207,12 +198,7 @@ private slots:
void _initSmartRTL();
void _smartRTLCleanUp(bool flying);
// Snake.
void _storeRoute(RoutingThread::PtrRoutingData data);
void _switchWaypointManager(WaypointManager::ManagerBase &manager);
void _switchToSnakeWaypointManager(QVariant variant);
void _progressChangedHandler();
void _enableSnakeChangedHandler();
void _updateRoute();
// Periodic tasks.
void _eventTimerHandler(void);
......@@ -234,7 +220,6 @@ private:
WaypointManager::AreaInterface _areaInterface;
WaypointManager::Settings _WMSettings; // Waypoint Manager Settings
WaypointManager::DefaultManager _defaultWM;
WaypointManager::DefaultManager _snakeWM;
WaypointManager::RTLManager _rtlWM;
WaypointManager::ManagerBase *_currentWM;
using ManagerList = QList<WaypointManager::ManagerBase *>;
......@@ -262,7 +247,6 @@ private:
SettingsFact _flightSpeed; // mission flight speed
SettingsFact _arrivalReturnSpeed; // arrival and return path speed
SettingsFact _altitude; // mission altitude
SettingsFact _enableSnake; // Enable Snake (see snake.h)
// Smart RTL.
QTimer _smartRTLTimer;
......@@ -271,13 +255,8 @@ private:
// Waypoint statistics.
double _measurementPathLength; // the lenght of the phase in meters
// Snake
QList<QList<QGeoCoordinate>> _rawTransects;
NemoInterface _nemoInterface;
using StatusMap = std::map<int, QString>;
static StatusMap _nemoStatusMap;
RoutingThread _routingThread;
QGeoCoordinate _origin;
// Periodic tasks.
QTimer _eventTimer;
......
......@@ -25,7 +25,8 @@ WimaPlaner::WimaPlaner(QObject *parent)
_currentAreaIndex(-1), _wimaBridge(nullptr), _mAreaChanged(true),
_sAreaChanged(true), _corridorChanged(true), _joinedArea(this),
_arrivalPathLength(0), _returnPathLength(0), _TSComplexItem(nullptr),
_surveyChanged(true), _synchronized(false), _needsUpdate(true) {
_surveyChanged(true), _synchronized(false), _needsUpdate(true),
_nemoInterface(this) {
connect(this, &WimaPlaner::currentPolygonIndexChanged, this,
&WimaPlaner::updatePolygonInteractivity);
......@@ -33,10 +34,14 @@ WimaPlaner::WimaPlaner(QObject *parent)
this->_mAreaChanged = true;
this->setNeedsUpdate(true);
});
connect(&this->_measurementArea, &WimaMeasurementArea::tilesChanged, [this] {
this->_nemoInterface.setTileData(this->_measurementArea.tileData());
});
connect(&this->_serviceArea, &WimaArea::pathChanged, [this] {
this->_sAreaChanged = true;
this->setNeedsUpdate(true);
});
connect(&this->_serviceArea, &WimaServiceArea::depotChanged, [this] {
this->_sAreaChanged = true;
this->setNeedsUpdate(true);
......@@ -52,6 +57,11 @@ WimaPlaner::WimaPlaner(QObject *parent)
_autoLoadTimer.setSingleShot(true);
_autoLoadTimer.start(300);
#endif
// NemoInterface
connect(&this->_nemoInterface, &NemoInterface::progressChanged, [this] {
this->_measurementArea.setProgress(this->_nemoInterface.progress());
});
}
PlanMasterController *WimaPlaner::masterController() {
......@@ -95,6 +105,8 @@ QGeoCoordinate WimaPlaner::joinedAreaCenter() const {
WimaBridge *WimaPlaner::wimaBridge() { return _wimaBridge; }
NemoInterface *WimaPlaner::nemoInterface() { return &_nemoInterface; }
void WimaPlaner::setMasterController(PlanMasterController *masterC) {
_masterController = masterC;
emit masterControllerChanged();
......
......@@ -14,6 +14,8 @@
#include "Geometry/WimaServiceAreaData.h"
#include "WimaPlanData.h"
#include "Snake/NemoInterface.h"
#include "JsonHelper.h"
class MissionController;
......@@ -45,6 +47,7 @@ public:
Q_PROPERTY(QGeoCoordinate joinedAreaCenter READ joinedAreaCenter CONSTANT)
Q_PROPERTY(WimaBridge *wimaBridge READ wimaBridge WRITE setWimaBridge NOTIFY
wimaBridgeChanged)
Q_PROPERTY(NemoInterface *nemoInterface READ nemoInterface CONSTANT)
Q_PROPERTY(bool synchronized READ synchronized NOTIFY synchronizedChanged)
Q_PROPERTY(bool needsUpdate READ needsUpdate NOTIFY needsUpdateChanged)
......@@ -59,6 +62,7 @@ public:
QString fileExtension(void) const;
QGeoCoordinate joinedAreaCenter(void) const;
WimaBridge *wimaBridge(void);
NemoInterface *nemoInterface(void);
bool synchronized();
bool needsUpdate();
......@@ -161,4 +165,6 @@ private:
QTimer _autoLoadTimer; // timer to auto load mission after some time, prevents
// seg. faults
#endif
NemoInterface _nemoInterface;
};
......@@ -110,25 +110,39 @@ Item {
// Add Snake tiles to the map
Component {
id: tileComponent
MapPolygon {
color: "transparent"
opacity: 1
border.color: "black"
border.width: 1
MapPolygon{
path: []
opacity: 0.6
z: 2
}
}
Repeater {
id: progressRepeater
property bool enable: areaItem.showTiles.value
model: enable ? areaItem.tiles : 0
function getColor(i) {
var progress = areaItem.progress[i]
if (progress < 25)
return "transparent"
if (progress < 50)
return "orange"
if (progress < 75)
return "yellow"
if (progress < 100)
return "greenyellow"
return "limegreen"
}
Item{
property var _tileComponent
function addVisuals() {
_tileComponent = tileComponent.createObject(map)
map.addMapItem(_tileComponent)
_tileComponent.path = object.path
_tileComponent.color = progressRepeater.getColor(index)
}
function removeVisuals() {
......
......@@ -155,7 +155,7 @@ Rectangle {
anchors.left: logoRow.right
anchors.right: uploadButton.visible ? uploadButton.left : parent.right
columnSpacing: 0
columns: 3
columns: 4
GridLayout {
columns: 8
......@@ -252,7 +252,7 @@ Rectangle {
rowSpacing: _rowSpacing
columnSpacing: _labelToValueSpacing
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
visible: _batteryInfoAvailable
// visible: _batteryInfoAvailable
QGCLabel {
text: qsTr("Battery")
......@@ -268,7 +268,7 @@ Rectangle {
}
Item { width: 1; height: 1 }
/*
/*
FIXME: Swap point display is currently hidden since the code which calcs it doesn't work correctly
QGCLabel { text: qsTr("Swap waypoint:"); font.pointSize: _dataFontSize; }
QGCLabel {
......@@ -278,6 +278,72 @@ Rectangle {
}
*/
}
GridLayout {
columns: 3
rowSpacing: _rowSpacing
columnSpacing: _labelToValueSpacing
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
QGCLabel {
text: qsTr("ROS")
Layout.columnSpan: 3
font.pointSize: ScreenTools.smallFontPointSize
}
QGCCheckBox {
id: enableCheckbox
property var nemo: wimaPlaner ? wimaPlaner.nemoInterface : undefined
text: qsTr("Enable")
checked: nemo ? nemo.running : false
onCheckedChanged: {
if (nemo){
if (checked){
nemo.start()
} else {
nemo.stop()
}
checked = Qt.binding(function(){return nemo.running})
}
}
Layout.minimumWidth: _mediumValueWidth
}
QGCLabel {
property var nemo: wimaPlaner ? wimaPlaner.nemoInterface : undefined
text: nemo ? nemo.statusString : ""
font.pointSize: _dataFontSize
Layout.minimumWidth: _mediumValueWidth
visible: enableCheckbox.checked
Layout.columnSpan: 2
}
QGCCheckBox {
property var nemo: wimaPlaner ? wimaPlaner.nemoInterface : undefined
text: qsTr("Lock Progress")
checked: nemo ? nemo.lockProgress : false
visible: enableCheckbox.checked
onCheckedChanged: {
if (nemo){
if (checked){
nemo.lockProgress = true
} else {
nemo.lockProgress = false
}
checked = Qt.binding(function(){return nemo.lockProgress})
}
}
Layout.minimumWidth: _mediumValueWidth
}
}
}
QGCButton {
......
......@@ -54,6 +54,7 @@ QGCView {
property bool _airspaceEnabled: QGroundControl.airmapSupported ? (QGroundControl.settingsManager.airMapSettings.enableAirMap.rawValue && QGroundControl.airspaceManager.connected): false
property var _wimaPlaner: wimaPlaner
property var _nemo: wimaPlaner.nemoInterface
property var _planMasterController: masterController
property var _missionController: _planMasterController.missionController
property var _visualItems: _missionController.visualItems
......@@ -702,6 +703,10 @@ QGCView {
name: qsTr("Update"),
iconSource: "/res/calculator.png"
},
{
name: qsTr("Publish"),
iconSource: "/res/calculator.png"
},
{
name: qsTr("Center"),
iconSource: "/qmlimages/MapCenter.svg",
......@@ -731,10 +736,13 @@ QGCView {
case 4:
wimaPlaner.update();
break
case 6:
editorMap.zoomLevel += 0.5
case 5:
_nemo.publishTileData();
break
case 7:
editorMap.zoomLevel += 0.5
break
case 8:
editorMap.zoomLevel -= 0.5
break
}
......
......@@ -4,61 +4,72 @@
#include <vector>
namespace ros_bridge {
//! @brief Namespace containing classes and methodes ros message generation.
namespace messages {
//! @brief Namespace containing classes and methodes for geometry_msgs generation.
//! @brief Namespace containing classes and methodes for geometry_msgs
//! generation.
namespace nemo_msgs {
//! @brief Namespace containing methodes for geometry_msgs/Point32 message generation.
//! @brief Namespace containing methodes for geometry_msgs/Point32 message
//! generation.
namespace progress {
std::string messageType();
//! @brief C++ representation of nemo_msgs/Progress message
template <class IntType = long, template <class, class...> class ContainterType = std::vector>
class GenericProgress{
template <class IntType = long,
template <class, class...> class ContainterType = std::vector>
class GenericProgress {
public:
GenericProgress() {}
GenericProgress(const ContainterType<IntType> &progress) : _progress(progress){}
GenericProgress(const GenericProgress &p) : _progress(p.progress()){}
GenericProgress() {}
GenericProgress(const ContainterType<IntType> &progress)
: _progress(progress) {}
GenericProgress(const GenericProgress &p) : _progress(p.progress()) {}
virtual const ContainterType<IntType> &progress(void) const {
return _progress;
}
virtual ContainterType<IntType> &progress(void) { return _progress; }
virtual const ContainterType<IntType> &progress(void) const {return _progress;}
virtual ContainterType<IntType> &progress(void) {return _progress;}
bool operator==(const GenericProgress &other) const {
return this->_progress == other._progress;
}
bool operator!=(const GenericProgress &other) const {
return !this->operator==(other);
}
protected:
ContainterType<IntType> _progress;
ContainterType<IntType> _progress;
};
typedef GenericProgress<> Progress;
template <class ProgressType>
bool toJson(const ProgressType &p, rapidjson::Value &value, rapidjson::Document::AllocatorType &allocator)
{
rapidjson::Value jProgress(rapidjson::kArrayType);
for(unsigned long i=0; i < std::uint64_t(p.progress().size()); ++i){
jProgress.PushBack(rapidjson::Value().SetInt(std::int32_t(p.progress()[i])), allocator);
}
value.AddMember("progress", jProgress, allocator);
return true;
bool toJson(const ProgressType &p, rapidjson::Value &value,
rapidjson::Document::AllocatorType &allocator) {
rapidjson::Value jProgress(rapidjson::kArrayType);
for (unsigned long i = 0; i < std::uint64_t(p.progress().size()); ++i) {
jProgress.PushBack(rapidjson::Value().SetInt(std::int32_t(p.progress()[i])),
allocator);
}
value.AddMember("progress", jProgress, allocator);
return true;
}
template <class ProgressType>
bool fromJson(const rapidjson::Value &value, ProgressType &p)
{
if (!value.HasMember("progress") || !value["progress"].IsArray()){
assert(false);
return false;
}
bool fromJson(const rapidjson::Value &value, ProgressType &p) {
if (!value.HasMember("progress") || !value["progress"].IsArray()) {
assert(false);
return false;
}
const auto& jsonProgress = value["progress"];
unsigned long sz = jsonProgress.Size();
p.progress().clear();
p.progress().reserve(sz);
for (unsigned long i=0; i < sz; ++i)
p.progress().push_back(std::int32_t(jsonProgress[i].GetInt()));
return true;
const auto &jsonProgress = value["progress"];
unsigned long sz = jsonProgress.Size();
p.progress().clear();
p.progress().reserve(sz);
for (unsigned long i = 0; i < sz; ++i)
p.progress().push_back(std::int32_t(jsonProgress[i].GetInt()));
return true;
}
} // namespace progress
......
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