1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-82 : More small improvements in move precision.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@877 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-06-23 22:31:05 +00:00 committed by edouard
parent ee2e21e7e1
commit df2bed8dd0

View File

@ -127,6 +127,7 @@ void PFDGadgetWidget::updateHeading(UAVObject *object1) {
// - Heading value in degrees // - Heading value in degrees
// - Scale is 540 degrees large // - Scale is 540 degrees large
headingTarget = field->getDouble()*compassBandWidth/(-540); headingTarget = field->getDouble()*compassBandWidth/(-540);
if (!dialTimer.isActive()) if (!dialTimer.isActive())
dialTimer.start(); // Rearm the dial Timer which might be stopped. dialTimer.start(); // Rearm the dial Timer which might be stopped.
} else { } else {
@ -315,41 +316,36 @@ void PFDGadgetWidget::resizeEvent(QResizeEvent *event)
// //
void PFDGadgetWidget::rotateNeedles() void PFDGadgetWidget::rotateNeedles()
{ {
int dialCount = 3; int dialCount = 3; // Gets decreased by one for each element
if ((abs((rollValue-rollTarget)*10) > 5)) { // which has finished moving
double rollDiff;
rollDiff =(rollTarget - rollValue)/5;
m_world->setRotation(m_world->rotation()+rollDiff);
m_rollscale->setRotation(m_rollscale->rotation()+rollDiff);
rollValue += rollDiff;
} else {
// This avoids any sort of offset resulting from rounding
// errors on the dichotomy above
rollValue = rollTarget;
m_world->setRotation(rollValue);
m_rollscale->setRotation(rollValue);
dialCount--;
}
if ((abs((pitchValue-pitchTarget)*10) > 5)) { double rollDiff;
double pitchDiff; if ((abs((rollValue-rollTarget)*10) > 5)) {
pitchDiff = (pitchTarget - pitchValue)/5; rollDiff =(rollTarget - rollValue)/5;
QPointF opd = QPointF(0,pitchDiff);
m_world->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true);
QPointF oop = m_world->transformOriginPoint();
m_world->setTransformOriginPoint((oop.x()-opd.x()),(oop.y()-opd.y()));
pitchValue += pitchDiff;
} else { } else {
pitchValue = pitchTarget; rollDiff = rollTarget - rollValue;
// TODO: should maybe reset the transformOriginpoint here one last
// time with the pitchValue=pitchTarget ? To be checked later.
dialCount--; dialCount--;
} }
m_world->setRotation(m_world->rotation()+rollDiff);
m_rollscale->setRotation(m_rollscale->rotation()+rollDiff);
rollValue += rollDiff;
double pitchDiff;
if ((abs((pitchValue-pitchTarget)*10) > 5)) {
pitchDiff = (pitchTarget - pitchValue)/5;
} else {
pitchDiff = pitchTarget - pitchValue;
dialCount--;
}
QPointF opd = QPointF(0,pitchDiff);
m_world->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true);
QPointF oop = m_world->transformOriginPoint();
m_world->setTransformOriginPoint((oop.x()-opd.x()),(oop.y()-opd.y()));
pitchValue += pitchDiff;
double headingOffset = 0; double headingOffset = 0;
double headingDiff; double headingDiff;
if ((abs((headingValue-headingTarget)*10) > 5)) { if ((abs((headingValue-headingTarget)*10) > 5)) {
headingDiff = (headingTarget - headingValue)/5; headingDiff = (headingTarget - headingValue)/5;
} else { } else {
headingDiff = headingTarget-headingValue; headingDiff = headingTarget-headingValue;
@ -365,11 +361,11 @@ void PFDGadgetWidget::rotateNeedles()
// We went under 180°: remove the -360 degree offset // We went under 180°: remove the -360 degree offset
headingOffset = -2*threshold; headingOffset = -2*threshold;
} }
QPointF opd = QPointF(headingDiff+headingOffset,0); opd = QPointF(headingDiff+headingOffset,0);
m_compassband->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true); m_compassband->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true);
headingValue += headingDiff; headingValue += headingDiff;
update(); //update();
if (!dialCount) if (!dialCount)
dialTimer.stop(); dialTimer.stop();
} }