From 24f5023e10051ee161604a6493a1f348289ba70c Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 4 Sep 2010 07:21:13 +0000 Subject: [PATCH] Ground/PFD : fixed the heading issue. Careful with this code, it's precision mechanics ;-) git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1523 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/pfd/pfdgadgetwidget.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ground/src/plugins/pfd/pfdgadgetwidget.cpp b/ground/src/plugins/pfd/pfdgadgetwidget.cpp index 3a2229b63..a9ca1aac9 100644 --- a/ground/src/plugins/pfd/pfdgadgetwidget.cpp +++ b/ground/src/plugins/pfd/pfdgadgetwidget.cpp @@ -247,11 +247,15 @@ void PFDGadgetWidget::updateAttitude(UAVObject *object1) { } pitchTarget = floor(object1->getField(QString("Pitch"))->getDouble()*7.5); + // These factors assume some things about the PFD SVG, namely: + // - Heading value in degrees + // - "Scale" element is 540 degrees wide + // Corvus Corax: "If you want a smooth transition between two angles, It is usually solved that by substracting // one from another, and if the result is >180 or <-180 I substract (respectively add) 360 degrees // to it. That way you always get the "shorter difference" to turn in." double fac = compassBandWidth/540; - headingTarget = yawField->getDouble(); + headingTarget = yawField->getDouble()*(-fac); if ((headingValue - headingTarget)/fac > 180) { headingTarget += 360*fac; } else if (((headingValue - headingTarget)/fac < -180)) { @@ -905,7 +909,7 @@ void PFDGadgetWidget::moveNeedles() headingDiff += 2*threshold; headingTarget += 2*threshold; } - QPointF opd = QPointF(-headingDiff*2.65,0); + QPointF opd = QPointF(headingDiff,0); m_compassband->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true); headingValue += headingDiff; } else {