1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 23:35:34 +03:00

Merge pull request #3799 from adrianmiriuta/HEADFREE_MAG

HEADFREE true 3D (second edition)...
This commit is contained in:
Michael Keller 2017-10-12 00:01:23 +13:00 committed by GitHub
commit a7deb8b899
11 changed files with 181 additions and 92 deletions

View file

@ -404,4 +404,5 @@ extern "C" {
void changePidProfile(uint8_t) {}
void dashboardEnablePageCycling(void) {}
void dashboardDisablePageCycling(void) {}
bool imuQuaternionHeadfreeOffsetSet(void) { return true; }
}

View file

@ -56,7 +56,7 @@ extern "C" {
void imuComputeRotationMatrix(void);
void imuUpdateEulerAngles(void);
extern float q0, q1, q2, q3;
extern quaternion q;
extern float rMat[3][3];
PG_REGISTER(rcControlsConfig_t, rcControlsConfig, PG_RC_CONTROLS_CONFIG, 0);
@ -79,10 +79,10 @@ TEST(FlightImuTest, TestCalculateRotationMatrix)
#define TOL 1e-6
// No rotation
q0 = 1.0f;
q1 = 0.0f;
q2 = 0.0f;
q3 = 0.0f;
q.w = 1.0f;
q.x = 0.0f;
q.y = 0.0f;
q.z = 0.0f;
imuComputeRotationMatrix();
@ -97,10 +97,10 @@ TEST(FlightImuTest, TestCalculateRotationMatrix)
EXPECT_FLOAT_EQ(1.0f, rMat[2][2]);
// 90 degrees around Z axis
q0 = sqrt2over2;
q1 = 0.0f;
q2 = 0.0f;
q3 = sqrt2over2;
q.w = sqrt2over2;
q.x = 0.0f;
q.y = 0.0f;
q.z = sqrt2over2;
imuComputeRotationMatrix();
@ -115,10 +115,10 @@ TEST(FlightImuTest, TestCalculateRotationMatrix)
EXPECT_NEAR(1.0f, rMat[2][2], TOL);
// 60 degrees around X axis
q0 = 0.866f;
q1 = 0.5f;
q2 = 0.0f;
q3 = 0.0f;
q.w = 0.866f;
q.x = 0.5f;
q.y = 0.0f;
q.z = 0.0f;
imuComputeRotationMatrix();