Unverified Commit b1e5c012 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8689 from DonLakeFlyer/TransectFixes

Plan - Terrain Follow: Fix tolerance adjustment step
parents d2c7be09 e6e812d6
...@@ -16,12 +16,13 @@ import QGroundControl.Controls 1.0 ...@@ -16,12 +16,13 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
FactTextField { FactTextField {
unitsLabel: fact ? fact.units : "" unitsLabel: fact ? fact.units : ""
extraUnitsLabel: fact ? _altitudeModeExtraUnits : "" extraUnitsLabel: fact ? _altitudeModeExtraUnits : ""
showUnits: true showUnits: true
showHelp: true showHelp: true
property int altitudeMode: QGroundControl.AltitudeModeNone property int altitudeMode: QGroundControl.AltitudeModeNone
property bool showAboveTerrainWarning: true
readonly property string _altModeNoneExtraUnits: "" readonly property string _altModeNoneExtraUnits: ""
readonly property string _altModeRelativeExtraUnits: qsTr("(Rel)") readonly property string _altModeRelativeExtraUnits: qsTr("(Rel)")
...@@ -44,7 +45,7 @@ FactTextField { ...@@ -44,7 +45,7 @@ FactTextField {
_altitudeModeExtraUnits = _altModeAbsoluteExtraUnits _altitudeModeExtraUnits = _altModeAbsoluteExtraUnits
} else if (altitudeMode === QGroundControl.AltitudeModeAboveTerrain) { } else if (altitudeMode === QGroundControl.AltitudeModeAboveTerrain) {
_altitudeModeExtraUnits = _altModeAboveTerrainExtraUnits _altitudeModeExtraUnits = _altModeAboveTerrainExtraUnits
if (!_aboveTerrainWarning.rawValue) { if (!_aboveTerrainWarning.rawValue && showAboveTerrainWarning) {
mainWindow.showComponentDialog(aboveTerrainWarning, qsTr("Warning"), mainWindow.showDialogDefaultWidth, StandardButton.Ok) mainWindow.showComponentDialog(aboveTerrainWarning, qsTr("Warning"), mainWindow.showDialogDefaultWidth, StandardButton.Ok)
} }
} else if (missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame) { } else if (missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame) {
......
...@@ -29,7 +29,7 @@ const char* CameraCalc::_jsonCameraSpecTypeKey = "CameraSpecType"; ...@@ -29,7 +29,7 @@ const char* CameraCalc::_jsonCameraSpecTypeKey = "CameraSpecType";
CameraCalc::CameraCalc(PlanMasterController* masterController, const QString& settingsGroup, QObject* parent) CameraCalc::CameraCalc(PlanMasterController* masterController, const QString& settingsGroup, QObject* parent)
: CameraSpec (settingsGroup, parent) : CameraSpec (settingsGroup, parent)
, _dirty (masterController) , _dirty (false)
, _disableRecalc (false) , _disableRecalc (false)
, _distanceToSurfaceRelative (true) , _distanceToSurfaceRelative (true)
, _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/CameraCalc.FactMetaData.json"), this)) , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/CameraCalc.FactMetaData.json"), this))
......
...@@ -33,6 +33,13 @@ public: ...@@ -33,6 +33,13 @@ public:
Q_PROPERTY(Fact* sideOverlap READ sideOverlap CONSTANT) Q_PROPERTY(Fact* sideOverlap READ sideOverlap CONSTANT)
Q_PROPERTY(Fact* adjustedFootprintSide READ adjustedFootprintSide CONSTANT) ///< Side footprint adjusted down for overlap Q_PROPERTY(Fact* adjustedFootprintSide READ adjustedFootprintSide CONSTANT) ///< Side footprint adjusted down for overlap
Q_PROPERTY(Fact* adjustedFootprintFrontal READ adjustedFootprintFrontal CONSTANT) ///< Frontal footprint adjusted down for overlap Q_PROPERTY(Fact* adjustedFootprintFrontal READ adjustedFootprintFrontal CONSTANT) ///< Frontal footprint adjusted down for overlap
// When we are creating a manual grid we still use CameraCalc to store the manual grid information. It's a bastardization of what
// CameraCalc is meant for but it greatly simplifies code and persistance of manual grids.
// grid altitude - distanceToSurface
// grid altitude mode - distanceToSurfaceRelative
// trigger distance - adjustedFootprintFrontal
// transect spacing - adjustedFootprintSide
Q_PROPERTY(bool distanceToSurfaceRelative READ distanceToSurfaceRelative WRITE setDistanceToSurfaceRelative NOTIFY distanceToSurfaceRelativeChanged) Q_PROPERTY(bool distanceToSurfaceRelative READ distanceToSurfaceRelative WRITE setDistanceToSurfaceRelative NOTIFY distanceToSurfaceRelativeChanged)
// The following values are calculated from the camera properties // The following values are calculated from the camera properties
......
...@@ -190,7 +190,9 @@ void MissionSettingsItem::_setCoordinateWorker(const QGeoCoordinate& coordinate) ...@@ -190,7 +190,9 @@ void MissionSettingsItem::_setCoordinateWorker(const QGeoCoordinate& coordinate)
_plannedHomePositionCoordinate = coordinate; _plannedHomePositionCoordinate = coordinate;
emit coordinateChanged(coordinate); emit coordinateChanged(coordinate);
emit exitCoordinateChanged(coordinate); emit exitCoordinateChanged(coordinate);
_plannedHomePositionAltitudeFact.setRawValue(coordinate.altitude()); if (_plannedHomePositionFromVehicle) {
_plannedHomePositionAltitudeFact.setRawValue(coordinate.altitude());
}
} }
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
}, },
{ {
"name": "TerrainAdjustTolerance", "name": "TerrainAdjustTolerance",
"shortDescription": "If adjacent terrain waypoints are within this tolerence they will be removed.", "shortDescription": "Additional waypoints within the transect will be added if the terrain altitude difference grows larger than this tolerance.",
"type": "double", "type": "double",
"decimalPlaces": 2, "decimalPlaces": 2,
"min": 0, "min": 0,
......
...@@ -538,6 +538,18 @@ void TransectStyleComplexItem::_adjustTransectsForTerrain(void) ...@@ -538,6 +538,18 @@ void TransectStyleComplexItem::_adjustTransectsForTerrain(void)
} }
emit lastSequenceNumberChanged(lastSequenceNumber()); emit lastSequenceNumberChanged(lastSequenceNumber());
// Update entry/exit coordinates
if (_transects.count()) {
if (_transects.first().count()) {
_coordinate.setAltitude(_transects.first().first().coord.altitude());
emit coordinateChanged(coordinate());
}
if (_transects.last().count()) {
_exitCoordinate.setAltitude(_transects.last().last().coord.altitude());
emit exitCoordinateChanged(exitCoordinate());
}
}
} }
} }
...@@ -653,32 +665,25 @@ void TransectStyleComplexItem::_adjustForTolerance(QList<CoordInfo_t>& transect) ...@@ -653,32 +665,25 @@ void TransectStyleComplexItem::_adjustForTolerance(QList<CoordInfo_t>& transect)
{ {
QList<CoordInfo_t> adjustedPoints; QList<CoordInfo_t> adjustedPoints;
double tolerance = _terrainAdjustToleranceFact.rawValue().toDouble(); if (transect.count()) {
double tolerance = _terrainAdjustToleranceFact.rawValue().toDouble();
int coordIndex = 0; CoordInfo_t& lastCoordInfo = transect.first();
while (coordIndex < transect.count()) {
const CoordInfo_t& fromCoordInfo = transect[coordIndex];
adjustedPoints.append(fromCoordInfo); adjustedPoints.append(lastCoordInfo);
// Walk forward until we fall out of tolerence or find a fixed point int coordIndex = 1;
while (++coordIndex < transect.count()) { while (coordIndex < transect.count()) {
const CoordInfo_t& toCoordInfo = transect[coordIndex]; // Walk forward until we fall out of tolerence. When we fall out of tolerance add that point.
if (toCoordInfo.coordType != CoordTypeInteriorTerrainAdded || qAbs(fromCoordInfo.coord.altitude() - toCoordInfo.coord.altitude()) > tolerance) { // We always add non-interstitial points no matter what.
adjustedPoints.append(toCoordInfo); const CoordInfo_t& nextCoordInfo = transect[coordIndex];
coordIndex++; if (nextCoordInfo.coordType != CoordTypeInteriorTerrainAdded || qAbs(lastCoordInfo.coord.altitude() - nextCoordInfo.coord.altitude()) > tolerance) {
break; adjustedPoints.append(nextCoordInfo);
lastCoordInfo = nextCoordInfo;
} }
coordIndex++;
} }
} }
#if 0
qDebug() << "_adjustForTolerance";
for (const TransectStyleComplexItem::CoordInfo_t& coordInfo: adjustedPoints) {
qDebug() << coordInfo.coordType;
}
#endif
transect = adjustedPoints; transect = adjustedPoints;
} }
...@@ -686,7 +691,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>& ...@@ -686,7 +691,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>&
{ {
QList<CoordInfo_t> adjustedTransect; QList<CoordInfo_t> adjustedTransect;
double requestedAltitude = _cameraCalc.distanceToSurface()->rawValue().toDouble(); double distanceToSurface = _cameraCalc.distanceToSurface()->rawValue().toDouble();
for (int i=0; i<transect.count() - 1; i++) { for (int i=0; i<transect.count() - 1; i++) {
CoordInfo_t fromCoordInfo = transect[i]; CoordInfo_t fromCoordInfo = transect[i];
...@@ -697,8 +702,8 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>& ...@@ -697,8 +702,8 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>&
const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo = transectPathHeightInfo[i]; const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo = transectPathHeightInfo[i];
fromCoordInfo.coord.setAltitude(pathHeightInfo.heights.first() + requestedAltitude); fromCoordInfo.coord.setAltitude(pathHeightInfo.heights.first() + distanceToSurface);
toCoordInfo.coord.setAltitude(pathHeightInfo.heights.last() + requestedAltitude); toCoordInfo.coord.setAltitude(pathHeightInfo.heights.last() + distanceToSurface);
if (i == 0) { if (i == 0) {
adjustedTransect.append(fromCoordInfo); adjustedTransect.append(fromCoordInfo);
...@@ -712,7 +717,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>& ...@@ -712,7 +717,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>&
CoordInfo_t interstitialCoordInfo; CoordInfo_t interstitialCoordInfo;
interstitialCoordInfo.coordType = CoordTypeInteriorTerrainAdded; interstitialCoordInfo.coordType = CoordTypeInteriorTerrainAdded;
interstitialCoordInfo.coord = fromCoordInfo.coord.atDistanceAndAzimuth(distance * percentTowardsTo, azimuth); interstitialCoordInfo.coord = fromCoordInfo.coord.atDistanceAndAzimuth(distance * percentTowardsTo, azimuth);
interstitialCoordInfo.coord.setAltitude(interstitialTerrainHeight + requestedAltitude); interstitialCoordInfo.coord.setAltitude(interstitialTerrainHeight + distanceToSurface);
adjustedTransect.append(interstitialCoordInfo); adjustedTransect.append(interstitialCoordInfo);
} }
...@@ -722,7 +727,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>& ...@@ -722,7 +727,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>&
CoordInfo_t lastCoordInfo = transect.last(); CoordInfo_t lastCoordInfo = transect.last();
const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo = transectPathHeightInfo.last(); const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo = transectPathHeightInfo.last();
lastCoordInfo.coord.setAltitude(pathHeightInfo.heights.last() + requestedAltitude); lastCoordInfo.coord.setAltitude(pathHeightInfo.heights.last() + distanceToSurface);
adjustedTransect.append(lastCoordInfo); adjustedTransect.append(lastCoordInfo);
#if 0 #if 0
......
...@@ -15,11 +15,6 @@ Column { ...@@ -15,11 +15,6 @@ Column {
spacing: _margin spacing: _margin
property var cameraCalc property var cameraCalc
property bool vehicleFlightIsFrontal: true
property string distanceToSurfaceLabel
property int distanceToSurfaceAltitudeMode: QGroundControl.AltitudeModeNone
property string frontalDistanceLabel
property string sideDistanceLabel
property real _margin: ScreenTools.defaultFontPixelWidth / 2 property real _margin: ScreenTools.defaultFontPixelWidth / 2
property string _cameraName: cameraCalc.cameraName.value property string _cameraName: cameraCalc.cameraName.value
......
...@@ -87,21 +87,24 @@ Column { ...@@ -87,21 +87,24 @@ Column {
QGCRadioButton { QGCRadioButton {
id: fixedDistanceRadio id: fixedDistanceRadio
leftPadding: 0
text: distanceToSurfaceLabel text: distanceToSurfaceLabel
checked: !!cameraCalc.valueSetIsDistance.value checked: !!cameraCalc.valueSetIsDistance.value
onClicked: cameraCalc.valueSetIsDistance.value = 1 onClicked: cameraCalc.valueSetIsDistance.value = 1
} }
AltitudeFactTextField { AltitudeFactTextField {
fact: cameraCalc.distanceToSurface fact: cameraCalc.distanceToSurface
altitudeMode: distanceToSurfaceAltitudeMode altitudeMode: distanceToSurfaceAltitudeMode
enabled: fixedDistanceRadio.checked showAboveTerrainWarning: false
Layout.fillWidth: true enabled: fixedDistanceRadio.checked
Layout.fillWidth: true
} }
QGCRadioButton { QGCRadioButton {
id: fixedImageDensityRadio id: fixedImageDensityRadio
text: qsTr("Ground Res") leftPadding: 0
text: qsTr("Grnd Res")
checked: !cameraCalc.valueSetIsDistance.value checked: !cameraCalc.valueSetIsDistance.value
onClicked: cameraCalc.valueSetIsDistance.value = 0 onClicked: cameraCalc.valueSetIsDistance.value = 0
} }
...@@ -125,9 +128,10 @@ Column { ...@@ -125,9 +128,10 @@ Column {
QGCLabel { text: distanceToSurfaceLabel } QGCLabel { text: distanceToSurfaceLabel }
AltitudeFactTextField { AltitudeFactTextField {
fact: cameraCalc.distanceToSurface fact: cameraCalc.distanceToSurface
altitudeMode: distanceToSurfaceAltitudeMode altitudeMode: distanceToSurfaceAltitudeMode
Layout.fillWidth: true showAboveTerrainWarning: false
Layout.fillWidth: true
} }
QGCLabel { text: frontalDistanceLabel } QGCLabel { text: frontalDistanceLabel }
......
...@@ -252,14 +252,7 @@ Rectangle { ...@@ -252,14 +252,7 @@ Rectangle {
visible: tabBar.currentIndex == 1 visible: tabBar.currentIndex == 1
CameraCalcCamera { CameraCalcCamera {
cameraCalc: missionItem.cameraCalc cameraCalc: missionItem.cameraCalc
vehicleFlightIsFrontal: true
distanceToSurfaceLabel: qsTr("Altitude")
distanceToSurfaceAltitudeMode: missionItem.followTerrain ?
QGroundControl.AltitudeModeAboveTerrain :
missionItem.cameraCalc.distanceToSurfaceRelative
frontalDistanceLabel: qsTr("Trigger Dist")
sideDistanceLabel: qsTr("Spacing")
} }
} }
} }
......
...@@ -247,12 +247,7 @@ Rectangle { ...@@ -247,12 +247,7 @@ Rectangle {
visible: tabBar.currentIndex == 1 visible: tabBar.currentIndex == 1
CameraCalcCamera { CameraCalcCamera {
cameraCalc: missionItem.cameraCalc cameraCalc: missionItem.cameraCalc
vehicleFlightIsFrontal: false
distanceToSurfaceLabel: qsTr("Scan Distance")
distanceToSurfaceAltitudeMode: QGroundControl.AltitudeModeNone
frontalDistanceLabel: qsTr("Layer Height")
sideDistanceLabel: qsTr("Trigger Distance")
} }
} }
} }
......
...@@ -280,16 +280,6 @@ Rectangle { ...@@ -280,16 +280,6 @@ Rectangle {
spacing: _margin spacing: _margin
visible: transectsHeader.checked visible: transectsHeader.checked
/*
Temporarily removed due to bug https://github.com/mavlink/qgroundcontrol/issues/7005
FactCheckBox {
text: qsTr("Split concave polygons")
fact: _splitConcave
visible: _splitConcave.visible
property Fact _splitConcave: missionItem.splitConcavePolygons
}
*/
QGCOptionsComboBox { QGCOptionsComboBox {
Layout.fillWidth: true Layout.fillWidth: true
...@@ -405,14 +395,7 @@ Rectangle { ...@@ -405,14 +395,7 @@ Rectangle {
visible: tabBar.currentIndex == 1 visible: tabBar.currentIndex == 1
CameraCalcCamera { CameraCalcCamera {
cameraCalc: missionItem.cameraCalc cameraCalc: missionItem.cameraCalc
vehicleFlightIsFrontal: true
distanceToSurfaceLabel: qsTr("Altitude")
distanceToSurfaceAltitudeMode: missionItem.followTerrain ?
QGroundControl.AltitudeModeAboveTerrain :
missionItem.cameraCalc.distanceToSurfaceRelative
frontalDistanceLabel: qsTr("Trigger Dist")
sideDistanceLabel: qsTr("Spacing")
} }
} // Camera Column } // Camera Column
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment