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

Merge pull request #6851 from mavlink/plannedHomeAlt_3.4

Fix terrain NaN making it all the way to Planned Home altitude
parents 1bd2ba52 2c2808b0
......@@ -1533,7 +1533,9 @@ void MissionController::_setPlannedHomePositionFromFirstCoordinate(void)
VisualMissionItem* item = _visualItems->value<VisualMissionItem*>(i);
if (item->specifiesCoordinate()) {
_settingsItem->setCoordinate(item->coordinate().atDistanceAndAzimuth(30, 0));
QGeoCoordinate plannedHomeCoord = item->coordinate().atDistanceAndAzimuth(30, 0);
plannedHomeCoord.setAltitude(0);
_settingsItem->setCoordinate(plannedHomeCoord);
}
}
}
......
......@@ -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);
}
}
......
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