aastha11 / aeroquad

Automatically exported from code.google.com/p/aeroquad
0 stars 0 forks source link

In the 2.1 beta in gyro.h there is large code in measure() without side effefcts #50

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. In Gyro.g there is
    // ************ Correct for gyro drift by FabQuad **************  
    // ************ http://aeroquad.com/entry.php?4-  **************
    // Modified FabQuad's approach to use yaw transmitter command instead of checking accelerometer
    if (abs(lastReceiverYaw - receiverYaw) < 15) {
      yawAge++;
      if (yawAge >= 4) {  // if gyro was the same long enough, we can assume that there is no (fast) rotation
        if (gyroData[YAW] < 0) { 
          negativeGyroYawCount++; // if gyro still indicates negative rotation, that's additional signal that gyroZero is too low
        }
        else if (gyroData[YAW] > 0) {
          positiveGyroYawCount++;  // additional signal that gyroZero is too high
        }
        else {
          zeroGyroYawCount++; // additional signal that gyroZero is correct
        }
        yawAge = 0;
        if (zeroGyroYawCount + negativeGyroYawCount + positiveGyroYawCount > 50) {
          if (negativeGyroYawCount >= 1.3*(zeroGyroYawCount+positiveGyroYawCount)) gyroZero[YAW]--;  // enough signals the gyroZero is too low
          if (positiveGyroYawCount >= 1.3*(zeroGyroYawCount+negativeGyroYawCount)) gyroZero[YAW]++;  // enough signals the gyroZero is too high
          zeroGyroYawCount=0;
          negativeGyroYawCount=0;
          positiveGyroYawCount=0; 
        }
      }
    }
    else { // gyro different, restart
      lastReceiverYaw = receiverYaw;
      yawAge = 0;
    }

All new variables for this part are defined global, but I see so usage of them 
anywhere. I see no effect of this code at all besides wasting time. Did I miss 
it ?

Original issue reported on code.google.com by al...@arcor.de on 1 Dec 2010 at 12:00

GoogleCodeExporter commented 8 years ago
Yes, if you comment this out and watch the heading, you will notice that it 
will start to drift.  This code fixes yaw gyro drift when there is no receiver 
yaw input.

Original comment by CaranchoEngineering@gmail.com on 4 Dec 2010 at 9:31