diff --git a/ChangeLog.md b/ChangeLog.md index 4c282bf4b9b978490706970dd82461574741686a..87f2913b3d5d2863e7a5c7fe84bc1f77a9e6edb6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,7 @@ Note: This file only contains high level features or important fixes. ### 3.4.3 - Not yet released * Fix bug where Resume Mission would not display correctly in some cases. Issue #6835. +* Fix Planned Home Position altitude when no terrain data available. Issue #6846. ### 3.4.2 * Fix bug where new mission items may end up with 0 altitude internally and sent to vehicle while UI shows correct altitude. Issue #6823. diff --git a/src/MissionManager/MissionController.cc b/src/MissionManager/MissionController.cc index f64e55eaa56d46f7c215c7347bc335286fd07d50..233f10af638ef6202cea39f7d3c08a47a8defe9f 100644 --- a/src/MissionManager/MissionController.cc +++ b/src/MissionManager/MissionController.cc @@ -1528,7 +1528,9 @@ void MissionController::_setPlannedHomePositionFromFirstCoordinate(void) VisualMissionItem* item = _visualItems->value(i); if (item->specifiesCoordinate()) { - _settingsItem->setCoordinate(item->coordinate().atDistanceAndAzimuth(30, 0)); + QGeoCoordinate plannedHomeCoord = item->coordinate().atDistanceAndAzimuth(30, 0); + plannedHomeCoord.setAltitude(0); + _settingsItem->setCoordinate(plannedHomeCoord); } } } diff --git a/src/MissionManager/MissionSettingsItem.cc b/src/MissionManager/MissionSettingsItem.cc index af784e7657642303936efb28747395eefde5e52e..912e67fc5737efac2db58528aeff4f49376ff7f8 100644 --- a/src/MissionManager/MissionSettingsItem.cc +++ b/src/MissionManager/MissionSettingsItem.cc @@ -231,7 +231,7 @@ void MissionSettingsItem::setHomePositionFromVehicle(const QGeoCoordinate& coord void MissionSettingsItem::setCoordinate(const QGeoCoordinate& coordinate) { if (_plannedHomePositionCoordinate != coordinate) { - // ArduPilot tends to send crap home positions at initial vehicel boot, discard them + // ArduPilot tends to send crap home positions at initial vehicle boot, discard them if (coordinate.isValid() && (coordinate.latitude() != 0 || coordinate.longitude() != 0)) { _plannedHomePositionCoordinate = coordinate; emit coordinateChanged(coordinate); @@ -269,7 +269,6 @@ void MissionSettingsItem::_updateAltitudeInCoordinate(QVariant value) double newAltitude = value.toDouble(); if (!qFuzzyCompare(_plannedHomePositionCoordinate.altitude(), newAltitude)) { - _plannedHomePositionCoordinate.setAltitude(newAltitude); emit coordinateChanged(_plannedHomePositionCoordinate); emit exitCoordinateChanged(_plannedHomePositionCoordinate); @@ -295,7 +294,7 @@ void MissionSettingsItem::setMissionEndRTL(bool missionEndRTL) void MissionSettingsItem::_setHomeAltFromTerrain(double terrainAltitude) { - if (!_plannedHomePositionFromVehicle) { + if (!_plannedHomePositionFromVehicle && !qIsNaN(terrainAltitude)) { _plannedHomePositionAltitudeFact.setRawValue(terrainAltitude); } }