mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Refactored arbitrary gyro and mag alignment.
The original implementation: * removed the old 'alignment' variable * did not require 'ALIGN_CUSTOM' * always used rotation matrix * had no additional per-pid-loop conditional logic. Extract currently unused code into tests. In preparation for either deleting or re-using in validateAndFixConfig. Fix code style of some old boardalignment code. De-duplicate vector rotation code. Now that rotation code is exacted from `alignBoard` and now doesn't use `boardRotation` some if it was similar to the code in `rotateV` in maths.c Use DECIDEGREES for mag and gyro/acc custom alignments. Use unnamed structure instead of `values`. Redefine what 'custom' orientation means. Move alignment test-only code into the tests. Ensure gyro/mag custom alignment settings follow the enum variations. This can't be applied to ALIGN_DEFAULT because, in the case of the MAG, the default isn't actually known until the gyro is detected, see `compassDetect`. OMNIBUSF4/F7 - Don't use ALIGN_DEFAULT in target.h, common_defaults_post.h does this now. Comment cleanup. Delete unused alignment code left from various tests/refactoring efforts. * Please do not squash this commit. Fix SITL build by avoiding structure assignment with anonymous inner struct. The error from the build server was as follows: ```./src/main/common/sensor_alignment.c:49:5: error: missing initializer for field ‘yaw’ of ‘struct <anonymous>’ [-Werror=missing-field-initializers] *sensorAlignment = CUSTOM_ALIGN_CW0_DEG; ^ In file included from ./src/main/common/sensor_alignment.c:27:0: ./src/main/common/sensor_alignment.h:80:17: note: ‘yaw’ declared here int16_t yaw; ^ ``` Cleanup sensor_alignment API.
This commit is contained in:
parent
494b559277
commit
980df1536f
27 changed files with 558 additions and 139 deletions
|
@ -144,9 +144,9 @@ TEST(SensorGyro, Update)
|
|||
EXPECT_FLOAT_EQ(0, gyro.gyroADCf[Z]);
|
||||
fakeGyroSet(gyroDevPtr, 15, 26, 97);
|
||||
gyroUpdate(currentTimeUs);
|
||||
EXPECT_FLOAT_EQ(10 * gyroDevPtr->scale, gyro.gyroADCf[X]); // gyroADCf values are scaled
|
||||
EXPECT_FLOAT_EQ(20 * gyroDevPtr->scale, gyro.gyroADCf[Y]);
|
||||
EXPECT_FLOAT_EQ(90 * gyroDevPtr->scale, gyro.gyroADCf[Z]);
|
||||
EXPECT_NEAR(10 * gyroDevPtr->scale, gyro.gyroADCf[X], 1e-3); // gyroADCf values are scaled
|
||||
EXPECT_NEAR(20 * gyroDevPtr->scale, gyro.gyroADCf[Y], 1e-3);
|
||||
EXPECT_NEAR(90 * gyroDevPtr->scale, gyro.gyroADCf[Z], 1e-3);
|
||||
}
|
||||
|
||||
// STUBS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue