Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
f060c3b7
Commit
f060c3b7
authored
Sep 29, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wima controller mod
parent
af4b4687
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
508 additions
and
463 deletions
+508
-463
QmlObjectListModel.cc
src/QmlControls/QmlObjectListModel.cc
+200
-202
QmlObjectListModel.h
src/QmlControls/QmlObjectListModel.h
+3
-0
WimaMeasurementArea.cc
src/Wima/Geometry/WimaMeasurementArea.cc
+77
-36
WimaMeasurementArea.h
src/Wima/Geometry/WimaMeasurementArea.h
+19
-5
WimaMeasurementAreaData.cc
src/Wima/Geometry/WimaMeasurementAreaData.cc
+32
-20
WimaMeasurementAreaData.h
src/Wima/Geometry/WimaMeasurementAreaData.h
+11
-6
NemoInterface.cpp
src/Wima/Snake/NemoInterface.cpp
+53
-21
NemoInterface.h
src/Wima/Snake/NemoInterface.h
+4
-2
WimaController.cc
src/Wima/WimaController.cc
+101
-131
WimaController.h
src/Wima/WimaController.h
+8
-40
No files found.
src/QmlControls/QmlObjectListModel.cc
View file @
f060c3b7
This diff is collapsed.
Click to expand it.
src/QmlControls/QmlObjectListModel.h
View file @
f060c3b7
...
@@ -51,6 +51,9 @@ public:
...
@@ -51,6 +51,9 @@ public:
}
}
QList
<
QObject
*>
*
objectList
()
{
return
&
_objectList
;
}
QList
<
QObject
*>
*
objectList
()
{
return
&
_objectList
;
}
bool
operator
==
(
const
QmlObjectListModel
&
other
);
bool
operator
!=
(
const
QmlObjectListModel
&
other
);
/// Calls deleteLater on all items and this itself.
/// Calls deleteLater on all items and this itself.
void
deleteListAndContents
();
void
deleteListAndContents
();
...
...
src/Wima/Geometry/WimaMeasurementArea.cc
View file @
f060c3b7
...
@@ -9,6 +9,38 @@
...
@@ -9,6 +9,38 @@
#define SNAKE_MAX_TILES 1000
#define SNAKE_MAX_TILES 1000
#endif
#endif
TileData
::
TileData
()
:
tiles
(
this
)
{}
TileData
::~
TileData
()
{
tiles
.
clearAndDeleteContents
();
}
TileData
&
TileData
::
operator
=
(
const
TileData
&
other
)
{
this
->
tiles
.
clearAndDeleteContents
();
for
(
std
::
size_t
i
=
0
;
i
<
std
::
size_t
(
other
.
tiles
.
count
());
++
i
)
{
const
auto
*
obj
=
other
.
tiles
.
get
(
i
);
const
auto
*
tile
=
qobject_cast
<
const
SnakeTile
*>
(
obj
);
if
(
tile
!=
nullptr
)
{
this
->
tiles
.
append
(
new
SnakeTile
(
*
tile
,
this
));
}
else
{
qWarning
(
"TileData::operator=: nullptr"
);
}
}
this
->
tileCenterPoints
=
other
.
tileCenterPoints
;
return
*
this
;
}
void
TileData
::
clear
()
{
this
->
tiles
.
clearAndDeleteContents
();
this
->
tileCenterPoints
.
clear
();
}
size_t
TileData
::
size
()
const
{
if
(
tiles
.
count
()
==
tileCenterPoints
.
size
())
{
return
tiles
.
count
();
}
else
{
return
0
;
}
}
const
char
*
WimaMeasurementArea
::
settingsGroup
=
"MeasurementArea"
;
const
char
*
WimaMeasurementArea
::
settingsGroup
=
"MeasurementArea"
;
const
char
*
WimaMeasurementArea
::
tileHeightName
=
"TileHeight"
;
const
char
*
WimaMeasurementArea
::
tileHeightName
=
"TileHeight"
;
const
char
*
WimaMeasurementArea
::
tileWidthName
=
"TileWidth"
;
const
char
*
WimaMeasurementArea
::
tileWidthName
=
"TileWidth"
;
...
@@ -39,8 +71,7 @@ WimaMeasurementArea::WimaMeasurementArea(QObject *parent)
...
@@ -39,8 +71,7 @@ WimaMeasurementArea::WimaMeasurementArea(QObject *parent)
this
/* QObject parent */
)),
this
/* QObject parent */
)),
_showTiles
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
showTilesName
],
_showTiles
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
showTilesName
],
this
/* QObject parent */
)),
this
/* QObject parent */
)),
_pTiles
(
new
QmlObjectListModel
(),
&
tileDeleter
),
_calculating
(
false
),
_calculating
(
false
)
{
_polygonValid
(
false
)
{
init
();
init
();
}
}
...
@@ -64,8 +95,7 @@ WimaMeasurementArea::WimaMeasurementArea(const WimaMeasurementArea &other,
...
@@ -64,8 +95,7 @@ WimaMeasurementArea::WimaMeasurementArea(const WimaMeasurementArea &other,
this
/* QObject parent */
)),
this
/* QObject parent */
)),
_showTiles
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
showTilesName
],
_showTiles
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
showTilesName
],
this
/* QObject parent */
)),
this
/* QObject parent */
)),
_pTiles
(
new
QmlObjectListModel
(),
&
tileDeleter
),
_calculating
(
false
),
_calculating
(
false
)
{
_polygonValid
(
false
)
{
init
();
init
();
}
}
...
@@ -81,9 +111,7 @@ operator=(const WimaMeasurementArea &other) {
...
@@ -81,9 +111,7 @@ operator=(const WimaMeasurementArea &other) {
return
*
this
;
return
*
this
;
}
}
WimaMeasurementArea
::~
WimaMeasurementArea
()
{
WimaMeasurementArea
::~
WimaMeasurementArea
()
{}
this
->
_pTiles
->
clearAndDeleteContents
();
}
QString
WimaMeasurementArea
::
mapVisualQML
()
const
{
QString
WimaMeasurementArea
::
mapVisualQML
()
const
{
return
"WimaMeasurementAreaMapVisual.qml"
;
return
"WimaMeasurementAreaMapVisual.qml"
;
...
@@ -105,10 +133,20 @@ Fact *WimaMeasurementArea::minTransectLength() { return &_minTransectLength; }
...
@@ -105,10 +133,20 @@ Fact *WimaMeasurementArea::minTransectLength() { return &_minTransectLength; }
Fact
*
WimaMeasurementArea
::
showTiles
()
{
return
&
_showTiles
;
}
Fact
*
WimaMeasurementArea
::
showTiles
()
{
return
&
_showTiles
;
}
QmlObjectListModel
*
WimaMeasurementArea
::
tiles
()
{
return
this
->
_pTiles
.
get
();
}
QmlObjectListModel
*
WimaMeasurementArea
::
tiles
()
{
return
&
this
->
_tileData
.
tiles
;
}
const
QmlObjectListModel
*
WimaMeasurementArea
::
tiles
()
const
{
const
QmlObjectListModel
*
WimaMeasurementArea
::
tiles
()
const
{
return
this
->
_pTiles
.
get
();
return
&
this
->
_tileData
.
tiles
;
}
const
QVariantList
&
WimaMeasurementArea
::
tileCenterPoints
()
const
{
return
this
->
_tileData
.
tileCenterPoints
;
}
const
TileData
&
WimaMeasurementArea
::
tileData
()
const
{
return
this
->
_tileData
;
}
}
int
WimaMeasurementArea
::
maxTiles
()
const
{
return
SNAKE_MAX_TILES
;
}
int
WimaMeasurementArea
::
maxTiles
()
const
{
return
SNAKE_MAX_TILES
;
}
...
@@ -181,8 +219,8 @@ bool WimaMeasurementArea::loadFromJson(const QJsonObject &json,
...
@@ -181,8 +219,8 @@ bool WimaMeasurementArea::loadFromJson(const QJsonObject &json,
}
}
//!
//!
//! \brief WimaMeasurementArea::doUpdate
//! \brief WimaMeasurementArea::doUpdate
//! \pre WimaMeasurementArea::deferUpdate must be called first, don't call
this
//! \pre WimaMeasurementArea::deferUpdate must be called first, don't call
//! function directly!
//!
this
function directly!
void
WimaMeasurementArea
::
doUpdate
()
{
void
WimaMeasurementArea
::
doUpdate
()
{
using
namespace
snake
;
using
namespace
snake
;
using
namespace
boost
::
units
;
using
namespace
boost
::
units
;
...
@@ -198,14 +236,10 @@ void WimaMeasurementArea::doUpdate() {
...
@@ -198,14 +236,10 @@ void WimaMeasurementArea::doUpdate() {
long
(
std
::
ceil
(
estNumTiles
.
value
()))
<=
SNAKE_MAX_TILES
&&
long
(
std
::
ceil
(
estNumTiles
.
value
()))
<=
SNAKE_MAX_TILES
&&
this
->
count
()
>=
3
&&
this
->
isSimplePolygon
())
{
this
->
count
()
>=
3
&&
this
->
isSimplePolygon
())
{
this
->
_calculating
=
true
;
this
->
_calculating
=
true
;
if
(
!
this
->
_polygonValid
)
{
auto
polygon
=
this
->
coordinateList
();
this
->
_polygon
=
this
->
coordinateList
();
for
(
auto
&
v
:
polygon
)
{
for
(
auto
&
v
:
this
->
_polygon
)
{
v
.
setAltitude
(
0
);
v
.
setAltitude
(
0
);
}
this
->
_polygonValid
=
true
;
}
}
const
auto
&
polygon
=
this
->
_polygon
;
const
auto
minArea
=
const
auto
minArea
=
this
->
_minTileArea
.
rawValue
().
toDouble
()
*
si
::
meter
*
si
::
meter
;
this
->
_minTileArea
.
rawValue
().
toDouble
()
*
si
::
meter
*
si
::
meter
;
auto
*
th
=
this
->
thread
();
auto
*
th
=
this
->
thread
();
...
@@ -213,35 +247,44 @@ void WimaMeasurementArea::doUpdate() {
...
@@ -213,35 +247,44 @@ void WimaMeasurementArea::doUpdate() {
#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
TilesPtr
pTiles
(
new
QmlObjectListModel
(),
&
tileDeleter
);
DataPtr
pData
(
new
TileData
());
// Convert to ENU system.
QGeoCoordinate
origin
=
polygon
.
first
();
QGeoCoordinate
origin
=
polygon
.
first
();
BoostPolygon
polygonENU
;
BoostPolygon
polygonENU
;
areaToEnu
(
origin
,
polygon
,
polygonENU
);
areaToEnu
(
origin
,
polygon
,
polygonENU
);
std
::
vector
<
BoostPolygon
>
tilesENU
;
std
::
vector
<
BoostPolygon
>
tilesENU
;
BoundingBox
bbox
;
BoundingBox
bbox
;
std
::
string
errorString
;
std
::
string
errorString
;
// Generate tiles.
if
(
snake
::
tiles
(
polygonENU
,
height
,
width
,
minArea
,
tilesENU
,
bbox
,
if
(
snake
::
tiles
(
polygonENU
,
height
,
width
,
minArea
,
tilesENU
,
bbox
,
errorString
))
{
errorString
))
{
// Convert to geo system.
for
(
const
auto
&
t
:
tilesENU
)
{
for
(
const
auto
&
t
:
tilesENU
)
{
auto
geoTile
=
new
SnakeTile
(
p
Tiles
.
get
());
auto
geoTile
=
new
SnakeTile
(
p
Data
.
get
());
for
(
const
auto
&
v
:
t
.
outer
())
{
for
(
const
auto
&
v
:
t
.
outer
())
{
QGeoCoordinate
geoVertex
;
QGeoCoordinate
geoVertex
;
fromENU
(
origin
,
v
,
geoVertex
);
fromENU
(
origin
,
v
,
geoVertex
);
geoTile
->
push_back
(
geoVertex
);
geoTile
->
push_back
(
geoVertex
);
}
}
pTiles
->
append
(
geoTile
);
pData
->
tiles
.
append
(
geoTile
);
// Calculate center.
snake
::
BoostPoint
center
;
snake
::
polygonCenter
(
t
,
center
);
QGeoCoordinate
geoCenter
;
fromENU
(
origin
,
center
,
geoCenter
);
pData
->
tileCenterPoints
.
append
(
QVariant
::
fromValue
(
geoCenter
));
}
}
}
}
p
Tiles
->
moveToThread
(
th
);
p
Data
->
moveToThread
(
th
);
#ifdef SNAKE_SHOW_TIME
#ifdef SNAKE_SHOW_TIME
qDebug
()
qDebug
()
<<
"WimaMeasurementArea::doUpdate concurrent update execution "
<<
"WimaMeasurementArea::doUpdate concurrent update execution
time: "
"
time: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
high_resolution_clock
::
now
()
-
start
)
std
::
chrono
::
high_resolution_clock
::
now
()
-
start
)
.
count
()
.
count
()
<<
" ms"
;
<<
" ms"
;
#endif
#endif
return
p
Tiles
;
return
p
Data
;
});
// QtConcurrent::run()
});
// QtConcurrent::run()
this
->
_watcher
.
setFuture
(
future
);
this
->
_watcher
.
setFuture
(
future
);
...
@@ -259,8 +302,8 @@ void WimaMeasurementArea::deferUpdate() {
...
@@ -259,8 +302,8 @@ void WimaMeasurementArea::deferUpdate() {
if
(
this
->
_timer
.
isActive
())
{
if
(
this
->
_timer
.
isActive
())
{
this
->
_timer
.
stop
();
this
->
_timer
.
stop
();
}
}
if
(
this
->
_
pTiles
->
count
()
>
0
)
{
if
(
this
->
_
tileData
.
size
()
>
0
)
{
this
->
_
pTiles
->
clearAndDeleteContents
();
this
->
_
tileData
.
clear
();
emit
this
->
tilesChanged
();
emit
this
->
tilesChanged
();
}
}
this
->
_timer
.
start
(
100
);
this
->
_timer
.
start
(
100
);
...
@@ -270,10 +313,10 @@ void WimaMeasurementArea::storeTiles() {
...
@@ -270,10 +313,10 @@ void WimaMeasurementArea::storeTiles() {
#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
this
->
_
pTiles
=
this
->
_watcher
.
result
();
this
->
_
tileData
=
*
this
->
_watcher
.
result
();
this
->
_calculating
=
false
;
this
->
_calculating
=
false
;
emit
this
// This is expensive. Drawing tiles is expensive too.
->
tilesChanged
();
// This is expensive. Drawing tiles is expensive too.
emit
this
->
tilesChanged
();
#ifdef SNAKE_SHOW_TIME
#ifdef SNAKE_SHOW_TIME
qDebug
()
<<
"WimaMeasurementArea::storeTiles() execution time: "
qDebug
()
<<
"WimaMeasurementArea::storeTiles() execution time: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
...
@@ -293,8 +336,6 @@ void WimaMeasurementArea::init() {
...
@@ -293,8 +336,6 @@ void WimaMeasurementArea::init() {
&
WimaMeasurementArea
::
deferUpdate
);
&
WimaMeasurementArea
::
deferUpdate
);
connect
(
this
,
&
WimaArea
::
pathChanged
,
this
,
connect
(
this
,
&
WimaArea
::
pathChanged
,
this
,
&
WimaMeasurementArea
::
deferUpdate
);
&
WimaMeasurementArea
::
deferUpdate
);
connect
(
this
,
&
WimaArea
::
pathChanged
,
[
this
]
{
this
->
_polygonValid
=
false
;
});
this
->
_timer
.
setSingleShot
(
true
);
this
->
_timer
.
setSingleShot
(
true
);
connect
(
&
this
->
_timer
,
&
QTimer
::
timeout
,
this
,
connect
(
&
this
->
_timer
,
&
QTimer
::
timeout
,
this
,
&
WimaMeasurementArea
::
doUpdate
);
&
WimaMeasurementArea
::
doUpdate
);
...
...
src/Wima/Geometry/WimaMeasurementArea.h
View file @
f060c3b7
...
@@ -8,6 +8,20 @@
...
@@ -8,6 +8,20 @@
#include "SettingsFact.h"
#include "SettingsFact.h"
class
TileData
:
public
QObject
{
public:
QmlObjectListModel
tiles
;
QVariantList
tileCenterPoints
;
TileData
();
~
TileData
();
TileData
&
operator
=
(
const
TileData
&
other
);
void
clear
();
std
::
size_t
size
()
const
;
};
class
WimaMeasurementArea
:
public
WimaArea
{
class
WimaMeasurementArea
:
public
WimaArea
{
Q_OBJECT
Q_OBJECT
public:
public:
...
@@ -38,6 +52,8 @@ public:
...
@@ -38,6 +52,8 @@ public:
Fact
*
showTiles
();
Fact
*
showTiles
();
QmlObjectListModel
*
tiles
();
QmlObjectListModel
*
tiles
();
const
QmlObjectListModel
*
tiles
()
const
;
const
QmlObjectListModel
*
tiles
()
const
;
const
QVariantList
&
tileCenterPoints
()
const
;
// List of QGeoCoordinate
const
TileData
&
tileData
()
const
;
int
maxTiles
()
const
;
int
maxTiles
()
const
;
bool
ready
()
const
;
bool
ready
()
const
;
...
@@ -86,10 +102,8 @@ private:
...
@@ -86,10 +102,8 @@ private:
// Tile stuff.
// Tile stuff.
QTimer
_timer
;
QTimer
_timer
;
using
TilesPtr
=
std
::
shared_ptr
<
QmlObjectListModel
>
;
using
DataPtr
=
std
::
shared_ptr
<
TileData
>
;
TilesPtr
_pTiles
;
TileData
_tileData
;
QList
<
QGeoCoordinate
>
_polygon
;
QFutureWatcher
<
DataPtr
>
_watcher
;
QFutureWatcher
<
TilesPtr
>
_watcher
;
bool
_calculating
;
bool
_calculating
;
bool
_polygonValid
;
};
};
src/Wima/Geometry/WimaMeasurementAreaData.cc
View file @
f060c3b7
...
@@ -44,33 +44,45 @@ operator=(const WimaMeasurementArea &other) {
...
@@ -44,33 +44,45 @@ operator=(const WimaMeasurementArea &other) {
QString
WimaMeasurementAreaData
::
type
()
const
{
return
this
->
typeString
;
}
QString
WimaMeasurementAreaData
::
type
()
const
{
return
this
->
typeString
;
}
QmlObjectListModel
*
WimaMeasurementAreaData
::
tiles
()
{
return
&
this
->
_tileData
.
tiles
;
}
const
QmlObjectListModel
*
WimaMeasurementAreaData
::
tiles
()
const
{
return
&
this
->
_tileData
.
tiles
;
}
const
QVariantList
&
WimaMeasurementAreaData
::
tileCenterPoints
()
const
{
return
this
->
_tileData
.
tileCenterPoints
;
}
QVariantList
&
WimaMeasurementAreaData
::
tileCenterPoints
()
{
return
this
->
_tileData
.
tileCenterPoints
;
}
const
TileData
&
WimaMeasurementAreaData
::
tileData
()
const
{
return
this
->
tileData
();
}
TileData
&
WimaMeasurementAreaData
::
tileData
()
{
return
this
->
tileData
();
}
const
QVector
<
int
>
&
WimaMeasurementAreaData
::
progress
()
const
{
return
this
->
_progress
;
}
QVector
<
int
>
&
WimaMeasurementAreaData
::
progress
()
{
return
this
->
_progress
;
}
void
WimaMeasurementAreaData
::
assign
(
const
WimaMeasurementAreaData
&
other
)
{
void
WimaMeasurementAreaData
::
assign
(
const
WimaMeasurementAreaData
&
other
)
{
WimaAreaData
::
assign
(
other
);
WimaAreaData
::
assign
(
other
);
this
->
tiles
.
clearAndDeleteContents
();
this
->
_tileData
=
other
.
_tileData
;
for
(
std
::
size_t
i
=
0
;
i
<
std
::
size_t
(
other
.
tiles
.
count
());
++
i
)
{
this
->
_progress
=
other
.
_progress
;
const
auto
*
obj
=
other
.
tiles
.
get
(
i
);
const
auto
*
tile
=
qobject_cast
<
const
SnakeTile
*>
(
obj
);
if
(
tile
!=
nullptr
)
{
this
->
tiles
.
append
(
new
SnakeTile
(
*
tile
,
this
));
}
else
{
qWarning
()
<<
"WimaMeasurementAreaData::assign(): type cast failed."
;
}
}
}
}
void
WimaMeasurementAreaData
::
assign
(
const
WimaMeasurementArea
&
other
)
{
void
WimaMeasurementAreaData
::
assign
(
const
WimaMeasurementArea
&
other
)
{
WimaAreaData
::
assign
(
other
);
WimaAreaData
::
assign
(
other
);
this
->
tiles
.
clearAndDeleteContents
();
if
(
other
.
ready
())
{
if
(
other
.
ready
())
{
for
(
std
::
size_t
i
=
0
;
i
<
std
::
size_t
(
other
.
tiles
()
->
count
());
++
i
)
{
this
->
_tileData
=
other
.
tileData
();
const
auto
*
obj
=
other
.
tiles
()
->
get
(
i
);
qWarning
()
<<
"WimaMeasurementAreaData: add progress copy here."
;
const
auto
*
tile
=
qobject_cast
<
const
SnakeTile
*>
(
obj
);
if
(
tile
!=
nullptr
)
{
this
->
tiles
.
append
(
new
SnakeTile
(
*
tile
,
this
));
}
else
{
qWarning
()
<<
"WimaMeasurementAreaData::assign(): type cast failed."
;
}
}
}
else
{
}
else
{
qWarning
()
qWarning
()
<<
"WimaMeasurementAreaData::assign(): WimaMeasurementArea not ready."
;
<<
"WimaMeasurementAreaData::assign(): WimaMeasurementArea not ready."
;
...
...
src/Wima/Geometry/WimaMeasurementAreaData.h
View file @
f060c3b7
...
@@ -23,17 +23,22 @@ public:
...
@@ -23,17 +23,22 @@ public:
return
new
WimaMeasurementAreaData
(
*
this
);
return
new
WimaMeasurementAreaData
(
*
this
);
}
}
static
const
char
*
typeString
;
QmlObjectListModel
*
tiles
();
const
QmlObjectListModel
*
tiles
()
const
;
signals:
const
QVariantList
&
tileCenterPoints
()
const
;
QVariantList
&
tileCenterPoints
();
const
TileData
&
tileData
()
const
;
TileData
&
tileData
();
const
QVector
<
int
>
&
progress
()
const
;
QVector
<
int
>
&
progress
();
public
slots
:
static
const
char
*
typeString
;
protected:
protected:
void
assign
(
const
WimaMeasurementAreaData
&
other
);
void
assign
(
const
WimaMeasurementAreaData
&
other
);
void
assign
(
const
WimaMeasurementArea
&
other
);
void
assign
(
const
WimaMeasurementArea
&
other
);
private:
private:
// see WimaMeasurementArea.h for explanation
TileData
_tileData
;
Q
mlObjectListModel
tile
s
;
Q
Vector
<
int
>
_progres
s
;
};
};
src/Wima/Snake/NemoInterface.cpp
View file @
f060c3b7
...
@@ -12,6 +12,9 @@
...
@@ -12,6 +12,9 @@
#include "QNemoHeartbeat.h"
#include "QNemoHeartbeat.h"
#include "QNemoProgress.h"
#include "QNemoProgress.h"
#include "Wima/Geometry/WimaMeasurementArea.h"
#include "Wima/Snake/SnakeTile.h"
#include "Wima/Snake/snake.h"
#include "ros_bridge/include/messages/geographic_msgs/geopoint.h"
#include "ros_bridge/include/messages/geographic_msgs/geopoint.h"
#include "ros_bridge/include/messages/jsk_recognition_msgs/polygon_array.h"
#include "ros_bridge/include/messages/jsk_recognition_msgs/polygon_array.h"
...
@@ -39,8 +42,9 @@ public:
...
@@ -39,8 +42,9 @@ public:
void
start
();
void
start
();
void
stop
();
void
stop
();
void
setTilesENU
(
const
SnakeTilesLocal
&
tilesENU
);
void
setTileData
(
const
TileData
&
tileData
);
void
setENUOrigin
(
const
QGeoCoordinate
&
ENUOrigin
);
bool
hasTileData
(
const
TileData
&
tileData
)
const
;
NemoInterface
::
NemoStatus
status
();
NemoInterface
::
NemoStatus
status
();
QVector
<
int
>
progress
();
QVector
<
int
>
progress
();
...
@@ -69,6 +73,9 @@ private:
...
@@ -69,6 +73,9 @@ private:
TimePoint
nextTimeout
;
TimePoint
nextTimeout
;
mutable
std
::
shared_timed_mutex
heartbeatMutex
;
mutable
std
::
shared_timed_mutex
heartbeatMutex
;
// Not protected data.
TileData
tileData
;
// Internals
// Internals
bool
running
;
bool
running
;
std
::
atomic_bool
topicServiceSetupDone
;
std
::
atomic_bool
topicServiceSetupDone
;
...
@@ -113,24 +120,49 @@ void NemoInterface::Impl::start() { this->running = true; }
...
@@ -113,24 +120,49 @@ void NemoInterface::Impl::start() { this->running = true; }
void
NemoInterface
::
Impl
::
stop
()
{
this
->
running
=
false
;
}
void
NemoInterface
::
Impl
::
stop
()
{
this
->
running
=
false
;
}
void
NemoInterface
::
Impl
::
setTilesENU
(
const
SnakeTilesLocal
&
tilesENU
)
{
void
NemoInterface
::
Impl
::
setTileData
(
const
TileData
&
tileData
)
{
UniqueLock
lk
(
this
->
tilesENUMutex
);
this
->
tileData
=
tileData
;
this
->
tilesENU
=
tilesENU
;
if
(
tileData
.
tiles
.
count
()
>
0
)
{
lk
.
unlock
();
std
::
lock
(
this
->
ENUOriginMutex
,
this
->
tilesENUMutex
);
if
(
this
->
running
&&
this
->
topicServiceSetupDone
)
{
UniqueLock
lk1
(
this
->
ENUOriginMutex
,
std
::
adopt_lock
);
lk
.
lock
();
UniqueLock
lk2
(
this
->
tilesENUMutex
,
std
::
adopt_lock
);
this
->
publishTilesENU
();
const
auto
*
obj
=
tileData
.
tiles
.
get
(
0
);
const
auto
*
tile
=
qobject_cast
<
const
SnakeTile
*>
(
obj
);
if
(
tile
!=
nullptr
)
{
if
(
tile
->
coordinateList
().
size
()
>
0
)
{
this
->
ENUOrigin
=
tile
->
coordinateList
().
first
();
const
auto
&
origin
=
this
->
ENUOrigin
;
this
->
tilesENU
.
polygons
().
clear
();
bool
error
=
false
;
for
(
std
::
size_t
i
=
0
;
i
<
tileData
.
tiles
.
count
();
++
i
)
{
*
obj
=
tileData
.
tiles
.
get
(
i
);
*
tile
=
qobject_cast
<
const
SnakeTile
*>
(
obj
);
if
(
tile
!=
nullptr
)
{
snake
::
BoostPolygon
tileENU
;
snake
::
areaToEnu
(
origin
,
tile
->
coordinateList
(),
tileENU
);
this
->
tilesENU
.
polygons
().
push_back
(
std
::
move
(
tileENU
));
}
else
{
qWarning
()
<<
"NemoInterface::Impl::setTileData(): nullptr."
;
error
=
true
;
break
;
}
}
if
(
!
error
&&
this
->
running
&&
this
->
topicServiceSetupDone
)
{
this
->
publishENUOrigin
();
this
->
publishTilesENU
();
}
else
{
qWarning
()
<<
"NemoInterface::Impl::setTileData(): first tile empty."
;
}
}
else
{
qWarning
()
<<
"NemoInterface::Impl::setTileData(): nullptr."
;
}
}
}
}
}
}
void
NemoInterface
::
Impl
::
setENUOrigin
(
const
QGeoCoordinate
&
ENUOrigin
)
{
bool
NemoInterface
::
Impl
::
hasTileData
(
const
TileData
&
tileData
)
const
{
UniqueLock
lk
(
this
->
ENUOriginMutex
);
return
this
->
tileData
=
tileData
;
this
->
ENUOrigin
=
ENUOrigin
;
lk
.
unlock
();
if
(
this
->
running
&&
this
->
topicServiceSetupDone
)
{
lk
.
lock
();
this
->
publishENUOrigin
();
}
}
}
NemoInterface
::
NemoStatus
NemoInterface
::
Impl
::
status
()
{
NemoInterface
::
NemoStatus
NemoInterface
::
Impl
::
status
()
{
...
@@ -341,12 +373,12 @@ void NemoInterface::start() { this->pImpl->start(); }
...
@@ -341,12 +373,12 @@ void NemoInterface::start() { this->pImpl->start(); }
void
NemoInterface
::
stop
()
{
this
->
pImpl
->
stop
();
}
void
NemoInterface
::
stop
()
{
this
->
pImpl
->
stop
();
}
void
NemoInterface
::
setTilesENU
(
const
SnakeTilesLocal
&
tilesENU
)
{
void
NemoInterface
::
publishTileData
(
const
TileData
&
tileData
)
{
this
->
pImpl
->
setTile
sENU
(
tilesENU
);
this
->
pImpl
->
setTile
Data
(
tileData
);
}
}
void
NemoInterface
::
setENUOrigin
(
const
QGeoCoordinate
&
ENUOrigin
)
{
bool
NemoInterface
::
hasTileData
(
const
TileData
&
tileData
)
const
{
this
->
pImpl
->
setENUOrigin
(
ENUOrigin
);
return
this
->
pImpl
->
hasTileData
(
tileData
);
}
}
NemoInterface
::
NemoStatus
NemoInterface
::
status
()
const
{
NemoInterface
::
NemoStatus
NemoInterface
::
status
()
const
{
...
...
src/Wima/Snake/NemoInterface.h
View file @
f060c3b7
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
#include <memory>
#include <memory>
class
TileData
;
class
NemoInterface
:
public
QObject
{
class
NemoInterface
:
public
QObject
{
Q_OBJECT
Q_OBJECT
class
Impl
;
class
Impl
;
...
@@ -26,8 +28,8 @@ public:
...
@@ -26,8 +28,8 @@ public:
void
start
();
void
start
();
void
stop
();
void
stop
();
void
setTilesENU
(
const
SnakeTilesLocal
&
tilesENU
);
void
publishTileData
(
const
TileData
&
tileData
);
void
setENUOrigin
(
const
QGeoCoordinate
&
ENUOrigin
)
;
bool
hasTileData
(
const
TileData
&
tileData
)
const
;
NemoStatus
status
()
const
;
NemoStatus
status
()
const
;
QVector
<
int
>
progress
()
const
;
QVector
<
int
>
progress
()
const
;
...
...
src/Wima/WimaController.cc
View file @
f060c3b7
This diff is collapsed.
Click to expand it.
src/Wima/WimaController.h
View file @
f060c3b7
...
@@ -6,31 +6,21 @@
...
@@ -6,31 +6,21 @@
#include "QGCMapPolygon.h"
#include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"
#include "QmlObjectListModel.h"
#include "Geometry/WimaArea.h"
//
#include "Geometry/WimaArea.h"
#include "Geometry/WimaCorridor.h"
//
#include "Geometry/WimaCorridor.h"
#include "Geometry/WimaCorridorData.h"
#include "Geometry/WimaCorridorData.h"
#include "Geometry/WimaMeasurementArea.h"
//
#include "Geometry/WimaMeasurementArea.h"
#include "Geometry/WimaMeasurementAreaData.h"
#include "Geometry/WimaMeasurementAreaData.h"
#include "Geometry/WimaServiceArea.h"
//
#include "Geometry/WimaServiceArea.h"
#include "Geometry/WimaServiceAreaData.h"
#include "Geometry/WimaServiceAreaData.h"
#include "WimaPlanData.h"
#include "WimaPlanData.h"
#include "JsonHelper.h"
#include "MissionController.h"
#include "MissionSettingsItem.h"
#include "PlanMasterController.h"
#include "QGCApplication.h"
#include "SettingsFact.h"
#include "SettingsFact.h"
#include "SettingsManager.h"
#include "SimpleMissionItem.h"
#include "SurveyComplexItem.h"
#include "Geometry/GeoPoint3D.h"
#include "Geometry/GeoPoint3D.h"
#include "RoutingThread.h"
#include "Snake/NemoInterface.h"
#include "Snake/NemoInterface.h"
#include "Snake/SnakeThread.h"
#include "Snake/SnakeTiles.h"
#include "Snake/SnakeTilesLocal.h"
#include "WaypointManager/DefaultManager.h"
#include "WaypointManager/DefaultManager.h"
#include "WaypointManager/RTLManager.h"
#include "WaypointManager/RTLManager.h"
...
@@ -89,15 +79,10 @@ public:
...
@@ -89,15 +79,10 @@ public:
nemoStatusStringChanged
)
nemoStatusStringChanged
)
Q_PROPERTY
(
bool
snakeCalcInProgress
READ
snakeCalcInProgress
NOTIFY
Q_PROPERTY
(
bool
snakeCalcInProgress
READ
snakeCalcInProgress
NOTIFY
snakeCalcInProgressChanged
)
snakeCalcInProgressChanged
)
Q_PROPERTY
(
Fact
*
snakeTileWidth
READ
snakeTileWidth
CONSTANT
)
Q_PROPERTY
(
Fact
*
snakeTileHeight
READ
snakeTileHeight
CONSTANT
)
Q_PROPERTY
(
Fact
*
snakeMinTileArea
READ
snakeMinTileArea
CONSTANT
)
Q_PROPERTY
(
Fact
*
snakeLineDistance
READ
snakeLineDistance
CONSTANT
)
Q_PROPERTY
(
Fact
*
snakeMinTransectLength
READ
snakeMinTransectLength
CONSTANT
)
Q_PROPERTY
(
Q_PROPERTY
(
QmlObjectListModel
*
snakeTiles
READ
snakeTiles
NOTIFY
snakeTilesChanged
)
QmlObjectListModel
*
snakeTiles
READ
snakeTiles
NOTIFY
snakeTilesChanged
)
Q_PROPERTY
(
QVariantList
snakeTileCenterPoints
READ
snakeTileCenterPoints
Q_PROPERTY
(
QVariantList
snakeTileCenterPoints
READ
snakeTileCenterPoints
NOTIFY
snakeTile
CenterPoint
sChanged
)
NOTIFY
snakeTilesChanged
)
Q_PROPERTY
(
Q_PROPERTY
(
QVector
<
int
>
nemoProgress
READ
nemoProgress
NOTIFY
nemoProgressChanged
)
QVector
<
int
>
nemoProgress
READ
nemoProgress
NOTIFY
nemoProgressChanged
)
...
@@ -125,11 +110,6 @@ public:
...
@@ -125,11 +110,6 @@ public:
Fact
*
altitude
(
void
);
Fact
*
altitude
(
void
);
// Snake settings facts.
// Snake settings facts.
Fact
*
enableSnake
(
void
)
{
return
&
_enableSnake
;
}
Fact
*
enableSnake
(
void
)
{
return
&
_enableSnake
;
}
Fact
*
snakeTileWidth
(
void
)
{
return
&
_snakeTileWidth
;
}
Fact
*
snakeTileHeight
(
void
)
{
return
&
_snakeTileHeight
;
}
Fact
*
snakeMinTileArea
(
void
)
{
return
&
_snakeMinTileArea
;
}
Fact
*
snakeLineDistance
(
void
)
{
return
&
_snakeLineDistance
;
}
Fact
*
snakeMinTransectLength
(
void
)
{
return
&
_snakeMinTransectLength
;
}
// Snake data.
// Snake data.
QmlObjectListModel
*
snakeTiles
(
void
);
QmlObjectListModel
*
snakeTiles
(
void
);
QVariantList
snakeTileCenterPoints
(
void
);
QVariantList
snakeTileCenterPoints
(
void
);
...
@@ -179,9 +159,6 @@ public:
...
@@ -179,9 +159,6 @@ public: