Here is a screenshot of my schematic:
For the batteries, we plan to Lithium Ultimate Energizers, as those have been proven to work at high altitudes.
We have special servos that have a very little start/stall current too. I'll attach a photo of the servos with the glider and the current flight controller:
As far as the code, I'm still confused why this snippet doesn't work:
void loop()
{
get_MPU_scaled();
now = micros();
deltat = (now - last) * 1.0e-6; //seconds since last update
last = now;
// correct for differing accelerometer and magnetometer alignment by circularly permuting mag axes
MahonyQuaternionUpdate(Axyz[0], Axyz[1], Axyz[2], Gxyz[0], Gxyz[1], Gxyz[2],
Mxyz[1], Mxyz[0], -Mxyz[2], deltat);
// Standard orientation: X North, Y West, Z Up
// Tait-Bryan angles as well as Euler angles are
// non-commutative; that is, the get the correct orientation the rotations
// must be applied in the correct order which for this configuration is yaw,
// pitch, and then roll.
// http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
// which has additional links.
// Strictly valid only for approximately level movement
// WARNING: This angular conversion is for DEMONSTRATION PURPOSES ONLY. It WILL
// MALFUNCTION for certain combinations of angles! See https://en.wikipedia.org/wiki/Gimbal_lock
roll = atan2((q[0] * q[1] + q[2] * q[3]), 0.5 - (q[1] * q[1] + q[2] * q[2]));
pitch = asin(2.0 * (q[0] * q[2] - q[1] * q[3]));
yaw = atan2((q[1] * q[2] + q[0] * q[3]), 0.5 - ( q[2] * q[2] + q[3] * q[3]));
// to degrees
yaw *= 180.0 / PI;
pitch *= 180.0 / PI;
roll *= 180.0 / PI;
get_MPU_scaled();
now = micros();
deltat = (now - last) * 1.0e-6; //seconds since last update
last = now;
// correct for differing accelerometer and magnetometer alignment by circularly permuting mag axes
MahonyQuaternionUpdate(Axyz[0], Axyz[1], Axyz[2], Gxyz[0], Gxyz[1], Gxyz[2],
Mxyz[1], Mxyz[0], -Mxyz[2], deltat);
// Standard orientation: X North, Y West, Z Up
// Tait-Bryan angles as well as Euler angles are
// non-commutative; that is, the get the correct orientation the rotations
// must be applied in the correct order which for this configuration is yaw,
// pitch, and then roll.
// http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
// which has additional links.
// Strictly valid only for approximately level movement
// WARNING: This angular conversion is for DEMONSTRATION PURPOSES ONLY. It WILL
// MALFUNCTION for certain combinations of angles! See https://en.wikipedia.org/wiki/Gimbal_lock
roll = atan2((q[0] * q[1] + q[2] * q[3]), 0.5 - (q[1] * q[1] + q[2] * q[2]));
pitch = asin(2.0 * (q[0] * q[2] - q[1] * q[3]));
yaw = atan2((q[1] * q[2] + q[0] * q[3]), 0.5 - ( q[2] * q[2] + q[3] * q[3]));
// to degrees
yaw *= 180.0 / PI;
pitch *= 180.0 / PI;
roll *= 180.0 / PI;
// http://www.ngdc.noaa.gov/geomag-web/#declination
//conventional nav, yaw increases CW from North, corrected for local magnetic declination
yaw = -yaw + 14.5;
if(yaw<0) yaw += 360.0;
if(yaw>360.0) yaw -= 360.0;
Serial.print(yaw, 0);
Serial.print(", ");
Serial.print(pitch, 0);
Serial.print(", ");
Serial.println(roll, 0);
delay(1000);
}
Thanks again for all your help!