From 905de2736c67bac7af15b5d89c7b576a216ac2d4 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Fri, 5 Jan 2018 12:58:15 -0800 Subject: [PATCH] Handle 0 from param --- src/FirmwarePlugin/APM/APMFirmwarePlugin.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc b/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc index b2e399a07..744114b39 100644 --- a/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc +++ b/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc @@ -913,14 +913,19 @@ void APMFirmwarePlugin::guidedModeTakeoff(Vehicle* vehicle, double altitudeRel) double APMFirmwarePlugin::minimumTakeoffAltitude(Vehicle* vehicle) { + double minTakeoffAlt = 0; QString takeoffAltParam(vehicle->vtol() ? QStringLiteral("Q_RTL_ALT") : QStringLiteral("PILOT_TKOFF_ALT")); float paramDivisor = vehicle->vtol() ? 1.0 : 100.0; // PILOT_TAKEOFF_ALT is in centimeters if (vehicle->parameterManager()->parameterExists(FactSystem::defaultComponentId, takeoffAltParam)) { - return vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, takeoffAltParam)->rawValue().toDouble() / paramDivisor; - } else { - return FirmwarePlugin::minimumTakeoffAltitude(vehicle); + minTakeoffAlt = vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, takeoffAltParam)->rawValue().toDouble() / paramDivisor; + } + + if (minTakeoffAlt == 0) { + minTakeoffAlt = FirmwarePlugin::minimumTakeoffAltitude(vehicle); } + + return minTakeoffAlt; } bool APMFirmwarePlugin::_guidedModeTakeoff(Vehicle* vehicle, double altitudeRel) -- 2.22.0