Commit 40da114d authored by Valentin Platzgummer's avatar Valentin Platzgummer

started to implement new nemo interface

parent 4948045b
......@@ -445,6 +445,10 @@ contains (DEFINES, QGC_ENABLE_PAIRING) {
#
HEADERS += \
src/MeasurementComplexItem/IDArray.h \
src/MeasurementComplexItem/LogicalArray.h \
src/MeasurementComplexItem/TileArray.h \
src/MeasurementComplexItem/TilePtrArray.h \
src/MeasurementComplexItem/geometry/ProgressArray.h \
src/MeasurementComplexItem/geometry/TileDiff.h \
src/MeasurementComplexItem/geometry/geometry.h \
......
#ifndef IDARRAY_H
#define IDARRAY_H
typedef QVector<long> IDArray;
#endif // IDARRAY_H
#ifndef LOGICALARRAY_H
#define LOGICALARRAY_H
typedef QVector<bool> LogicalArray;
#endif // LOGICALARRAY_H
......@@ -15,9 +15,9 @@
#include "GenericSingelton.h"
#include "geometry/MeasurementArea.h"
#include "geometry/geometry.h"
#include "nemo_interface/MeasurementTile.h"
#include "nemo_interface/QNemoHeartbeat.h"
#include "nemo_interface/QNemoProgress.h"
#include "nemo_interface/MeasurementTile.h"
#include "ros_bridge/include/messages/geographic_msgs/geopoint.h"
#include "ros_bridge/include/messages/jsk_recognition_msgs/polygon_array.h"
......@@ -31,7 +31,7 @@
QGC_LOGGING_CATEGORY(NemoInterfaceLog, "NemoInterfaceLog")
#define EVENT_TIMER_INTERVAL 100 // ms
auto static timeoutInterval = std::chrono::milliseconds(3000);
auto constexpr static timeoutInterval = std::chrono::milliseconds(3000);
using ROSBridgePtr = std::unique_ptr<ros_bridge::ROSBridge>;
using JsonDocUPtr = ros_bridge::com_private::JsonDocUPtr;
......@@ -47,15 +47,20 @@ public:
void start();
void stop();
void setTileData(const TileData &tileData);
bool hasTileData(const TileData &tileData) const;
void setAutoPublish(bool ap);
void setHoldProgress(bool hp);
void addTiles(const TilePtrArray &tileArray);
void addTiles(const TileArray &tileArray);
void removeTiles(const IDArray &idArray);
void clearTiles();
TileArray getTiles(const IDArray &idArray);
TileArray getAllTiles();
LogicalArray containsTiles(const IDArray &idArray);
TileArray extractTiles(const IDArray &idArray);
std::size_t size();
bool empty();
void publishTileData();
NemoInterface::STATUS status();
QVector<int> progress();
bool running();
private:
......@@ -63,32 +68,13 @@ private:
void loop();
static STATUS heartbeatToStatus(
const ros_bridge::messages::nemo_msgs::heartbeat::Heartbeat &hb);
//!
//! \brief Publishes tilesENU
//! \pre this->tilesENUMutex must be locked
//!
void publishTilesENU();
//!
//! \brief Publishes ENUOrigin
//! \pre this->ENUOriginMutex must be locked
//!
void publishENUOrigin();
bool setStatus(NemoInterface::STATUS s);
// Data.
SnakeTilesLocal tilesENU;
mutable std::shared_timed_mutex tilesENUMutex;
QGeoCoordinate ENUOrigin;
mutable std::shared_timed_mutex ENUOriginMutex;
QNemoProgress qProgress;
mutable std::shared_timed_mutex progressMutex;
TimePoint nextTimeout;
mutable std::shared_timed_mutex timeoutMutex;
std::atomic<NemoInterface::STATUS> status_;
// Not protected data.
TileData tileData;
// Internals
std::atomic_bool running_;
std::atomic_bool topicServiceSetupDone;
......@@ -170,7 +156,8 @@ void NemoInterface::Impl::setTileData(const TileData &tileData) {
tile = qobject_cast<const MeasurementTile *>(obj);
if (tile != nullptr) {
SnakeTileLocal tileENU;
geometry::areaToEnu(origin, tile->coordinateList(), tileENU.path());
geometry::areaToEnu(origin, tile->coordinateList(),
tileENU.path());
this->tilesENU.polygons().push_back(std::move(tileENU));
} else {
qCDebug(NemoInterfaceLog) << "Impl::setTileData(): nullptr.";
......@@ -443,6 +430,44 @@ void NemoInterface::start() { this->pImpl->start(); }
void NemoInterface::stop() { this->pImpl->stop(); }
void NemoInterface::addTiles(const NemoInterface::TilePtrArray &tileArray) {
this->pImpl -
}
void NemoInterface::addTiles(const TileArray &tileArray) {
TilePtrArray ptrArray;
for (const auto &tile : tileArray) {
ptrArray.append(&tile);
}
addTiles(ptrArray);
}
void NemoInterface::removeTiles(const IDArray &idArray) {
this->pImpl->removeTiles(idArray);
}
void NemoInterface::clearTiles() { this->pImpl->clearTiles(); }
TileArray NemoInterface::getTiles(const IDArray &idArray) {
return this->pImpl->getTiles(idArray);
}
TileArray NemoInterface::getAllTiles() {
return this->pImpl->getTiles(idArray);
}
LogicalArray NemoInterface::containsTiles(const IDArray &idArray) {
return this->pImpl->containsTiles(idArray);
}
TileArray NemoInterface::extractTiles(const IDArray &idArray) {
return this->pImpl->extractTiles(idArray);
}
std::size_t NemoInterface::size() { return this->pImpl->size(); }
bool NemoInterface::empty() { return this->pImpl->empty(); }
void NemoInterface::publishTileData() { this->pImpl->publishTileData(); }
void NemoInterface::requestProgress() {
......
......@@ -5,8 +5,13 @@
#include <memory>
class TileData;
#include "IDArray.h"
#include "LogicalArray.h"
#include "TileArray.h"
#include "TilePtrArray.h"
// Singelton class used to interface measurement devices implementing the nemo
// interface.
class NemoInterface : public QObject {
Q_OBJECT
class Impl;
......@@ -31,23 +36,25 @@ public:
Q_PROPERTY(STATUS 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_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);
void addTiles(const TilePtrArray &tileArray);
void addTiles(const TileArray &tileArray);
void removeTiles(const IDArray &idArray);
void clearTiles();
TileArray getTiles(const IDArray &idArray);
TileArray getAllTiles();
LogicalArray containsTiles(const IDArray &idArray);
TileArray extractTiles(const IDArray &idArray);
std::size_t size();
bool empty();
STATUS status() const;
QString statusString() const;
QVector<int> progress() const;
QString editorQml();
bool running();
......
#ifndef TILEARRAY_H
#define TILEARRAY_H
typedef QVector<MeasurementTile> TileArray;
#endif // TILEARRAY_H
#ifndef TILEPTRARRAY_H
#define TILEPTRARRAY_H
typedef QVector<MeasurementTile *> TilePtrArray;
#endif // TILEPTRARRAY_H
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