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
06e9bcab
Commit
06e9bcab
authored
Oct 18, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp, not compilable
parent
86faa707
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
192 additions
and
156 deletions
+192
-156
CircularGenerator.cpp
src/Wima/Snake/CircularGenerator.cpp
+39
-43
CircularGenerator.h
src/Wima/Snake/CircularGenerator.h
+6
-12
GeneratorBase.h
src/Wima/Snake/GeneratorBase.h
+4
-5
WimaPlanData.cc
src/Wima/WimaPlanData.cc
+106
-80
WimaPlanData.h
src/Wima/WimaPlanData.h
+37
-16
No files found.
src/Wima/Snake/CircularGenerator.cpp
View file @
06e9bcab
#include "CircularGenerator.h"
#include "QGCLoggingCategory.h"
QGC_LOGGING_CATEGORY
(
CircularGeneratorLog
,
"CircularGeneratorLog"
)
#define CLIPPER_SCALE 1000000
#include "Wima/Geometry/GenericCircle.h"
#include "clipper/clipper.hpp"
// Clipper and GenericCircle
using
namespace
ClipperLib
;
template
<>
auto
get
<
0
>
(
const
IntPoint
&
p
)
{
return
p
.
X
;
}
template
<>
auto
get
<
1
>
(
const
IntPoint
&
p
)
{
return
p
.
Y
;
}
namespace
routing
{
bool
circularTransects
(
const
snake
::
FPolygon
&
polygon
,
...
...
@@ -11,18 +18,7 @@ bool circularTransects(const snake::FPolygon &polygon,
snake
::
Length
deltaR
,
snake
::
Angle
deltaAlpha
,
snake
::
Length
minLength
,
snake
::
Transects
&
transects
);
CircularGenerator
::
CircularGenerator
()
:
GeneratorBase
()
{}
CircularGenerator
::
CircularGenerator
(
std
::
shared_ptr
<
GeneratorData
>
par
,
QObject
*
parent
)
:
GeneratorBase
(
parent
)
{
if
(
qobject_cast
<
StandardData
*>
(
par
.
get
())
!=
nullptr
)
{
data_
=
data
;
}
else
{
qCWarning
(
CircularGeneratorLog
)
<<
"CircularGenerator(): CircularGenerator accepts only StandartData."
;
}
}
CircularGenerator
::
CircularGenerator
(
QObject
*
parent
)
:
GeneratorBase
(
parent
)
{}
QString
CircularGenerator
::
editorQML
()
{
return
QStringLiteral
(
"CircularGeneratorEditor.qml"
);
...
...
@@ -38,19 +34,17 @@ QString CircularGenerator::name() {
QString
CircularGenerator
::
abbreviation
()
{
return
QStringLiteral
(
"C. Gen."
);
}
GeneratorBase
::
Generator
CircularGenerator
::
get
()
{}
bool
CircularGenerator
::
setData
(
std
::
shared_ptr
<
GeneratorData
>
data
)
{
if
(
qobject_cast
<
StandardData
*>
(
par
.
get
())
!=
nullptr
)
{
data_
=
data
;
}
else
{
qCWarning
(
CircularGeneratorLog
)
<<
"setData(): CircularGenerator accepts only StandartData."
;
}
bool
CircularGenerator
::
get
(
const
WimaPlanData
&
data
,
GeneratorBase
&
generator
)
{
auto
generator
=
[
depot
,
pPolygon
,
pTiles
,
distance
,
alpha
,
minLength
](
snake
::
Transects
&
transects
)
->
bool
{
bool
value
=
circularTransects
(
*
pPolygon
,
*
pTiles
,
distance
,
alpha
,
minLength
,
transects
);
transects
.
insert
(
transects
.
begin
(),
snake
::
FLineString
{
depot
});
return
value
;
}
;
}
std
::
shared_ptr
<
GeneratorData
>
CircularGenerator
::
data
()
{
return
data_
;
}
bool
circularTransects
(
const
snake
::
FPolygon
&
polygon
,
const
std
::
vector
<
snake
::
FPolygon
>
&
tiles
,
snake
::
Length
deltaR
,
snake
::
Angle
deltaAlpha
,
...
...
@@ -65,12 +59,12 @@ bool circularTransects(const snake::FPolygon &polygon,
std
::
string
error
;
// Check validity.
if
(
!
bg
::
is_valid
(
polygon
,
error
))
{
qCWarning
(
Circular
Survey
Log
)
<<
"circularTransects(): "
"invalid polygon."
;
qCWarning
(
Circular
Survey
Log
)
<<
error
.
c_str
();
qCWarning
(
Circular
Generator
Log
)
<<
"circularTransects(): "
"invalid polygon."
;
qCWarning
(
Circular
Generator
Log
)
<<
error
.
c_str
();
std
::
stringstream
ss
;
ss
<<
bg
::
wkt
(
polygon
);
qCWarning
(
Circular
Survey
Log
)
<<
ss
.
str
().
c_str
();
qCWarning
(
Circular
Generator
Log
)
<<
ss
.
str
().
c_str
();
}
else
{
// Calculate polygon distances and angles.
std
::
vector
<
snake
::
Length
>
distances
;
...
...
@@ -78,7 +72,7 @@ bool circularTransects(const snake::FPolygon &polygon,
std
::
vector
<
snake
::
Angle
>
angles
;
angles
.
reserve
(
polygon
.
outer
().
size
());
//#ifdef DEBUG_CIRCULAR_SURVEY
// qCWarning(Circular
Survey
Log) << "circularTransects():";
// qCWarning(Circular
Generator
Log) << "circularTransects():";
//#endif
for
(
const
auto
&
p
:
polygon
.
outer
())
{
snake
::
Length
distance
=
bg
::
distance
(
origin
,
p
)
*
si
::
meter
;
...
...
@@ -87,11 +81,12 @@ bool circularTransects(const snake::FPolygon &polygon,
alpha
=
alpha
<
0
*
si
::
radian
?
alpha
+
2
*
M_PI
*
si
::
radian
:
alpha
;
angles
.
push_back
(
alpha
);
//#ifdef DEBUG_CIRCULAR_SURVEY
// qCWarning(CircularSurveyLog) << "distances, angles,
// coordinates:"; qCWarning(CircularSurveyLog) <<
// to_string(distance).c_str(); qCWarning(CircularSurveyLog) <<
// to_string(snake::Degree(alpha)).c_str();
// qCWarning(CircularSurveyLog) << "x = " << p.get<0>() << "y = "
// qCWarning(CircularGeneratorLog) << "distances, angles,
// coordinates:"; qCWarning(CircularGeneratorLog) <<
// to_string(distance).c_str(); qCWarning(CircularGeneratorLog)
// << to_string(snake::Degree(alpha)).c_str();
// qCWarning(CircularGeneratorLog) << "x = " << p.get<0>() << "y
// = "
// << p.get<1>();
//#endif
}
...
...
@@ -123,19 +118,20 @@ bool circularTransects(const snake::FPolygon &polygon,
const
auto
nSectors
=
long
(
std
::
round
(((
alpha2
-
alpha1
)
/
deltaAlpha
).
value
()));
//#ifdef DEBUG_CIRCULAR_SURVEY
// qCWarning(Circular
Survey
Log) << "circularTransects(): sector
// parameres:"; qCWarning(Circular
Survey
Log) << "alpha1: " <<
// qCWarning(Circular
Generator
Log) << "circularTransects(): sector
// parameres:"; qCWarning(Circular
Generator
Log) << "alpha1: " <<
// to_string(snake::Degree(alpha1)).c_str();
// qCWarning(Circular
Survey
Log) << "alpha2:
// qCWarning(Circular
Generator
Log) << "alpha2:
// "
// << to_string(snake::Degree(alpha2)).c_str();
// qCWarning(Circular
Survey
Log) << "n: "
// qCWarning(Circular
Generator
Log) << "n: "
// << to_string((alpha2 - alpha1) / deltaAlpha).c_str();
// qCWarning(CircularSurveyLog)
// << "nSectors: " << nSectors; qCWarning(CircularSurveyLog) <<
// "rMin: " << to_string(rMin).c_str(); qCWarning(CircularSurveyLog)
// qCWarning(CircularGeneratorLog)
// << "nSectors: " << nSectors; qCWarning(CircularGeneratorLog) <<
// "rMin: " << to_string(rMin).c_str();
// qCWarning(CircularGeneratorLog)
// << "rMax: " << to_string(rMax).c_str();
// qCWarning(Circular
Survey
Log) << "nTran: " << nTran;
// qCWarning(Circular
Generator
Log) << "nTran: " << nTran;
//#endif
using
ClipperCircle
=
GenericCircle
<
ClipperLib
::
cInt
,
ClipperLib
::
IntPoint
>
;
...
...
@@ -254,7 +250,7 @@ bool circularTransects(const snake::FPolygon &polygon,
}
}
qCWarning
(
Circular
Survey
Log
)
qCWarning
(
Circular
Generator
Log
)
<<
"circularTransects(): transect gen. time: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
high_resolution_clock
::
now
()
-
s1
)
...
...
src/Wima/Snake/CircularGenerator.h
View file @
06e9bcab
...
...
@@ -6,21 +6,15 @@ namespace routing {
class
CircularGenerator
:
public
GeneratorBase
{
Q_OBJECT
public:
CircularGenerator
();
CircularGenerator
(
std
::
shared_ptr
<
GeneratorData
>
par
,
QObject
*
parent
=
nullptr
);
~
CircularGenerator
();
CircularGenerator
(
QObject
*
parent
=
nullptr
)
override
;
virtual
QString
editorQML
();
virtual
QString
mapVisualQML
();
virtual
QString
editorQML
()
override
;
virtual
QString
mapVisualQML
()
override
;
virtual
QString
name
();
virtual
QString
abbreviation
();
virtual
QString
name
()
override
;
virtual
QString
abbreviation
()
override
;
virtual
Generator
get
();
private:
std
::
shared_ptr
<
GeneratorData
>
_data
;
virtual
bool
get
(
const
WimaPlanData
&
data
,
GeneratorBase
&
generator
);
};
}
// namespace routing
src/Wima/Snake/GeneratorBase.h
View file @
06e9bcab
...
...
@@ -5,7 +5,7 @@
#include "snake.h"
#include "
Generator
Data.h"
#include "
Wima/WimaPlan
Data.h"
namespace
routing
{
...
...
@@ -15,7 +15,6 @@ public:
using
Generator
=
std
::
function
<
bool
(
snake
::
Transects
&
)
>
;
explicit
GeneratorBase
(
QObject
*
parent
=
nullptr
);
GeneratorBase
(
std
::
shared_ptr
<
GeneratorData
>
par
,
QObject
*
parent
=
nullptr
);
~
GeneratorBase
();
virtual
QString
editorQML
()
=
0
;
...
...
@@ -24,10 +23,10 @@ public:
virtual
QString
name
()
=
0
;
virtual
QString
abbreviation
()
=
0
;
virtual
Generator
get
(
)
=
0
;
virtual
bool
get
(
const
WimaPlanData
&
data
,
GeneratorBase
&
generator
)
=
0
;
virtual
bool
setData
(
std
::
shared_ptr
<
GeneratorData
>
par
)
=
0
;
v
irtual
std
::
shared_ptr
<
GeneratorData
>
data
()
=
0
;
signals:
v
oid
generatorChanged
()
;
};
}
// namespace routing
src/Wima/WimaPlanData.cc
View file @
06e9bcab
#include "WimaPlanData.h"
WimaPlanData
::
WimaPlanData
(
QObject
*
parent
)
:
QObject
(
parent
)
{}
enum
Signal
{
measuremtAreaChanged
,
serviceAreaChanged
,
joinedAreaChanged
,
corridorChanged
,
};
WimaPlanData
::
WimaPlanData
(
QObject
*
parent
)
:
QObject
(
parent
),
_editing
(
false
)
{}
WimaPlanData
::
WimaPlanData
(
const
WimaPlanData
&
other
,
QObject
*
parent
)
:
QObject
(
parent
)
{
:
QObject
(
parent
)
,
_editing
(
false
)
{
*
this
=
other
;
}
/*!
* \fn WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other)
*
* Copies the data area list of \a other to the calling \c WimaPlanData object.
* Returns a reference to the calling \c WimaPlanData object.
*/
WimaPlanData
&
WimaPlanData
::
operator
=
(
const
WimaPlanData
&
other
)
{
// copy wima areas
QList
<
const
WimaAreaData
*>
areaList
=
other
.
areaList
();
_areaList
.
clear
();
for
(
int
i
=
0
;
i
<
areaList
.
size
();
i
++
)
{
const
WimaAreaData
*
areaData
=
areaList
[
i
];
// determine area type and append
if
(
areaData
->
type
()
==
WimaJoinedAreaData
::
typeString
)
{
this
->
append
(
*
qobject_cast
<
const
WimaJoinedAreaData
*>
(
areaData
));
}
else
if
(
areaData
->
type
()
==
WimaServiceAreaData
::
typeString
)
{
this
->
append
(
*
qobject_cast
<
const
WimaServiceAreaData
*>
(
areaData
));
}
else
if
(
areaData
->
type
()
==
WimaMeasurementAreaData
::
typeString
)
{
this
->
append
(
*
qobject_cast
<
const
WimaMeasurementAreaData
*>
(
areaData
));
}
else
if
(
areaData
->
type
()
==
WimaCorridorData
::
typeString
)
{
this
->
append
(
*
qobject_cast
<
const
WimaCorridorData
*>
(
areaData
));
}
}
this
->
_measurementArea
=
other
.
_measurementArea
;
this
->
_serviceArea
=
other
.
_serviceArea
;
this
->
_joinedArea
=
other
.
_joinedArea
;
this
->
_corridor
=
other
.
_corridor
;
return
*
this
;
}
/*!
* \fn void WimaPlanData::append(const WimaAreaData &areaData)
*
* Adds a WimaAreaData item.
*/
void
WimaPlanData
::
append
(
const
WimaJoinedAreaData
&
areaData
)
{
_joinedArea
=
areaData
;
void
WimaPlanData
::
set
(
const
WimaJoinedAreaData
&
areaData
)
{
if
(
_joinedArea
!=
areaData
)
{
_joinedArea
=
areaData
;
emitJoinedAreaChanged
();
}
}
if
(
!
_areaList
.
contains
(
&
_joinedArea
))
{
_areaList
.
append
(
&
_joinedArea
);
void
WimaPlanData
::
set
(
const
WimaServiceAreaData
&
areaData
)
{
if
(
_serviceArea
!=
areaData
)
{
_serviceArea
=
areaData
;
emitServiceAreaChanged
();
}
}
/*!
* \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
*
* Adds a WimaServiceAreaData item.
*/
void
WimaPlanData
::
append
(
const
WimaServiceAreaData
&
areaData
)
{
_serviceArea
=
areaData
;
void
WimaPlanData
::
set
(
const
WimaCorridorData
&
areaData
)
{
if
(
_corridor
!=
areaData
)
{
_corridor
=
areaData
;
emitCorridorChanged
();
}
}
if
(
!
_areaList
.
contains
(
&
_serviceArea
))
{
_areaList
.
append
(
&
_serviceArea
);
void
WimaPlanData
::
set
(
const
WimaMeasurementAreaData
&
areaData
)
{
if
(
_measurementArea
!=
areaData
)
{
_measurementArea
=
areaData
;
emitMeasurementAreaChanged
();
}
}
/*!
* \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
*
* Adds a WimaCorridorData item.
*/
void
WimaPlanData
::
append
(
const
WimaCorridorData
&
areaData
)
{
_corridor
=
areaData
;
void
WimaPlanData
::
clear
()
{
_joinedArea
=
WimaJoinedAreaData
();
_serviceArea
=
WimaServiceAreaData
();
_corridor
=
WimaCorridorData
();
_measurementArea
=
WimaMeasurementAreaData
();
}
if
(
!
_areaList
.
contains
(
&
_corridor
))
{
_areaList
.
append
(
&
_corridor
);
}
const
WimaJoinedAreaData
&
WimaPlanData
::
joinedArea
()
const
{
return
this
->
_joinedArea
;
}
const
WimaServiceAreaData
&
WimaPlanData
::
serviceArea
()
const
{
return
this
->
_serviceArea
;
}
/*!
* \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
*
* Adds a WimaMeasurementAreaData item.
*/
void
WimaPlanData
::
append
(
const
WimaMeasurementAreaData
&
areaData
)
{
_measurementArea
=
areaData
;
const
WimaCorridorData
&
WimaPlanData
::
corridor
()
const
{
return
this
->
_corridor
;
}
const
WimaMeasurementAreaData
&
WimaPlanData
::
measurementArea
()
const
{
return
this
->
_measurementArea
;
}
if
(
!
_areaList
.
contains
(
&
_measurementArea
))
{
_areaList
.
append
(
&
_measurementArea
);
void
WimaPlanData
::
startEditing
()
{
if
(
!
this
->
_editing
)
{
this
->
_editing
=
true
;
}
}
/*!
* \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
*
* Clears all stored objects
*/
void
WimaPlanData
::
clear
()
{
_areaList
.
clear
();
}
void
WimaPlanData
::
stopEditing
()
{
if
(
this
->
_editing
)
{
this
->
_editing
=
false
;
for
(
auto
&
s
:
this
->
_queuedSignals
)
{
s
.
second
();
}
this
->
_queuedSignals
.
clear
();
}
}
const
QList
<
const
WimaAreaData
*>
&
WimaPlanData
::
areaList
()
const
{
return
_areaList
;
WimaPlanData
::
Guard
WimaPlanData
::
guard
()
{
return
Guard
(
std
::
bind
(
&
WimaPlanData
::
stopEditing
,
this
))
;
}
bool
WimaPlanData
::
operator
==
(
const
WimaPlanData
&
other
)
const
{
...
...
@@ -107,14 +105,42 @@ bool WimaPlanData::operator!=(const WimaPlanData &other) const {
return
!
(
*
this
==
other
);
}
/*!
* \class WimaPlanData
* \brief Class storing data generated by the \c WimaPlaner class.
*
* This class is designed to store data generated by the \c WimaPlaner class and
* meant for data exchange between the \c WimaController and the \c WimaPlanner.
* It stores a QList of \c WimaAreaData objects, called area data list,
* containing the data of serveral \c WimaAreas generated by the \c WimaPlaner.
*
* \sa QList
*/
void
WimaPlanData
::
emitJoinedAreaChanged
()
{
if
(
!
this
->
_editing
)
{
emit
joinedAreaChanged
();
}
else
{
this
->
_queuedSignals
.
insert
(
std
::
make_pair
(
Signal
::
joinedAreaChanged
,
std
::
bind
(
&
WimaPlanData
::
joinedAreaChanged
,
this
)));
}
}
void
WimaPlanData
::
emitMeasurementAreaChanged
()
{
if
(
!
this
->
_editing
)
{
emit
measurementAreaChanged
();
}
else
{
this
->
_queuedSignals
.
insert
(
std
::
make_pair
(
Signal
::
measuremtAreaChanged
,
std
::
bind
(
&
WimaPlanData
::
measurementAreaChanged
,
this
)));
}
}
void
WimaPlanData
::
emitServiceAreaChanged
()
{
if
(
!
this
->
_editing
)
{
emit
serviceAreaChanged
();
}
else
{
this
->
_queuedSignals
.
insert
(
std
::
make_pair
(
Signal
::
serviceAreaChanged
,
std
::
bind
(
&
WimaPlanData
::
serviceAreaChanged
,
this
)));
}
}
void
WimaPlanData
::
emitCorridorChanged
()
{
if
(
!
this
->
_editing
)
{
emit
corridorChanged
();
}
else
{
this
->
_queuedSignals
.
insert
(
std
::
make_pair
(
Signal
::
corridorChanged
,
std
::
bind
(
&
WimaPlanData
::
corridorChanged
,
this
)));
}
}
src/Wima/WimaPlanData.h
View file @
06e9bcab
#pragma once
#include <functional>
#include <map>
#include <QGeoCoordinate>
#include <QObject>
...
...
@@ -13,38 +16,56 @@
class
WimaPlanData
:
public
QObject
{
Q_OBJECT
public:
class
Guard
{
public:
Guard
(
std
::
function
<
void
(
void
)
>
fun
)
:
fun_
(
fun
)
{}
~
Guard
()
{
fun_
();
}
private:
std
::
function
<
void
(
void
)
>
fun_
;
};
WimaPlanData
(
QObject
*
parent
=
nullptr
);
WimaPlanData
(
const
WimaPlanData
&
other
,
QObject
*
parent
=
nullptr
);
WimaPlanData
&
operator
=
(
const
WimaPlanData
&
other
);
// Member Methodes
void
append
(
const
WimaJoinedAreaData
&
areaData
);
void
append
(
const
WimaServiceAreaData
&
areaData
);
void
append
(
const
WimaCorridorData
&
areaData
);
void
append
(
const
WimaMeasurementAreaData
&
areaData
);
void
setTransects
(
const
QList
<
QList
<
QGeoCoordinate
>>
&
transects
);
//!
//! \brief append
//! \param missionItems
//! \note Takes owenership of MissionItems*
void
append
(
const
QList
<
MissionItem
*>
&
missionItems
);
void
set
(
const
WimaJoinedAreaData
&
areaData
);
void
set
(
const
WimaServiceAreaData
&
areaData
);
void
set
(
const
WimaCorridorData
&
areaData
);
void
set
(
const
WimaMeasurementAreaData
&
areaData
);
void
clear
();
const
QList
<
const
WimaAreaData
*>
&
areaList
()
const
;
const
QList
<
QList
<
QGeoCoordinate
>>
&
transects
()
const
;
const
QList
<
MissionItem
*>
&
missionItems
()
const
;
const
WimaJoinedAreaData
&
joinedArea
()
const
;
const
WimaServiceAreaData
&
serviceArea
()
const
;
const
WimaCorridorData
&
corridor
()
const
;
const
WimaMeasurementAreaData
&
measurementArea
()
const
;
void
startEditing
();
void
stopEditing
();
Guard
guard
();
bool
operator
==
(
const
WimaPlanData
&
other
)
const
;
bool
operator
!=
(
const
WimaPlanData
&
other
)
const
;
signals:
void
areaListChanged
();
void
joinedAreaChanged
();
void
serviceAreaChanged
();
void
corridorChanged
();
void
measurementAreaChanged
();
private:
void
emitJoinedAreaChanged
();
void
emitServiceAreaChanged
();
void
emitCorridorChanged
();
void
emitMeasurementAreaChanged
();
WimaJoinedAreaData
_joinedArea
;
WimaServiceAreaData
_serviceArea
;
WimaCorridorData
_corridor
;
WimaMeasurementAreaData
_measurementArea
;
QList
<
const
WimaAreaData
*>
_areaList
;
std
::
map
<
int
,
std
::
function
<
void
(
void
)
>>
_queuedSignals
;
bool
_editing
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment