From 8f0e4e7f8695840a30edfbf45e025112887d868f Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 28 Dec 2015 15:11:19 -0800 Subject: [PATCH] Fix backwards APM Stack Pitch setting --- .../Common/RadioComponentController.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/AutoPilotPlugins/Common/RadioComponentController.cc b/src/AutoPilotPlugins/Common/RadioComponentController.cc index b4e8cb3fb..abf2e726b 100644 --- a/src/AutoPilotPlugins/Common/RadioComponentController.cc +++ b/src/AutoPilotPlugins/Common/RadioComponentController.cc @@ -854,7 +854,15 @@ void RadioComponentController::_writeCalibration(void) getParameterFact(FactSystem::defaultComponentId, trimTpl.arg(oneBasedChannel))->setRawValue((float)info->rcTrim); getParameterFact(FactSystem::defaultComponentId, minTpl.arg(oneBasedChannel))->setRawValue((float)info->rcMin); getParameterFact(FactSystem::defaultComponentId, maxTpl.arg(oneBasedChannel))->setRawValue((float)info->rcMax); - getParameterFact(FactSystem::defaultComponentId, revTpl.arg(oneBasedChannel))->setRawValue(info->reversed ? -1.0f : 1.0f); + + // APM has a backwards interpretation of "reversed" on the Pitch control. So be careful. + float reversedParamValue; + if (_px4Vehicle() || info->function != rcCalFunctionPitch) { + reversedParamValue = info->reversed ? -1.0f : 1.0f; + } else { + reversedParamValue = info->reversed ? 1.0f : -1.0f; + } + getParameterFact(FactSystem::defaultComponentId, revTpl.arg(oneBasedChannel))->setRawValue(reversedParamValue); } // Write function mapping parameters -- 2.22.0