Skip to main content

MadgwickFilter

Struct MadgwickFilter 

Source
pub struct MadgwickFilter<T> { /* private fields */ }
Expand description

Implementations§

Source§

impl<T> MadgwickFilter<T>
where T: Copy + ConstZero + ConstOne + ConstFour,

Source

pub const fn new() -> Self

Constructor.

Source

pub const fn with_beta(self, beta: T) -> Self

Set the beta gain of a newly constructed filter.

Source

pub const fn with_orientation(self, orientation: Quaternion<T>) -> Self

Set the orientation of a newly constructed filter.

Source§

impl<T: Copy> MadgwickFilter<T>

Source

pub fn set_orientation(&mut self, orientation: Quaternion<T>)

Source

pub fn set_beta(&mut self, beta: T)

Source

pub fn set_beta_yaw(&mut self, beta_yaw: T)

Source§

impl<T> MadgwickFilter<T>

Source

pub fn correct_yaw(&mut self, yaw_radians: T, delta_t: T) -> Quaternion<T>

Trait Implementations§

Source§

impl<T: Clone> Clone for MadgwickFilter<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy> Copy for MadgwickFilter<T>

Source§

impl<T: Debug> Debug for MadgwickFilter<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for MadgwickFilter<T>
where T: Copy + ConstZero + ConstOne + ConstFour,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: PartialEq> PartialEq for MadgwickFilter<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T> SensorFusion<T> for MadgwickFilter<T>

Madgwick AHRS algorithm, calculates orientation by fusing output from gyroscope and accelerometer. (No magnetometer is used in this implementation.)

The orientation is calculated as the integration of the gyroscope measurements summed with the measurement from the accelerometer multiplied by a gain. A low gain gives more weight to the gyroscope more and so is more susceptible to drift. A high gain gives more weight to the accelerometer and so is more susceptible to accelerometer noise, lag, and other accelerometer errors. A gain of zero means that orientation is determined by solely by the gyroscope.

See Sebastian Madgwick’s Phd thesis and also x-io Technologies sensor fusion library.

For computation efficiency this code refactors the code used in many implementations (Arduino, Adafruit, M5 Stack, Reefwing-AHRS), see Madgwick refactoring.

Source§

fn fuse_acc_gyro( &mut self, acc: Vector3<T>, gyro_rps: Vector3<T>, delta_t: T, ) -> Quaternion<T>

Fuses accelerometer and gyroscope readings to give the orientation quaternion.

Source§

fn fuse_acc_gyro_mag( &mut self, acc: Vector3<T>, gyro_rps: Vector3<T>, mag: Vector3<T>, delta_t: T, ) -> Quaternion<T>

Fuses accelerometer, gyroscope, and magnetometer readings to give the orientation quaternion.

Source§

fn correct_yaw_with_gain( &mut self, yaw_radians: T, gain: T, delta_t: T, ) -> Quaternion<T>

Note delta_t is the time since correct_yaw was last called, distinct from the delta_t in fuse_acc_gyro. This function called at a frequency of ~10Hz if called from a GPS update, or ~200Hz for a magnetometer update. It is normally called withing the Gyro/PID loop and so should be as fast as possible to minimize jitter.

Source§

fn set_gains(&mut self, gain0: T, gain1: T)

Source§

fn gains(&self) -> (T, T)

Source§

fn requires_initialization() -> bool

Source§

impl<T: PartialEq> StructuralPartialEq for MadgwickFilter<T>

Auto Trait Implementations§

§

impl<T> Freeze for MadgwickFilter<T>
where Quaternion<T>: Freeze, T: Freeze,

§

impl<T> RefUnwindSafe for MadgwickFilter<T>

§

impl<T> Send for MadgwickFilter<T>
where Quaternion<T>: Send, T: Send,

§

impl<T> Sync for MadgwickFilter<T>
where Quaternion<T>: Sync, T: Sync,

§

impl<T> Unpin for MadgwickFilter<T>
where Quaternion<T>: Unpin, T: Unpin,

§

impl<T> UnsafeUnpin for MadgwickFilter<T>

§

impl<T> UnwindSafe for MadgwickFilter<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.