E&R S3 prime / Mbed 2 deprecated Fusion3

Dependencies:   mbed LSM6DS33_GR1

Embed: (wiki syntax)

« Back to documentation index

FusionAhrs.h File Reference

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).

Author:
Seb Madgwick The algorithm behaviour is governed by a gain. A low gain will decrease the influence of the accelerometer and magnetometer so that the algorithm will better reject disturbances causes by translational motion and temporary magnetic distortions. However, a low gain will also increase the risk of drift due to gyroscope calibration errors. A typical gain value suitable for most applications is 0.5.

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:
fusionAhrsAHRS 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:
fusionAhrsAHRS 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:
fusionAhrsAHRS 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:
fusionAhrsAHRS algorithm structure.
gainAHRS 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:
fusionAhrsAHRS 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:
fusionAhrsAHRS 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:
gainAHRS 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:
fusionAhrsAHRS algorithm structure.
minimumMagneticFieldMinimum valid magnetic field magnitude.
maximumMagneticFieldMaximum 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:
fusionAhrsAHRS algorithm structure.
yawYaw 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:
fusionAhrsAHRS algorithm structure.
gyroscopeGyroscope measurement in degrees per second.
accelerometerAccelerometer measurement in g.
magnetometerMagnetometer measurement in uT.
samplePeriodSample 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:
fusionAhrsAHRS algorithm structure.
gyroscopeGyroscope measurement in degrees per second.
accelerometerAccelerometer measurement in g.
samplePeriodSample period in seconds. This is the difference in time between the current and previous gyroscope measurements.

Definition at line 189 of file FusionAhrs.c.