1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

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
This commit is contained in:
edouard 2010-09-04 07:21:13 +00:00 committed by edouard
parent cd93574511
commit 24f5023e10

View File

@ -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 {