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
6233aba8
Commit
6233aba8
authored
Mar 04, 2017
by
Don Gagne
Committed by
GitHub
Mar 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4709 from DonLakeFlyer/FWLandingPersistence
Support Fixed Wing Landing Pattern file persistence
parents
3d8afe13
14474c94
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
24 deletions
+102
-24
FixedWingLandingComplexItem.cc
src/MissionManager/FixedWingLandingComplexItem.cc
+83
-24
FixedWingLandingComplexItem.h
src/MissionManager/FixedWingLandingComplexItem.h
+9
-0
MissionController.cc
src/MissionManager/MissionController.cc
+10
-0
No files found.
src/MissionManager/FixedWingLandingComplexItem.cc
View file @
6233aba8
...
@@ -25,6 +25,13 @@ const char* FixedWingLandingComplexItem::_loiterAltitudeName = "Loiter
...
@@ -25,6 +25,13 @@ const char* FixedWingLandingComplexItem::_loiterAltitudeName = "Loiter
const
char
*
FixedWingLandingComplexItem
::
_loiterRadiusName
=
"Loiter radius"
;
const
char
*
FixedWingLandingComplexItem
::
_loiterRadiusName
=
"Loiter radius"
;
const
char
*
FixedWingLandingComplexItem
::
_landingAltitudeName
=
"Landing altitude"
;
const
char
*
FixedWingLandingComplexItem
::
_landingAltitudeName
=
"Landing altitude"
;
const
char
*
FixedWingLandingComplexItem
::
_jsonLoiterCoordinateKey
=
"loiterCoordinate"
;
const
char
*
FixedWingLandingComplexItem
::
_jsonLoiterRadiusKey
=
"loiterRadius"
;
const
char
*
FixedWingLandingComplexItem
::
_jsonLoiterClockwiseKey
=
"loiterClockwise"
;
const
char
*
FixedWingLandingComplexItem
::
_jsonLoiterAltitudeRelativeKey
=
"loiterAltitudeRelative"
;
const
char
*
FixedWingLandingComplexItem
::
_jsonLandingCoordinateKey
=
"landCoordinate"
;
const
char
*
FixedWingLandingComplexItem
::
_jsonLandingAltitudeRelativeKey
=
"landAltitudeRelative"
;
QMap
<
QString
,
FactMetaData
*>
FixedWingLandingComplexItem
::
_metaDataMap
;
QMap
<
QString
,
FactMetaData
*>
FixedWingLandingComplexItem
::
_metaDataMap
;
FixedWingLandingComplexItem
::
FixedWingLandingComplexItem
(
Vehicle
*
vehicle
,
QObject
*
parent
)
FixedWingLandingComplexItem
::
FixedWingLandingComplexItem
(
Vehicle
*
vehicle
,
QObject
*
parent
)
...
@@ -60,6 +67,8 @@ FixedWingLandingComplexItem::FixedWingLandingComplexItem(Vehicle* vehicle, QObje
...
@@ -60,6 +67,8 @@ FixedWingLandingComplexItem::FixedWingLandingComplexItem(Vehicle* vehicle, QObje
_landingHeadingFact
.
setRawValue
(
_landingHeadingFact
.
rawDefaultValue
());
_landingHeadingFact
.
setRawValue
(
_landingHeadingFact
.
rawDefaultValue
());
_landingAltitudeFact
.
setRawValue
(
_landingAltitudeFact
.
rawDefaultValue
());
_landingAltitudeFact
.
setRawValue
(
_landingAltitudeFact
.
rawDefaultValue
());
connect
(
&
_loiterAltitudeFact
,
&
Fact
::
valueChanged
,
this
,
&
FixedWingLandingComplexItem
::
_updateLoiterCoodinateAltitudeFromFact
);
connect
(
&
_landingAltitudeFact
,
&
Fact
::
valueChanged
,
this
,
&
FixedWingLandingComplexItem
::
_updateLandingCoodinateAltitudeFromFact
);
connect
(
&
_loiterToLandDistanceFact
,
&
Fact
::
valueChanged
,
this
,
&
FixedWingLandingComplexItem
::
_recalcLoiterCoordFromFacts
);
connect
(
&
_loiterToLandDistanceFact
,
&
Fact
::
valueChanged
,
this
,
&
FixedWingLandingComplexItem
::
_recalcLoiterCoordFromFacts
);
connect
(
&
_landingHeadingFact
,
&
Fact
::
valueChanged
,
this
,
&
FixedWingLandingComplexItem
::
_recalcLoiterCoordFromFacts
);
connect
(
&
_landingHeadingFact
,
&
Fact
::
valueChanged
,
this
,
&
FixedWingLandingComplexItem
::
_recalcLoiterCoordFromFacts
);
connect
(
this
,
&
FixedWingLandingComplexItem
::
loiterCoordinateChanged
,
this
,
&
FixedWingLandingComplexItem
::
_recalcFactsFromCoords
);
connect
(
this
,
&
FixedWingLandingComplexItem
::
loiterCoordinateChanged
,
this
,
&
FixedWingLandingComplexItem
::
_recalcFactsFromCoords
);
...
@@ -86,7 +95,23 @@ void FixedWingLandingComplexItem::save(QJsonObject& saveObject) const
...
@@ -86,7 +95,23 @@ void FixedWingLandingComplexItem::save(QJsonObject& saveObject) const
saveObject
[
VisualMissionItem
::
jsonTypeKey
]
=
VisualMissionItem
::
jsonTypeComplexItemValue
;
saveObject
[
VisualMissionItem
::
jsonTypeKey
]
=
VisualMissionItem
::
jsonTypeComplexItemValue
;
saveObject
[
ComplexMissionItem
::
jsonComplexItemTypeKey
]
=
jsonComplexItemTypeValue
;
saveObject
[
ComplexMissionItem
::
jsonComplexItemTypeKey
]
=
jsonComplexItemTypeValue
;
// FIXME: Need real implementation
QGeoCoordinate
coordinate
;
QJsonValue
jsonCoordinate
;
coordinate
=
_loiterCoordinate
;
coordinate
.
setAltitude
(
_loiterAltitudeFact
.
rawValue
().
toDouble
());
JsonHelper
::
saveGeoCoordinate
(
coordinate
,
true
/* writeAltitude */
,
jsonCoordinate
);
saveObject
[
_jsonLoiterCoordinateKey
]
=
jsonCoordinate
;
coordinate
=
_landingCoordinate
;
coordinate
.
setAltitude
(
_landingAltitudeFact
.
rawValue
().
toDouble
());
JsonHelper
::
saveGeoCoordinate
(
coordinate
,
true
/* writeAltitude */
,
jsonCoordinate
);
saveObject
[
_jsonLandingCoordinateKey
]
=
jsonCoordinate
;
saveObject
[
_jsonLoiterRadiusKey
]
=
_loiterRadiusFact
.
rawValue
().
toDouble
();
saveObject
[
_jsonLoiterClockwiseKey
]
=
_loiterClockwise
;
saveObject
[
_jsonLoiterAltitudeRelativeKey
]
=
_loiterAltitudeRelative
;
saveObject
[
_jsonLandingAltitudeRelativeKey
]
=
_landingAltitudeRelative
;
}
}
void
FixedWingLandingComplexItem
::
setSequenceNumber
(
int
sequenceNumber
)
void
FixedWingLandingComplexItem
::
setSequenceNumber
(
int
sequenceNumber
)
...
@@ -100,32 +125,57 @@ void FixedWingLandingComplexItem::setSequenceNumber(int sequenceNumber)
...
@@ -100,32 +125,57 @@ void FixedWingLandingComplexItem::setSequenceNumber(int sequenceNumber)
bool
FixedWingLandingComplexItem
::
load
(
const
QJsonObject
&
complexObject
,
int
sequenceNumber
,
QString
&
errorString
)
bool
FixedWingLandingComplexItem
::
load
(
const
QJsonObject
&
complexObject
,
int
sequenceNumber
,
QString
&
errorString
)
{
{
// FIXME: Need real implementation
QList
<
JsonHelper
::
KeyValidateInfo
>
keyInfoList
=
{
Q_UNUSED
(
complexObject
);
{
JsonHelper
::
jsonVersionKey
,
QJsonValue
::
Double
,
true
},
Q_UNUSED
(
sequenceNumber
);
{
VisualMissionItem
::
jsonTypeKey
,
QJsonValue
::
String
,
true
},
{
ComplexMissionItem
::
jsonComplexItemTypeKey
,
QJsonValue
::
String
,
true
},
{
_jsonLoiterCoordinateKey
,
QJsonValue
::
Array
,
true
},
{
_jsonLoiterRadiusKey
,
QJsonValue
::
Double
,
true
},
{
_jsonLoiterClockwiseKey
,
QJsonValue
::
Bool
,
true
},
{
_jsonLoiterAltitudeRelativeKey
,
QJsonValue
::
Bool
,
true
},
{
_jsonLandingCoordinateKey
,
QJsonValue
::
Array
,
true
},
{
_jsonLandingAltitudeRelativeKey
,
QJsonValue
::
Bool
,
true
},
};
if
(
!
JsonHelper
::
validateKeys
(
complexObject
,
keyInfoList
,
errorString
))
{
return
false
;
}
errorString
=
"NYI"
;
QString
itemType
=
complexObject
[
VisualMissionItem
::
jsonTypeKey
].
toString
();
return
false
;
QString
complexType
=
complexObject
[
ComplexMissionItem
::
jsonComplexItemTypeKey
].
toString
();
}
if
(
itemType
!=
VisualMissionItem
::
jsonTypeComplexItemValue
||
complexType
!=
jsonComplexItemTypeValue
)
{
errorString
=
tr
(
"QGroundControl does not support loading this complex mission item type: %1:2"
).
arg
(
itemType
).
arg
(
complexType
);
return
false
;
}
double
FixedWingLandingComplexItem
::
greatestDistanceTo
(
const
QGeoCoordinate
&
other
)
const
setSequenceNumber
(
sequenceNumber
);
{
// FIXME: Need real implementation
Q_UNUSED
(
other
);
double
greatestDistance
=
0.0
;
QGeoCoordinate
coordinate
;
if
(
!
JsonHelper
::
loadGeoCoordinate
(
complexObject
[
_jsonLoiterCoordinateKey
],
true
/* altitudeRequired */
,
coordinate
,
errorString
))
{
return
false
;
}
_loiterCoordinate
=
coordinate
;
_loiterAltitudeFact
.
setRawValue
(
coordinate
.
altitude
());
#if 0
if
(
!
JsonHelper
::
loadGeoCoordinate
(
complexObject
[
_jsonLandingCoordinateKey
],
true
/* altitudeRequired */
,
coordinate
,
errorString
))
{
for (int i=0; i<_gridPoints.count(); i++) {
return
false
;
QGeoCoordinate currentCoord = _gridPoints[i].value<QGeoCoordinate>();
double distance = currentCoord.distanceTo(other);
if (distance > greatestDistance) {
greatestDistance = distance;
}
}
}
#endif
_landingCoordinate
=
coordinate
;
_landingAltitudeFact
.
setRawValue
(
coordinate
.
altitude
());
_loiterRadiusFact
.
setRawValue
(
complexObject
[
_jsonLoiterRadiusKey
].
toDouble
());
_loiterClockwise
=
complexObject
[
_jsonLoiterClockwiseKey
].
toBool
();
_loiterAltitudeRelative
=
complexObject
[
_jsonLoiterAltitudeRelativeKey
].
toBool
();
_landingAltitudeRelative
=
complexObject
[
_jsonLandingAltitudeRelativeKey
].
toBool
();
return
greatestDistance
;
_landingCoordSet
=
true
;
_recalcFactsFromCoords
();
return
true
;
}
double
FixedWingLandingComplexItem
::
greatestDistanceTo
(
const
QGeoCoordinate
&
other
)
const
{
return
qMax
(
_loiterCoordinate
.
distanceTo
(
other
),
_landingCoordinate
.
distanceTo
(
other
));
}
}
bool
FixedWingLandingComplexItem
::
specifiesCoordinate
(
void
)
const
bool
FixedWingLandingComplexItem
::
specifiesCoordinate
(
void
)
const
...
@@ -181,13 +231,12 @@ QmlObjectListModel* FixedWingLandingComplexItem::getMissionItems(void) const
...
@@ -181,13 +231,12 @@ QmlObjectListModel* FixedWingLandingComplexItem::getMissionItems(void) const
double
FixedWingLandingComplexItem
::
complexDistance
(
void
)
const
double
FixedWingLandingComplexItem
::
complexDistance
(
void
)
const
{
{
// FIXME: Need real implementation
return
_loiterCoordinate
.
distanceTo
(
_landingCoordinate
);
return
0
;
}
}
void
FixedWingLandingComplexItem
::
setCruiseSpeed
(
double
cruiseSpeed
)
void
FixedWingLandingComplexItem
::
setCruiseSpeed
(
double
cruiseSpeed
)
{
{
//
FIXME: Need real implementation
//
We don't care about cruise speed
Q_UNUSED
(
cruiseSpeed
);
Q_UNUSED
(
cruiseSpeed
);
}
}
...
@@ -296,3 +345,13 @@ void FixedWingLandingComplexItem::_recalcFactsFromCoords(void)
...
@@ -296,3 +345,13 @@ void FixedWingLandingComplexItem::_recalcFactsFromCoords(void)
_ignoreRecalcSignals
=
false
;
_ignoreRecalcSignals
=
false
;
}
}
}
}
void
FixedWingLandingComplexItem
::
_updateLoiterCoodinateAltitudeFromFact
(
void
)
{
_loiterCoordinate
.
setAltitude
(
_loiterAltitudeFact
.
rawValue
().
toDouble
());
}
void
FixedWingLandingComplexItem
::
_updateLandingCoodinateAltitudeFromFact
(
void
)
{
_landingCoordinate
.
setAltitude
(
_landingAltitudeFact
.
rawValue
().
toDouble
());
}
src/MissionManager/FixedWingLandingComplexItem.h
View file @
6233aba8
...
@@ -93,6 +93,8 @@ signals:
...
@@ -93,6 +93,8 @@ signals:
private
slots
:
private
slots
:
void
_recalcLoiterCoordFromFacts
(
void
);
void
_recalcLoiterCoordFromFacts
(
void
);
void
_recalcFactsFromCoords
(
void
);
void
_recalcFactsFromCoords
(
void
);
void
_updateLoiterCoodinateAltitudeFromFact
(
void
);
void
_updateLandingCoodinateAltitudeFromFact
(
void
);
private:
private:
QPointF
_rotatePoint
(
const
QPointF
&
point
,
const
QPointF
&
origin
,
double
angle
);
QPointF
_rotatePoint
(
const
QPointF
&
point
,
const
QPointF
&
origin
,
double
angle
);
...
@@ -121,6 +123,13 @@ private:
...
@@ -121,6 +123,13 @@ private:
static
const
char
*
_loiterRadiusName
;
static
const
char
*
_loiterRadiusName
;
static
const
char
*
_landingHeadingName
;
static
const
char
*
_landingHeadingName
;
static
const
char
*
_landingAltitudeName
;
static
const
char
*
_landingAltitudeName
;
static
const
char
*
_jsonLoiterCoordinateKey
;
static
const
char
*
_jsonLoiterRadiusKey
;
static
const
char
*
_jsonLoiterClockwiseKey
;
static
const
char
*
_jsonLoiterAltitudeRelativeKey
;
static
const
char
*
_jsonLandingCoordinateKey
;
static
const
char
*
_jsonLandingAltitudeRelativeKey
;
};
};
#endif
#endif
src/MissionManager/MissionController.cc
View file @
6233aba8
...
@@ -488,6 +488,16 @@ bool MissionController::_loadJsonMissionFileV2(Vehicle* vehicle, const QJsonObje
...
@@ -488,6 +488,16 @@ bool MissionController::_loadJsonMissionFileV2(Vehicle* vehicle, const QJsonObje
qCDebug
(
MissionControllerLog
)
<<
"Survey load complete: nextSequenceNumber"
<<
nextSequenceNumber
;
qCDebug
(
MissionControllerLog
)
<<
"Survey load complete: nextSequenceNumber"
<<
nextSequenceNumber
;
visualItems
->
append
(
surveyItem
);
visualItems
->
append
(
surveyItem
);
complexItems
->
append
(
surveyItem
);
complexItems
->
append
(
surveyItem
);
}
else
if
(
complexItemType
==
FixedWingLandingComplexItem
::
jsonComplexItemTypeValue
)
{
qCDebug
(
MissionControllerLog
)
<<
"Loading Fixed Wing Landing Pattern: nextSequenceNumber"
<<
nextSequenceNumber
;
FixedWingLandingComplexItem
*
landingItem
=
new
FixedWingLandingComplexItem
(
vehicle
,
visualItems
);
if
(
!
landingItem
->
load
(
itemObject
,
nextSequenceNumber
++
,
errorString
))
{
return
false
;
}
nextSequenceNumber
=
landingItem
->
lastSequenceNumber
()
+
1
;
qCDebug
(
MissionControllerLog
)
<<
"FW Landing Pattern load complete: nextSequenceNumber"
<<
nextSequenceNumber
;
visualItems
->
append
(
landingItem
);
complexItems
->
append
(
landingItem
);
}
else
{
}
else
{
errorString
=
tr
(
"Unsupported complex item type: %1"
).
arg
(
complexItemType
);
errorString
=
tr
(
"Unsupported complex item type: %1"
).
arg
(
complexItemType
);
}
}
...
...
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