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
42eeb4ee
Commit
42eeb4ee
authored
Dec 13, 2017
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit tests which verify item count and lastSequenceNumber
Fixed bugs the unit test found
parent
ba2b94b9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
30 deletions
+88
-30
PlanManager.cc
src/MissionManager/PlanManager.cc
+1
-1
StructureScanComplexItem.cc
src/MissionManager/StructureScanComplexItem.cc
+4
-2
StructureScanComplexItemTest.cc
src/MissionManager/StructureScanComplexItemTest.cc
+10
-3
StructureScanComplexItemTest.h
src/MissionManager/StructureScanComplexItemTest.h
+1
-0
SurveyMissionItem.cc
src/MissionManager/SurveyMissionItem.cc
+25
-14
SurveyMissionItem.h
src/MissionManager/SurveyMissionItem.h
+1
-0
SurveyMissionItemTest.cc
src/MissionManager/SurveyMissionItemTest.cc
+44
-10
SurveyMissionItemTest.h
src/MissionManager/SurveyMissionItemTest.h
+2
-0
No files found.
src/MissionManager/PlanManager.cc
View file @
42eeb4ee
...
...
@@ -604,7 +604,7 @@ void PlanManager::_handleMissionAck(const mavlink_message_t& message)
// MISSION_REQUEST is expected, or MISSION_ACK to end sequence
if
(
missionAck
.
type
==
MAV_MISSION_ACCEPTED
)
{
if
(
_itemIndicesToWrite
.
count
()
==
0
)
{
qCDebug
(
PlanManagerLog
)
<<
QStringLiteral
(
"_handleMissionAck write sequence complete"
).
arg
(
_planTypeString
());
qCDebug
(
PlanManagerLog
)
<<
QStringLiteral
(
"_handleMissionAck write sequence complete
%1
"
).
arg
(
_planTypeString
());
_finishTransaction
(
true
);
}
else
{
_sendError
(
MissingRequestsError
,
tr
(
"Vehicle did not request all items during write sequence, missed count %1."
).
arg
(
_itemIndicesToWrite
.
count
()));
...
...
src/MissionManager/StructureScanComplexItem.cc
View file @
42eeb4ee
...
...
@@ -127,8 +127,10 @@ void StructureScanComplexItem::_polygonCountChanged(int count)
int
StructureScanComplexItem
::
lastSequenceNumber
(
void
)
const
{
return
_sequenceNumber
+
((
_flightPolygon
.
count
()
+
1
)
*
_layersFact
.
rawValue
().
toInt
())
+
// 1 waypoint for each polygon vertex + 1 to go back to first polygon vertex
1
;
// Gimbal control command
(
_layersFact
.
rawValue
().
toInt
()
*
((
_flightPolygon
.
count
()
+
1
)
+
// 1 waypoint for each polygon vertex + 1 to go back to first polygon vertex for each layer
2
))
+
// Camera trigger start/stop for each layer
1
;
// Gimbal control command
}
void
StructureScanComplexItem
::
setDirty
(
bool
dirty
)
...
...
src/MissionManager/StructureScanComplexItemTest.cc
View file @
42eeb4ee
...
...
@@ -122,9 +122,6 @@ void StructureScanComplexItemTest::_validateItem(StructureScanComplexItem* item)
QCOMPARE
(
item
->
gimbalPitch
()
->
cookedValue
().
toDouble
(),
45.0
);
QCOMPARE
(
item
->
gimbalYaw
()
->
cookedValue
().
toDouble
(),
45.0
);
QCOMPARE
(
item
->
layers
()
->
cookedValue
().
toInt
(),
2
);
int
seqNum
=
item
->
sequenceNumber
();
QCOMPARE
(
item
->
lastSequenceNumber
(),
seqNum
+
(
5
/* 5 waypoints per layer */
*
item
->
layers
()
->
cookedValue
().
toInt
())
+
1
/* gimbal command */
);
}
void
StructureScanComplexItemTest
::
_testSaveLoad
(
void
)
...
...
@@ -152,3 +149,13 @@ void StructureScanComplexItemTest::_testGimbalAngleUpdate(void)
QCOMPARE
(
_structureScanItem
->
gimbalPitch
()
->
cookedValue
().
toDouble
(),
0.0
);
QCOMPARE
(
_structureScanItem
->
gimbalYaw
()
->
cookedValue
().
toDouble
(),
90.0
);
}
void
StructureScanComplexItemTest
::
_testItemCount
(
void
)
{
QList
<
MissionItem
*>
items
;
_initItem
();
_structureScanItem
->
appendMissionItems
(
items
,
this
);
QCOMPARE
(
items
.
count
(),
_structureScanItem
->
lastSequenceNumber
());
}
src/MissionManager/StructureScanComplexItemTest.h
View file @
42eeb4ee
...
...
@@ -28,6 +28,7 @@ private slots:
void
_testDirty
(
void
);
void
_testSaveLoad
(
void
);
void
_testGimbalAngleUpdate
(
void
);
void
_testItemCount
(
void
);
private:
void
_initItem
(
void
);
...
...
src/MissionManager/SurveyMissionItem.cc
View file @
42eeb4ee
...
...
@@ -638,6 +638,28 @@ void SurveyMissionItem::_adjustTransectsToEntryPointLocation(QList<QList<QGeoCoo
qCDebug
(
SurveyMissionItemLog
)
<<
"Modified entry point"
<<
transects
.
first
().
first
();
}
int
SurveyMissionItem
::
_calcMissionCommandCount
(
QList
<
QList
<
QGeoCoordinate
>>&
transectSegments
)
{
int
missionCommandCount
=
0
;
for
(
int
i
=
0
;
i
<
transectSegments
.
count
();
i
++
)
{
const
QList
<
QGeoCoordinate
>&
transectSegment
=
transectSegments
[
i
];
missionCommandCount
+=
transectSegment
.
count
();
// This accounts for all waypoints
if
(
_hoverAndCaptureEnabled
())
{
// Internal camera trigger points are entry point, plus all points before exit point
missionCommandCount
+=
transectSegment
.
count
()
-
(
_hasTurnaround
()
?
2
:
0
)
-
1
;
}
else
if
(
_triggerCamera
()
&&
!
_imagesEverywhere
())
{
// Camera on/off at entry/exit of each transect
missionCommandCount
+=
2
;
}
}
if
(
transectSegments
.
count
()
&&
_triggerCamera
()
&&
_imagesEverywhere
())
{
// Camera on/off for entire survey
missionCommandCount
+=
2
;
}
return
missionCommandCount
;
}
void
SurveyMissionItem
::
_generateGrid
(
void
)
{
if
(
_ignoreRecalc
)
{
...
...
@@ -725,19 +747,8 @@ void SurveyMissionItem::_generateGrid(void)
emit
gridPointsChanged
();
// Determine command count for lastSequenceNumber
_missionCommandCount
=
0
;
for
(
int
i
=
0
;
i
<
_transectSegments
.
count
();
i
++
)
{
const
QList
<
QGeoCoordinate
>&
transectSegment
=
_transectSegments
[
i
];
_missionCommandCount
+=
transectSegment
.
count
();
// This accounts for all waypoints
if
(
_hoverAndCaptureEnabled
())
{
// Internal camera trigger points are entry point, plus all points before exit point
_missionCommandCount
+=
transectSegment
.
count
()
-
(
_hasTurnaround
()
?
2
:
0
)
-
1
;
}
else
if
(
_triggerCamera
())
{
_missionCommandCount
+=
2
;
// Camera on/off at entry/exit
}
}
_missionCommandCount
=
_calcMissionCommandCount
(
_transectSegments
);
_missionCommandCount
+=
_calcMissionCommandCount
(
_reflyTransectSegments
);
emit
lastSequenceNumberChanged
(
lastSequenceNumber
());
// Set exit coordinate
...
...
@@ -1117,7 +1128,7 @@ bool SurveyMissionItem::_appendMissionItemsWorker(QList<MissionItem*>& items, QO
{
bool
firstWaypointTrigger
=
false
;
qCDebug
(
SurveyMissionItemLog
)
<<
"hasTurnaround:triggerCamera:hoverAndCapture:imagesEverywhere:hasRefly:buildRefly"
<<
_hasTurnaround
()
<<
_triggerCamera
()
<<
_hoverAndCaptureEnabled
()
<<
_imagesEverywhere
()
<<
hasRefly
<<
buildRefly
;
qCDebug
(
SurveyMissionItemLog
)
<<
QStringLiteral
(
"hasTurnaround(%1) triggerCamera(%2) hoverAndCapture(%3) imagesEverywhere(%4) hasRefly(%5) buildRefly(%6) "
).
arg
(
_hasTurnaround
()).
arg
(
_triggerCamera
()).
arg
(
_hoverAndCaptureEnabled
()).
arg
(
_imagesEverywhere
()).
arg
(
hasRefly
).
arg
(
buildRefly
)
;
QList
<
QList
<
QGeoCoordinate
>>&
transectSegments
=
buildRefly
?
_reflyTransectSegments
:
_transectSegments
;
...
...
src/MissionManager/SurveyMissionItem.h
View file @
42eeb4ee
...
...
@@ -222,6 +222,7 @@ private:
void
_adjustTransectsToEntryPointLocation
(
QList
<
QList
<
QGeoCoordinate
>>&
transects
);
bool
_gridAngleIsNorthSouthTransects
();
double
_clampGridAngle90
(
double
gridAngle
);
int
_calcMissionCommandCount
(
QList
<
QList
<
QGeoCoordinate
>>&
transectSegments
);
int
_sequenceNumber
;
bool
_dirty
;
...
...
src/MissionManager/SurveyMissionItemTest.cc
View file @
42eeb4ee
...
...
@@ -200,14 +200,17 @@ double SurveyMissionItemTest::_clampGridAngle180(double gridAngle)
return
gridAngle
;
}
void
SurveyMissionItemTest
::
_
testGridAngle
(
void
)
void
SurveyMissionItemTest
::
_
setPolygon
(
void
)
{
QGCMapPolygon
*
mapPolygon
=
_surveyItem
->
mapPolygon
();
for
(
int
i
=
0
;
i
<
_polyPoints
.
count
();
i
++
)
{
QGeoCoordinate
&
vertex
=
_polyPoints
[
i
];
mapPolygon
->
appendVertex
(
vertex
);
_
mapPolygon
->
appendVertex
(
vertex
);
}
}
void
SurveyMissionItemTest
::
_testGridAngle
(
void
)
{
_setPolygon
();
for
(
double
gridAngle
=-
360.0
;
gridAngle
<=
360.0
;
gridAngle
++
)
{
_surveyItem
->
gridAngle
()
->
setRawValue
(
gridAngle
);
...
...
@@ -223,12 +226,7 @@ void SurveyMissionItemTest::_testGridAngle(void)
void
SurveyMissionItemTest
::
_testEntryLocation
(
void
)
{
QGCMapPolygon
*
mapPolygon
=
_surveyItem
->
mapPolygon
();
for
(
int
i
=
0
;
i
<
_polyPoints
.
count
();
i
++
)
{
QGeoCoordinate
&
vertex
=
_polyPoints
[
i
];
mapPolygon
->
appendVertex
(
vertex
);
}
_setPolygon
();
for
(
double
gridAngle
=-
360.0
;
gridAngle
<=
360.0
;
gridAngle
++
)
{
_surveyItem
->
gridAngle
()
->
setRawValue
(
gridAngle
);
...
...
@@ -251,3 +249,39 @@ void SurveyMissionItemTest::_testEntryLocation(void)
rgSeenEntryCoords
.
clear
();
}
}
void
SurveyMissionItemTest
::
_testItemCount
(
void
)
{
QList
<
MissionItem
*>
items
;
_setPolygon
();
_surveyItem
->
hoverAndCapture
()
->
setRawValue
(
false
);
_surveyItem
->
cameraTriggerInTurnaround
()
->
setRawValue
(
false
);
_surveyItem
->
setRefly90Degrees
(
false
);
_surveyItem
->
appendMissionItems
(
items
,
this
);
QCOMPARE
(
items
.
count
(),
_surveyItem
->
lastSequenceNumber
());
items
.
clear
();
_surveyItem
->
hoverAndCapture
()
->
setRawValue
(
false
);
_surveyItem
->
cameraTriggerInTurnaround
()
->
setRawValue
(
true
);
_surveyItem
->
setRefly90Degrees
(
false
);
_surveyItem
->
appendMissionItems
(
items
,
this
);
QCOMPARE
(
items
.
count
(),
_surveyItem
->
lastSequenceNumber
());
items
.
clear
();
_surveyItem
->
hoverAndCapture
()
->
setRawValue
(
true
);
_surveyItem
->
cameraTriggerInTurnaround
()
->
setRawValue
(
false
);
_surveyItem
->
setRefly90Degrees
(
false
);
_surveyItem
->
appendMissionItems
(
items
,
this
);
QCOMPARE
(
items
.
count
(),
_surveyItem
->
lastSequenceNumber
());
items
.
clear
();
_surveyItem
->
hoverAndCapture
()
->
setRawValue
(
true
);
_surveyItem
->
cameraTriggerInTurnaround
()
->
setRawValue
(
false
);
_surveyItem
->
setRefly90Degrees
(
true
);
_surveyItem
->
appendMissionItems
(
items
,
this
);
QCOMPARE
(
items
.
count
(),
_surveyItem
->
lastSequenceNumber
());
items
.
clear
();
}
src/MissionManager/SurveyMissionItemTest.h
View file @
42eeb4ee
...
...
@@ -36,9 +36,11 @@ private slots:
void
_testCameraTrigger
(
void
);
void
_testGridAngle
(
void
);
void
_testEntryLocation
(
void
);
void
_testItemCount
(
void
);
private:
double
_clampGridAngle180
(
double
gridAngle
);
void
_setPolygon
(
void
);
enum
{
gridPointsChangedIndex
=
0
,
...
...
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