From 74f3755e03c677d550301ebff0cbaee9a6a6e754 Mon Sep 17 00:00:00 2001 From: DoinLakeFlyer Date: Thu, 5 Mar 2020 12:53:37 -0800 Subject: [PATCH] Correctly set altitude for land commands to 0. VTOL will insert a VTOL_LAND for a land command. --- src/MissionManager/MissionController.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/MissionManager/MissionController.cc b/src/MissionManager/MissionController.cc index 580991034..4e06ce00a 100644 --- a/src/MissionManager/MissionController.cc +++ b/src/MissionManager/MissionController.cc @@ -348,12 +348,15 @@ VisualMissionItem* MissionController::_insertSimpleMissionItemWorker(QGeoCoordin _initVisualItem(newItem); if (newItem->specifiesAltitude()) { - double prevAltitude; - int prevAltitudeMode; - - if (_findPreviousAltitude(visualItemIndex, &prevAltitude, &prevAltitudeMode)) { - newItem->altitude()->setRawValue(prevAltitude); - newItem->setAltitudeMode(static_cast(prevAltitudeMode)); + const MissionCommandUIInfo* uiInfo = qgcApp()->toolbox()->missionCommandTree()->getUIInfo(_controllerVehicle, command); + if (!uiInfo->isLandCommand()) { + double prevAltitude; + int prevAltitudeMode; + + if (_findPreviousAltitude(visualItemIndex, &prevAltitude, &prevAltitudeMode)) { + newItem->altitude()->setRawValue(prevAltitude); + newItem->setAltitudeMode(static_cast(prevAltitudeMode)); + } } } newItem->setMissionFlightStatus(_missionFlightStatus); @@ -418,7 +421,7 @@ VisualMissionItem* MissionController::insertLandItem(QGeoCoordinate coordinate, fwLanding->setLoiterDragAngleOnly(true); return fwLanding; } else { - return _insertSimpleMissionItemWorker(coordinate, MAV_CMD_NAV_RETURN_TO_LAUNCH, visualItemIndex, makeCurrentItem); + return _insertSimpleMissionItemWorker(coordinate, _managerVehicle->vtol() ? MAV_CMD_NAV_VTOL_LAND : MAV_CMD_NAV_RETURN_TO_LAUNCH, visualItemIndex, makeCurrentItem); } } -- 2.22.0