Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fusion/FusionCalibration.h@1:57502185804c, 2021-10-30 (annotated)
- Committer:
- natvich
- Date:
- Sat Oct 30 17:17:07 2021 +0000
- Revision:
- 1:57502185804c
Projet ATTITUDE IMU
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
natvich | 1:57502185804c | 1 | /** |
natvich | 1:57502185804c | 2 | * @file FusionCalibration.h |
natvich | 1:57502185804c | 3 | * @author Seb Madgwick |
natvich | 1:57502185804c | 4 | * @brief Gyroscope, accelerometer, and magnetometer calibration model. |
natvich | 1:57502185804c | 5 | * |
natvich | 1:57502185804c | 6 | * Static inline implementations are used to optimise for increased execution |
natvich | 1:57502185804c | 7 | * speed. |
natvich | 1:57502185804c | 8 | */ |
natvich | 1:57502185804c | 9 | |
natvich | 1:57502185804c | 10 | #ifndef FUSION_CALIBRATION_H |
natvich | 1:57502185804c | 11 | #define FUSION_CALIBRATION_H |
natvich | 1:57502185804c | 12 | |
natvich | 1:57502185804c | 13 | //------------------------------------------------------------------------------ |
natvich | 1:57502185804c | 14 | // Includes |
natvich | 1:57502185804c | 15 | |
natvich | 1:57502185804c | 16 | #include "FusionTypes.h" |
natvich | 1:57502185804c | 17 | |
natvich | 1:57502185804c | 18 | //------------------------------------------------------------------------------ |
natvich | 1:57502185804c | 19 | // Inline functions |
natvich | 1:57502185804c | 20 | |
natvich | 1:57502185804c | 21 | /** |
natvich | 1:57502185804c | 22 | * @brief Gyroscope and accelerometer calibration model. |
natvich | 1:57502185804c | 23 | * @param uncalibrated Uncalibrated gyroscope or accelerometer measurement in |
natvich | 1:57502185804c | 24 | * lsb. |
natvich | 1:57502185804c | 25 | * @param misalignment Misalignment matrix (may not be a true rotation matrix). |
natvich | 1:57502185804c | 26 | * @param sensitivity Sensitivity in g per lsb for an accelerometer and degrees |
natvich | 1:57502185804c | 27 | * per second per lsb for a gyroscope. |
natvich | 1:57502185804c | 28 | * @param bias Bias in lsb. |
natvich | 1:57502185804c | 29 | * @return Calibrated gyroscope or accelerometer measurement. |
natvich | 1:57502185804c | 30 | */ |
natvich | 1:57502185804c | 31 | static inline __attribute__((always_inline)) FusionVector3 FusionCalibrationInertial(const FusionVector3 uncalibrated, const FusionRotationMatrix misalignment, const FusionVector3 sensitivity, const FusionVector3 bias) { |
natvich | 1:57502185804c | 32 | return FusionRotationMatrixMultiplyVector(misalignment, FusionVectorHadamardProduct(FusionVectorSubtract(uncalibrated, bias), sensitivity)); |
natvich | 1:57502185804c | 33 | } |
natvich | 1:57502185804c | 34 | |
natvich | 1:57502185804c | 35 | /** |
natvich | 1:57502185804c | 36 | * @brief Magnetometer calibration model. |
natvich | 1:57502185804c | 37 | * @param magnetometer Uncalibrated magnetometer measurement in uT. |
natvich | 1:57502185804c | 38 | * @param softIronMatrix Soft-iron matrix (may not be a true rotation matrix). |
natvich | 1:57502185804c | 39 | * @param hardIronBias Hard-iron bias in uT. |
natvich | 1:57502185804c | 40 | * @return Calibrated magnetometer measurement. |
natvich | 1:57502185804c | 41 | */ |
natvich | 1:57502185804c | 42 | static inline __attribute__((always_inline)) FusionVector3 FusionCalibrationMagnetic(const FusionVector3 uncalibrated, const FusionRotationMatrix softIronMatrix, const FusionVector3 hardIronBias) { |
natvich | 1:57502185804c | 43 | return FusionVectorSubtract(FusionRotationMatrixMultiplyVector(softIronMatrix, uncalibrated), hardIronBias); |
natvich | 1:57502185804c | 44 | } |
natvich | 1:57502185804c | 45 | |
natvich | 1:57502185804c | 46 | #endif |
natvich | 1:57502185804c | 47 | |
natvich | 1:57502185804c | 48 | //------------------------------------------------------------------------------ |
natvich | 1:57502185804c | 49 | // End of file |