if (calibratingG>0) { for (axis = 0; axis < 3; axis++) { // Reset g[axis] at start of calibration if (calibratingG == 400) g[axis]=0; // Sum up 400 readings g[axis] +=gyroADC[axis]; // Clear global variables for next reading gyroADC[axis]=0; gyroZero[axis]=0; if (calibratingG == 1) { gyroZero[axis]=g[axis]/400; blinkLED(10,15,1+3*nunchuk); } } calibratingG--; } for (axis = 0; axis < 3; axis++) { gyroADC[axis] -= gyroZero[axis]; //anti gyro glitch, limit the variation between two consecutive readings gyroADC[axis] = constrain(gyroADC[axis],previousGyroADC[axis]-800,previousGyroADC[axis]+800); previousGyroADC[axis] = gyroADC[axis]; } int roll,pitch,yaw;
// BUG Correction GYRO_ORIENTATION is not applied when you have WMP // You must save it to exclude swap between vars roll=gyroADC[ROLL]; pitch=gyroADC[PITCH]; yaw=gyroADC[YAW]; GYRO_ORIENTATION( roll, pitch, yaw); }
// BUG Correction GYRO_ORIENTATION is not applied when you have WMP // You must save it to exclude swap between vars roll=gyroADC[ROLL]; pitch=gyroADC[PITCH]; yaw=gyroADC[YAW]; GYRO_ORIENTATION( roll, pitch, yaw);
In the last dev version there aren't these lines of code to apply different orientation also to a Wii sensors. Please add it.
if (calibratingG>0) { for (axis = 0; axis < 3; axis++) { // Reset g[axis] at start of calibration if (calibratingG == 400) g[axis]=0; // Sum up 400 readings g[axis] +=gyroADC[axis]; // Clear global variables for next reading gyroADC[axis]=0; gyroZero[axis]=0; if (calibratingG == 1) { gyroZero[axis]=g[axis]/400; blinkLED(10,15,1+3*nunchuk); } } calibratingG--; } for (axis = 0; axis < 3; axis++) { gyroADC[axis] -= gyroZero[axis]; //anti gyro glitch, limit the variation between two consecutive readings gyroADC[axis] = constrain(gyroADC[axis],previousGyroADC[axis]-800,previousGyroADC[axis]+800); previousGyroADC[axis] = gyroADC[axis]; } int roll,pitch,yaw;
// BUG Correction GYRO_ORIENTATION is not applied when you have WMP // You must save it to exclude swap between vars roll=gyroADC[ROLL]; pitch=gyroADC[PITCH]; yaw=gyroADC[YAW]; GYRO_ORIENTATION( roll, pitch, yaw); }
Doing this at this place in the code would create a double switch axis for all non other WMP gyro. (GYRO_ORIENTATION would be applied twice) This code should work, but in the WMP part code only, not in GYRO_common part.
Would it be possible to fix this bug within the next release? I would also move the GYRO_ORIENTATION macro into Gyro_common, because it affects all Gyro sensors and you follow the rules of "Don't repeat yourself".
Hi all, I added Gyro orientation for WMP only here, and modified the orientation in the last (as default commented) lines of "Config.h", and already done some test flight and seems run OK with quad + configuration.