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.
Dependencies: mbed LSM6DS33_GR1
FusionAhrs.h File Reference
The AHRS sensor fusion algorithm to combines gyroscope, accelerometer, and magnetometer measurements into a single measurement of orientation relative to the Earth (NWU convention). More...
Go to the source code of this file.
Data Structures | |
struct | FusionAhrs |
AHRS algorithm structure. More... | |
Functions | |
void | FusionAhrsInitialise (FusionAhrs *const fusionAhrs, const float gain) |
Initialises the AHRS algorithm structure. | |
void | FusionAhrsSetGain (FusionAhrs *const fusionAhrs, const float gain) |
Sets the AHRS algorithm gain. | |
void | FusionAhrsSetMagneticField (FusionAhrs *const fusionAhrs, const float minimumMagneticField, const float maximumMagneticField) |
Sets the minimum and maximum valid magnetic field magnitudes in uT. | |
void | FusionAhrsUpdate (FusionAhrs *const fusionAhrs, const FusionVector3 gyroscope, const FusionVector3 accelerometer, const FusionVector3 magnetometer, const float samplePeriod) |
Updates the AHRS algorithm. | |
void | FusionAhrsUpdateWithoutMagnetometer (FusionAhrs *const fusionAhrs, const FusionVector3 gyroscope, const FusionVector3 accelerometer, const float samplePeriod) |
Updates the AHRS algorithm. | |
FusionQuaternion | FusionAhrsGetQuaternion (const FusionAhrs *const fusionAhrs) |
Gets the quaternion describing the sensor relative to the Earth. | |
FusionVector3 | FusionAhrsGetLinearAcceleration (const FusionAhrs *const fusionAhrs) |
Gets the linear acceleration measurement equal to the accelerometer measurement with the 1 g of gravity removed. | |
FusionVector3 | FusionAhrsGetEarthAcceleration (const FusionAhrs *const fusionAhrs) |
Gets the Earth acceleration measurement equal to linear acceleration in the Earth coordinate frame. | |
void | FusionAhrsReinitialise (FusionAhrs *const fusionAhrs) |
Reinitialise the AHRS algorithm. | |
bool | FusionAhrsIsInitialising (const FusionAhrs *const fusionAhrs) |
Returns true while the AHRS algorithm is initialising. | |
void | FusionAhrsSetYaw (FusionAhrs *const fusionAhrs, const float yaw) |
Sets the yaw component of the orientation measurement provided by the AHRS algorithm. |
Detailed Description
The AHRS sensor fusion algorithm to combines gyroscope, accelerometer, and magnetometer measurements into a single measurement of orientation relative to the Earth (NWU convention).
The algorithm allows the application to define a minimum and maximum valid magnetic field magnitude. The algorithm will ignore magnetic measurements that fall outside of this range. This allows the algorithm to reject magnetic measurements that do not represent the direction of magnetic North. The typical magnitude of the Earth's magnetic field is between 20 uT and 70 uT.
The algorithm can be used without a magnetometer. Measurements of orientation obtained using only gyroscope and accelerometer measurements can be expected to drift in the yaw component of orientation only. The application can reset the drift in yaw by setting the yaw to a specified angle at any time.
The algorithm provides the measurement of orientation as a quaternion. The library includes functions for converting this quaternion to a rotation matrix and Euler angles.
The algorithm also provides a measurement of linear acceleration and Earth acceleration. Linear acceleration is equal to the accelerometer measurement with the 1 g of gravity removed. Earth acceleration is a measurement of linear acceleration in the Earth coordinate frame.
Definition in file FusionAhrs.h.
Function Documentation
FusionVector3 FusionAhrsGetEarthAcceleration | ( | const FusionAhrs *const | fusionAhrs ) |
Gets the Earth acceleration measurement equal to linear acceleration in the Earth coordinate frame.
- Parameters:
-
fusionAhrs AHRS algorithm structure.
- Returns:
- Earth acceleration measurement.
Definition at line 230 of file FusionAhrs.c.
FusionVector3 FusionAhrsGetLinearAcceleration | ( | const FusionAhrs *const | fusionAhrs ) |
Gets the linear acceleration measurement equal to the accelerometer measurement with the 1 g of gravity removed.
- Parameters:
-
fusionAhrs AHRS algorithm structure.
- Returns:
- Linear acceleration measurement.
Definition at line 220 of file FusionAhrs.c.
FusionQuaternion FusionAhrsGetQuaternion | ( | const FusionAhrs *const | fusionAhrs ) |
Gets the quaternion describing the sensor relative to the Earth.
- Parameters:
-
fusionAhrs AHRS algorithm structure.
- Returns:
- Quaternion describing the sensor relative to the Earth.
Definition at line 210 of file FusionAhrs.c.
void FusionAhrsInitialise | ( | FusionAhrs *const | fusionAhrs, |
const float | gain | ||
) |
Initialises the AHRS algorithm structure.
- Parameters:
-
fusionAhrs AHRS algorithm structure. gain AHRS algorithm gain.
Definition at line 68 of file FusionAhrs.c.
bool FusionAhrsIsInitialising | ( | const FusionAhrs *const | fusionAhrs ) |
Returns true while the AHRS algorithm is initialising.
- Parameters:
-
fusionAhrs AHRS algorithm structure.
- Returns:
- True while the AHRS algorithm is initialising.
Definition at line 265 of file FusionAhrs.c.
void FusionAhrsReinitialise | ( | FusionAhrs *const | fusionAhrs ) |
Reinitialise the AHRS algorithm.
- Parameters:
-
fusionAhrs AHRS algorithm structure.
Definition at line 254 of file FusionAhrs.c.
void FusionAhrsSetGain | ( | FusionAhrs *const | fusionAhrs, |
const float | gain | ||
) |
Sets the AHRS algorithm gain.
The gain must be equal or greater than zero.
- Parameters:
-
gain AHRS algorithm gain.
Definition at line 83 of file FusionAhrs.c.
void FusionAhrsSetMagneticField | ( | FusionAhrs *const | fusionAhrs, |
const float | minimumMagneticField, | ||
const float | maximumMagneticField | ||
) |
Sets the minimum and maximum valid magnetic field magnitudes in uT.
- Parameters:
-
fusionAhrs AHRS algorithm structure. minimumMagneticField Minimum valid magnetic field magnitude. maximumMagneticField Maximum valid magnetic field magnitude.
Definition at line 93 of file FusionAhrs.c.
void FusionAhrsSetYaw | ( | FusionAhrs *const | fusionAhrs, |
const float | yaw | ||
) |
Sets the yaw component of the orientation measurement provided by the AHRS algorithm.
This function can be used to reset drift in yaw when the AHRS algorithm is being used without a magnetometer.
- Parameters:
-
fusionAhrs AHRS algorithm structure. yaw Yaw angle in degrees.
Definition at line 276 of file FusionAhrs.c.
void FusionAhrsUpdate | ( | FusionAhrs *const | fusionAhrs, |
const FusionVector3 | gyroscope, | ||
const FusionVector3 | accelerometer, | ||
const FusionVector3 | magnetometer, | ||
const float | samplePeriod | ||
) |
Updates the AHRS algorithm.
This function should be called for each new gyroscope measurement.
- Parameters:
-
fusionAhrs AHRS algorithm structure. gyroscope Gyroscope measurement in degrees per second. accelerometer Accelerometer measurement in g. magnetometer Magnetometer measurement in uT. samplePeriod Sample period in seconds. This is the difference in time between the current and previous gyroscope measurements.
Definition at line 108 of file FusionAhrs.c.
void FusionAhrsUpdateWithoutMagnetometer | ( | FusionAhrs *const | fusionAhrs, |
const FusionVector3 | gyroscope, | ||
const FusionVector3 | accelerometer, | ||
const float | samplePeriod | ||
) |
Updates the AHRS algorithm.
This function should be called for each new gyroscope measurement.
- Parameters:
-
fusionAhrs AHRS algorithm structure. gyroscope Gyroscope measurement in degrees per second. accelerometer Accelerometer measurement in g. samplePeriod Sample period in seconds. This is the difference in time between the current and previous gyroscope measurements.
Definition at line 189 of file FusionAhrs.c.
Generated on Sat Sep 3 2022 06:36:54 by
