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
11d8aaf3
Commit
11d8aaf3
authored
May 29, 2017
by
Don Gagne
Committed by
GitHub
May 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5224 from DonLakeFlyer/SurveyFixes
Fix crash in refly recalc
parents
fd5b9a74
b39f318c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
24 deletions
+30
-24
SurveyMissionItem.cc
src/MissionManager/SurveyMissionItem.cc
+29
-23
SurveyMissionItem.h
src/MissionManager/SurveyMissionItem.h
+1
-1
No files found.
src/MissionManager/SurveyMissionItem.cc
View file @
11d8aaf3
...
...
@@ -444,18 +444,17 @@ void SurveyMissionItem::_convertTransectToGeo(const QList<QList<QPointF>>& trans
}
}
void
SurveyMissionItem
::
_optimizeReflySegments
(
void
)
/// Reorders the transects such that the first transect is the shortest distance to the specified coordinate
/// and the first point within that transect is the shortest distance to the specified coordinate.
/// @param distanceCoord Coordinate to measure distance against
/// @param transects Transects to test and reorder
void
SurveyMissionItem
::
_optimizeTransectsForShortestDistance
(
const
QGeoCoordinate
&
distanceCoord
,
QList
<
QList
<
QGeoCoordinate
>>&
transects
)
{
// The last flight point of the initial pass
QGeoCoordinate
initialPassLastCoord
=
_transectSegments
.
last
().
last
();
// Now determine where we should start the refly pass
double
rgTransectDistance
[
4
];
rgTransectDistance
[
0
]
=
_reflyTransectSegments
.
first
().
first
().
distanceTo
(
initialPassLast
Coord
);
rgTransectDistance
[
1
]
=
_reflyTransectSegments
.
first
().
last
().
distanceTo
(
initialPassLast
Coord
);
rgTransectDistance
[
2
]
=
_reflyTransectSegments
.
last
().
first
().
distanceTo
(
initialPassLast
Coord
);
rgTransectDistance
[
3
]
=
_reflyTransectSegments
.
last
().
last
().
distanceTo
(
initialPassLast
Coord
);
rgTransectDistance
[
0
]
=
transects
.
first
().
first
().
distanceTo
(
distance
Coord
);
rgTransectDistance
[
1
]
=
transects
.
first
().
last
().
distanceTo
(
distance
Coord
);
rgTransectDistance
[
2
]
=
transects
.
last
().
first
().
distanceTo
(
distance
Coord
);
rgTransectDistance
[
3
]
=
transects
.
last
().
last
().
distanceTo
(
distance
Coord
);
int
shortestIndex
=
0
;
double
shortestDistance
=
rgTransectDistance
[
0
];
...
...
@@ -469,20 +468,20 @@ void SurveyMissionItem::_optimizeReflySegments(void)
if
(
shortestIndex
>
1
)
{
// We need to reverse the order of segments
QList
<
QList
<
QGeoCoordinate
>>
rgReversedTransects
;
for
(
int
i
=
_reflyTransectSegmen
ts
.
count
()
-
1
;
i
>=
0
;
i
--
)
{
rgReversedTransects
.
append
(
_reflyTransectSegmen
ts
[
i
]);
for
(
int
i
=
transec
ts
.
count
()
-
1
;
i
>=
0
;
i
--
)
{
rgReversedTransects
.
append
(
transec
ts
[
i
]);
}
_reflyTransectSegmen
ts
=
rgReversedTransects
;
transec
ts
=
rgReversedTransects
;
}
if
(
shortestIndex
&
1
)
{
// We need to reverse the points within each segment
for
(
int
i
=
0
;
i
<
_reflyTransectSegmen
ts
.
count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
transec
ts
.
count
();
i
++
)
{
QList
<
QGeoCoordinate
>
rgReversedCoords
;
QList
<
QGeoCoordinate
>&
rgOriginalCoords
=
_reflyTransectSegmen
ts
[
i
];
for
(
int
j
=
rgOriginalCoords
.
count
()
-
1
;
j
>=
0
;
j
++
)
{
QList
<
QGeoCoordinate
>&
rgOriginalCoords
=
transec
ts
[
i
];
for
(
int
j
=
rgOriginalCoords
.
count
()
-
1
;
j
>=
0
;
j
--
)
{
rgReversedCoords
.
append
(
rgOriginalCoords
[
j
]);
}
_reflyTransectSegmen
ts
[
i
]
=
rgReversedCoords
;
transec
ts
[
i
]
=
rgReversedCoords
;
}
}
}
...
...
@@ -578,14 +577,19 @@ void SurveyMissionItem::_generateGrid(void)
QList
<
QList
<
QPointF
>>
transectSegments
;
// Convert polygon to NED
qCDebug
(
SurveyMissionItemLog
)
<<
"Convert polygon"
;
QGeoCoordinate
tangentOrigin
=
_mapPolygon
.
path
()[
0
].
value
<
QGeoCoordinate
>
()
;
QGeoCoordinate
tangentOrigin
=
_mapPolygon
.
pathModel
().
value
<
QGCQGeoCoordinate
*>
(
0
)
->
coordinate
()
;
qCDebug
(
SurveyMissionItemLog
)
<<
"Convert polygon to NED - tangentOrigin"
<<
tangentOrigin
;
for
(
int
i
=
0
;
i
<
_mapPolygon
.
count
();
i
++
)
{
double
y
,
x
,
down
;
QGeoCoordinate
vertex
=
_mapPolygon
.
pathModel
().
value
<
QGCQGeoCoordinate
*>
(
i
)
->
coordinate
();
convertGeoToNed
(
vertex
,
tangentOrigin
,
&
y
,
&
x
,
&
down
);
if
(
i
==
0
)
{
// This avoids a nan calculation that comes out of convertGeoToNed
x
=
y
=
0
;
}
else
{
convertGeoToNed
(
vertex
,
tangentOrigin
,
&
y
,
&
x
,
&
down
);
}
polygonPoints
+=
QPointF
(
x
,
y
);
qCDebug
(
SurveyMissionItemLog
)
<<
vertex
<<
polygonPoints
.
last
().
x
()
<<
polygonPoints
.
last
().
y
();
qCDebug
(
SurveyMissionItemLog
)
<<
"vertex:x:y"
<<
vertex
<<
polygonPoints
.
last
().
x
()
<<
polygonPoints
.
last
().
y
();
}
polygonPoints
=
_convexPolygon
(
polygonPoints
);
...
...
@@ -604,14 +608,16 @@ void SurveyMissionItem::_generateGrid(void)
int
cameraShots
=
0
;
cameraShots
+=
_gridGenerator
(
polygonPoints
,
transectSegments
,
false
/* refly */
);
_convertTransectToGeo
(
transectSegments
,
tangentOrigin
,
_transectSegments
);
//_optimizeTransectsForShortestDistance(?, _transectSegments);
_appendGridPointsFromTransects
(
_transectSegments
);
qDebug
()
<<
_transectSegments
.
count
();
if
(
_refly90Degrees
)
{
QVariantList
reflyPointsGeo
;
transectSegments
.
clear
();
cameraShots
+=
_gridGenerator
(
polygonPoints
,
transectSegments
,
true
/* refly */
);
_convertTransectToGeo
(
transectSegments
,
tangentOrigin
,
_reflyTransectSegments
);
_optimize
ReflySegments
(
);
_optimize
TransectsForShortestDistance
(
_transectSegments
.
last
().
last
(),
_reflyTransectSegments
);
_appendGridPointsFromTransects
(
_reflyTransectSegments
);
}
...
...
@@ -795,7 +801,7 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
double
gridAngle
=
_gridAngleFact
.
rawValue
().
toDouble
()
+
(
refly
?
90
:
0
);
double
gridSpacing
=
_gridSpacingFact
.
rawValue
().
toDouble
();
qCDebug
(
SurveyMissionItemLog
)
<<
"SurveyMissionItem::_gridGenerator gridSpacing:gridAngle
"
<<
gridSpacing
<<
gridAngle
;
qCDebug
(
SurveyMissionItemLog
)
<<
"SurveyMissionItem::_gridGenerator gridSpacing:gridAngle
:refly"
<<
gridSpacing
<<
gridAngle
<<
refly
;
transectSegments
.
clear
();
...
...
src/MissionManager/SurveyMissionItem.h
View file @
11d8aaf3
...
...
@@ -197,7 +197,7 @@ private:
double
_turnaroundDistance
(
void
)
const
;
void
_convertTransectToGeo
(
const
QList
<
QList
<
QPointF
>>&
transectSegmentsNED
,
const
QGeoCoordinate
&
tangentOrigin
,
QList
<
QList
<
QGeoCoordinate
>>&
transectSegmentsGeo
);
bool
_appendMissionItemsWorker
(
QList
<
MissionItem
*>&
items
,
QObject
*
missionItemParent
,
int
&
seqNum
,
bool
hasRefly
,
bool
buildRefly
);
void
_optimize
ReflySegments
(
void
);
void
_optimize
TransectsForShortestDistance
(
const
QGeoCoordinate
&
distanceCoord
,
QList
<
QList
<
QGeoCoordinate
>>&
transects
);
void
_appendGridPointsFromTransects
(
QList
<
QList
<
QGeoCoordinate
>>&
rgTransectSegments
);
qreal
_ccw
(
QPointF
pt1
,
QPointF
pt2
,
QPointF
pt3
);
qreal
_dp
(
QPointF
pt1
,
QPointF
pt2
);
...
...
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