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
7c0976d9
Commit
7c0976d9
authored
Aug 03, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
not compilable
parent
5be50a5b
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
786 additions
and
785 deletions
+786
-785
qgroundcontrol.pro
qgroundcontrol.pro
+0
-4
flight_plan.cpp
src/Snake/flight_plan.cpp
+0
-372
flight_plan.h
src/Snake/flight_plan.h
+0
-59
snake.cpp
src/Snake/snake.cpp
+433
-145
snake.h
src/Snake/snake.h
+119
-19
snake_geometry.cpp
src/Snake/snake_geometry.cpp
+0
-1
snake_geometry.h
src/Snake/snake_geometry.h
+0
-0
SnakeWorker.cc
src/Wima/Snake/SnakeWorker.cc
+187
-122
SnakeWorker.h
src/Wima/Snake/SnakeWorker.h
+44
-60
WimaController.cc
src/Wima/WimaController.cc
+2
-2
WimaController.h
src/Wima/WimaController.h
+1
-1
No files found.
qgroundcontrol.pro
View file @
7c0976d9
...
...
@@ -408,7 +408,6 @@ FORMS += \
HEADERS
+=
\
src
/
Snake
/
clipper
/
clipper
.
hpp
\
src
/
Snake
/
flight_plan
.
h
\
src
/
Snake
/
mapbox
/
feature
.
hpp
\
src
/
Snake
/
mapbox
/
geometry
.
hpp
\
src
/
Snake
/
mapbox
/
geometry
/
box
.
hpp
\
...
...
@@ -430,7 +429,6 @@ HEADERS += \
src
/
Snake
/
mapbox
/
variant
.
hpp
\
src
/
Snake
/
mapbox
/
variant_io
.
hpp
\
src
/
Snake
/
snake
.
h
\
src
/
Snake
/
snake_geometry
.
h
\
src
/
Snake
/
snake_typedefs
.
h
\
src
/
Wima
/
Geometry
/
GeoPoint3D
.
h
\
src
/
Wima
/
Geometry
/
Polygon2D
.
h
\
...
...
@@ -498,9 +496,7 @@ HEADERS += \
src
/
comm
/
utilities
.
h
SOURCES
+=
\
src
/
Snake
/
clipper
/
clipper
.
cpp
\
src
/
Snake
/
flight_plan
.
cpp
\
src
/
Snake
/
snake
.
cpp
\
src
/
Snake
/
snake_geometry
.
cpp
\
src
/
Wima
/
Geometry
/
GeoPoint3D
.
cpp
\
src
/
Wima
/
Geometry
/
PolygonArray
.
cc
\
src
/
Wima
/
Snake
/
GeoTile
.
cpp
\
...
...
src/Snake/flight_plan.cpp
deleted
100644 → 0
View file @
5be50a5b
This diff is collapsed.
Click to expand it.
src/Snake/flight_plan.h
deleted
100644 → 0
View file @
5be50a5b
#pragma once
namespace
flight_plan
{
//========================================================================================
// FlightPlan
//========================================================================================
class
FlightPlan
{
public:
FlightPlan
();
void
setScenario
(
Scenario
&
scenario
)
{
_scenario
=
scenario
;}
void
setProgress
(
vector
<
int
>
&
progress
)
{
_progress
=
progress
;}
const
Scenario
&
getScenario
(
void
)
const
{
return
_scenario
;}
const
BoostLineString
&
getWaypointsENU
(
void
)
const
{
return
_waypointsENU
;}
const
GeoPoint2DList
&
getWaypoints
(
void
)
const
{
return
_waypoints
;}
const
vector
<
uint64_t
>
&
getArrivalPathIdx
(
void
)
const
{
return
_arrivalPathIdx
;}
const
vector
<
uint64_t
>
&
getReturnPathIdx
(
void
)
const
{
return
_returnPathIdx
;}
#ifndef NDEBUG
const
BoostLineString
&
getPathVertices
(
void
)
const
{
return
_PathVertices
;}
#endif
bool
generate
(
double
lineDistance
,
double
minTransectLength
);
const
vector
<
BoostLineString
>
&
getTransects
()
const
{
return
_transects
;}
string
errorString
;
private:
// Search Filter to speed up routing.SolveWithParameters(...);
// Found here: http://www.lia.disi.unibo.it/Staff/MicheleLombardi/or-tools-doc/user_manual/manual/ls/ls_filtering.html
class
SearchFilter
;
struct
RoutingDataModel
;
bool
_generateTransects
(
double
lineDistance
,
double
minTransectLength
);
void
_generateRoutingModel
(
const
BoostLineString
&
vertices
,
const
BoostPolygon
&
polygonOffset
,
size_t
n0
,
RoutingDataModel
&
dataModel
,
Matrix
<
double
>
&
graph
);
Scenario
_scenario
;
BoostLineString
_waypointsENU
;
GeoPoint2DList
_waypoints
;
vector
<
BoostLineString
>
_transects
;
vector
<
int
>
_progress
;
vector
<
uint64_t
>
_arrivalPathIdx
;
vector
<
uint64_t
>
_returnPathIdx
;
#ifndef NDEBUG
BoostLineString
_PathVertices
;
#endif
};
}
src/Snake/snake.cpp
View file @
7c0976d9
This diff is collapsed.
Click to expand it.
src/Snake/snake.h
View file @
7c0976d9
...
...
@@ -3,9 +3,9 @@
#include <vector>
#include <string>
#include <array>
#include <memory>
#include "snake_typedefs.h"
#include "snake_geometry.h"
#include <GeographicLib/Geocentric.hpp>
#include <GeographicLib/LocalCartesian.hpp>
...
...
@@ -81,12 +81,16 @@ private:
std
::
vector
<
T
>
_matrix
;
};
typedef
struct
{
struct
BoundingBox
{
BoundingBox
();
void
clear
();
double
width
;
double
height
;
double
angle
;
BoostPolygon
corners
;
}
BoundingBox
;
};
template
<
class
GeoPoint
>
void
toENU
(
const
GeoPoint
&
origin
,
const
GeoPoint
&
in
,
BoostPoint
&
out
)
...
...
@@ -144,8 +148,67 @@ void shortestPathFromGraph(const Matrix<double> &graph,
std
::
vector
<
size_t
>
&
pathIdx
);
//=========================================================================
//
Tile calculation
.
//
Scenario
.
//=========================================================================
class
Scenario
{
public:
Scenario
();
void
setMeasurementArea
(
const
BoostPolygon
&
area
);
void
setServiceArea
(
const
BoostPolygon
&
area
);
void
setCorridor
(
const
BoostPolygon
&
area
);
BoostPolygon
&
measurementArea
();
BoostPolygon
&
serviceArea
();
BoostPolygon
&
corridor
();
const
BoundingBox
&
mAreaBoundingBox
()
const
;
const
BoostPolygon
&
measurementArea
()
const
;
const
BoostPolygon
&
serviceArea
()
const
;
const
BoostPolygon
&
corridor
()
const
;
double
tileWidth
()
const
;
void
setTileWidth
(
double
tileWidth
);
double
tileHeight
()
const
;
void
setTileHeight
(
double
tileHeight
);
double
minTileArea
()
const
;
void
setMinTileArea
(
double
minTileArea
);
const
BoostPolygon
&
joinedArea
()
const
;
const
vector
<
BoostPolygon
>
&
tiles
()
const
;
const
BoostLineString
&
tileCenterPoints
()
const
;
const
BoundingBox
&
measurementAreaBBox
()
const
;
const
BoostPoint
&
homePositon
()
const
;
bool
update
();
string
errorString
;
private:
bool
_calculateBoundingBox
();
bool
_calculateTiles
();
bool
_calculateJoinedArea
();
double
_tileWidth
;
double
_tileHeight
;
double
_minTileArea
;
mutable
bool
_needsUpdate
;
BoostPolygon
_mArea
;
BoostPolygon
_sArea
;
BoostPolygon
_corridor
;
BoostPolygon
_jArea
;
BoundingBox
_mAreaBoundingBox
;
vector
<
BoostPolygon
>
_tiles
;
BoostLineString
_tileCenterPoints
;
BoostPoint
_homePosition
;
};
template
<
class
GeoPoint
,
template
<
class
,
class
...
>
class
Container
>
void
areaToEnu
(
const
GeoPoint
&
origin
,
const
Container
<
GeoPoint
>
&
in
,
...
...
@@ -156,7 +219,7 @@ void areaToEnu( const GeoPoint &origin,
toENU
(
origin
,
vertex
,
p
);
out
.
outer
().
push_back
(
p
);
}
bg
::
correct
(
_measurementAreaENU
);
bg
::
correct
(
out
);
}
template
<
class
GeoPoint
,
template
<
class
,
class
...
>
class
Container
>
...
...
@@ -171,24 +234,61 @@ void areaFromEnu( const GeoPoint &origin,
}
}
bool
calculateTiles
(
const
BoostPolygon
&
mArea
,
double
tileWidth
,
double
tileHeight
,
double
minTileArea
,
std
::
vector
<
BoostPolygon
>
&
tiles
,
std
::
string
&
errorString
);
bool
joinAreas
(
const
std
::
vector
<
BoostPolygon
>
&
areas
,
BoostPolygon
&
joinedArea
);
//========================================================================================
// Flightplan
//========================================================================================
//=========================================================================
// Waypoint calculation.
//=========================================================================
bool
waypoints
(
const
BoostPolygon
&
mArea
,
const
BoostPolygon
&
jArea
,
std
::
vector
<
BoostPolygon
>
&
tiles
,
BoostPoint
&
home
,
double
lineDistance
,
double
minTransectLength
,
std
::
vector
<
BoostPoint
>
,
size_t
arrivalPathLength
,
size_t
returnPathLength
);
class
Flightplan
{
public:
using
ScenarioPtr
=
shared_ptr
<
Scenario
>
;
using
ProgressPtr
=
shared_ptr
<
vector
<
int
>>
;
Flightplan
(
ScenarioPtr
s
,
ScenarioPtr
p
);
const
vector
<
BoostPoint
>
&
waypoints
(
void
)
const
{
return
_waypoints
;}
const
vector
<
BoostPoint
>
&
arrivalPath
(
void
)
const
{
return
_arrivalPath
;}
const
vector
<
BoostPoint
>
&
returnPath
(
void
)
const
{
return
_returnPath
;}
double
lineDistance
()
const
;
void
setLineDistance
(
double
lineDistance
);
double
minTransectLengthconst
;
void
setMinTransectLength
(
double
minTransectLength
);
ScenarioPtr
scenario
()
const
;
void
setScenario
(
ScenarioPtr
&
scenario
);
ProgressPtr
progress
()
const
;
void
setProgress
(
ProgressPtr
&
progress
);
bool
update
();
string
errorString
;
private:
// Search Filter to speed up routing.SolveWithParameters(...);
// Found here: http://www.lia.disi.unibo.it/Staff/MicheleLombardi/or-tools-doc/user_manual/manual/ls/ls_filtering.html
class
SearchFilter
;
struct
RoutingDataModel
;
bool
_generateTransects
();
void
_generateRoutingModel
(
const
BoostLineString
&
vertices
,
const
BoostPolygon
&
polygonOffset
,
size_t
n0
,
RoutingDataModel
&
dataModel
,
Matrix
<
double
>
&
graph
);
double
_lineDistance
;
double
_minTransectLength
;
shared_ptr
<
const
Scenario
>
_pScenario
;
shared_ptr
<
const
vector
<
int
>>
_pProgress
;
vector
<
BoostPoint
>
_waypoints
;
vector
<
BoostPoint
>
_arrivalPath
;
vector
<
BoostPoint
>
_returnPath
;
vector
<
BoostLineString
>
_transects
;
};
namespace
detail
{
const
double
offsetConstant
=
0
.
1
;
// meter, polygon offset to compenstate for numerical inaccurracies.
...
...
src/Snake/snake_geometry.cpp
deleted
100644 → 0
View file @
5be50a5b
src/Snake/snake_geometry.h
deleted
100644 → 0
View file @
5be50a5b
src/Wima/Snake/SnakeWorker.cc
View file @
7c0976d9
This diff is collapsed.
Click to expand it.
src/Wima/Snake/SnakeWorker.h
View file @
7c0976d9
...
...
@@ -5,46 +5,63 @@
#include <QThread>
#include <QVector>
#include <QGeoCoordinate>
#include <QMutex>
#include <vector>
#include <memory>
#include "GeoPolygonArray.h"
#include "PolygonArray.h"
#include "SnakeWorker.h"
#include "QNemoProgress.h"
typedef
QList
<
QVariant
>
QVariantList
;
typedef
struct
Result
{
namespace
snake
{
class
Scenario
;
class
Flightplan
;
}
struct
SnakeData
{
SnakeData
();
QVector
<
QGeoCoordinate
>
waypoints
;
QVector
<
QGeoCoordinate
>
arrivalPath
;
QVector
<
QGeoCoordinate
>
returnPath
;
QGeoCoordinate
ENUorigin
;
QVector
<
QGeoCoordinate
>
waypointsENU
;
QVector
<
QGeoCoordinate
>
arrivalPathENU
;
QVector
<
QGeoCoordinate
>
returnPathENU
;
GeoPolygonArray
tiles
;
PolygonArray
tilesLocal
;
QVariantList
tileCenterPoints
;
QGeoCoordinate
origin
;
QVector
<
unsigned
long
>
arrivalPathIdx
;
QVector
<
unsigned
long
>
returnPathIdx
;
bool
success
;
PolygonArray
tilesENU
;
QVector
<
QGeoCoordinate
>
tileCenterPointsENU
;
QString
errorMessage
;
mutable
QMutex
m
;
void
clear
();
}
WorkerResult_t
;
};
class
Snake
Work
er
:
public
QThread
{
class
Snake
DataManag
er
:
public
QThread
{
Q_OBJECT
public:
SnakeWorker
(
QObject
*
parent
=
nullptr
);
~
SnakeWorker
()
override
;
using
ProgressPtr
=
std
::
shared_ptr
<
std
::
vector
<
int
>>
;
using
ScenarioPtr
=
std
::
shared_ptr
<
snake
::
Scenario
>
;
using
FlightPlanPtr
=
std
::
shared_ptr
<
snake
::
Flightplan
>
;
using
SnakeDataPtr
=
std
::
shared_ptr
<
SnakeData
>
;
SnakeDataManager
(
QObject
*
parent
=
nullptr
);
~
SnakeDataManager
()
override
;
template
<
template
<
class
,
class
...
>
class
Container
>
void
setMeasurementArea
(
const
Container
<
QGeoCoordinate
>
&
measurementArea
);
template
<
template
<
class
,
class
...
>
class
Container
>
void
setServiceArea
(
const
Container
<
QGeoCoordinate
>
&
serviceArea
);
template
<
template
<
class
,
class
...
>
class
Container
>
void
setCorridor
(
const
Container
<
QGeoCoordinate
>
&
corridor
);
template
<
template
<
class
,
class
...
>
class
Container
,
class
IntType
>
void
setProgress
(
const
Container
<
IntType
>
&
progress
);
WorkerResult_t
&
result
();
void
setMeasurementArea
(
const
QList
<
QGeoCoordinate
>
&
measurementArea
);
void
setServiceArea
(
const
QList
<
QGeoCoordinate
>
&
serviceArea
);
void
setCorridor
(
const
QList
<
QGeoCoordinate
>
&
corridor
);
SnakeDataPtr
snakeData
();
double
lineDistance
()
const
;
void
setLineDistance
(
double
lineDistance
);
...
...
@@ -67,53 +84,20 @@ protected:
private:
bool
precondition
()
const
;
std
::
vector
<
QGeoCoordinate
>
_mArea
;
std
::
vector
<
QGeoCoordinate
>
_sArea
;
std
::
vector
<
QGeoCoordinate
>
_corridor
;
std
::
vector
<
int
>
_progress
;
double
_lineDistance
;
double
_minTransectLength
;
double
_tileWidth
;
double
_tileHeight
;
double
_minTileArea
;
WorkerResult_t
_result
;
ScenarioPtr
_pScenario
;
ProgressPtr
_pProgress
;
FlightPlanPtr
_pFlightplan
;
SnakeDataPtr
_pData
;
};
template
<
template
<
class
,
class
...
>
class
Container
>
void
SnakeWorker
::
setCorridor
(
const
Container
<
QGeoCoordinate
>
&
corridor
)
{
_corridor
.
clear
();
for
(
auto
vertex
:
corridor
)
{
_corridor
.
push_back
(
vertex
);
}
}
template
<
template
<
class
,
class
...
>
class
Container
>
void
SnakeWorker
::
setMeasurementArea
(
const
Container
<
QGeoCoordinate
>
&
measurementArea
)
{
_mArea
.
clear
();
for
(
auto
vertex
:
measurementArea
)
{
_mArea
.
push_back
(
vertex
);
}
}
template
<
template
<
class
,
class
...
>
class
Container
>
void
SnakeWorker
::
setServiceArea
(
const
Container
<
QGeoCoordinate
>
&
serviceArea
)
{
_sArea
.
clear
();
for
(
auto
vertex
:
serviceArea
)
{
_sArea
.
push_back
(
vertex
);
}
}
template
<
template
<
class
,
class
...
>
class
Container
,
class
IntType
>
void
SnakeWorker
::
setProgress
(
const
Container
<
IntType
>
&
progress
)
{
_progress
.
clear
();
for
(
auto
p
:
progress
)
{
assert
(
p
>=
-
1
&&
p
<=
100
);
_progress
.
push_back
(
p
);
}
}
src/Wima/WimaController.cc
View file @
7c0976d9
...
...
@@ -112,9 +112,9 @@ WimaController::WimaController(QObject *parent)
_eventTimer
.
start
(
EVENT_TIMER_INTERVAL
);
// Snake Worker Thread.
connect
(
&
_snakeWorker
,
&
Snake
Work
er
::
finished
,
this
,
&
WimaController
::
_updateSnakeData
);
connect
(
&
_snakeWorker
,
&
Snake
DataManag
er
::
finished
,
this
,
&
WimaController
::
_updateSnakeData
);
connect
(
this
,
&
WimaController
::
nemoProgressChanged
,
this
,
&
WimaController
::
_initStartSnakeWorker
);
connect
(
this
,
&
QObject
::
destroyed
,
&
this
->
_snakeWorker
,
&
Snake
Work
er
::
quit
);
connect
(
this
,
&
QObject
::
destroyed
,
&
this
->
_snakeWorker
,
&
Snake
DataManag
er
::
quit
);
// Snake.
connect
(
&
_enableSnake
,
&
Fact
::
rawValueChanged
,
this
,
&
WimaController
::
_switchSnakeManager
);
...
...
src/Wima/WimaController.h
View file @
7c0976d9
...
...
@@ -401,7 +401,7 @@ private:
// Snake
bool
_snakeCalcInProgress
;
Snake
Work
er
_snakeWorker
;
Snake
DataManag
er
_snakeWorker
;
GeoPoint
_snakeOrigin
;
GeoPolygonArray
_snakeTiles
;
// tiles
PolygonArray
_snakeTilesLocal
;
// tiles local coordinate system
...
...
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