Struct VQF

Source
pub struct VQF { /* private fields */ }
Expand description

A Versatile Quaternion-based Filter for IMU Orientation Estimation.

This class implements the orientation estimation filter described in the following publication:

D. Laidig and T. Seel. “VQF: Highly Accurate IMU Orientation Estimation with Bias Estimation and Magnetic Disturbance Rejection.” Information Fusion 2023, 91, 187–204. doi:10.1016/j.inffus.2022.10.014. [Accepted manuscript available at arXiv:2203.17024.]

The filter can perform simultaneous 6D (magnetometer-free) and 9D (gyr+acc+mag) sensor fusion and can also be used without magnetometer data. It performs rest detection, gyroscope bias estimation during rest and motion, and magnetic disturbance detection and rejection. Different sampling rates for gyroscopes, accelerometers, and magnetometers are supported as well. While in most cases, the defaults will be reasonable, the algorithm can be influenced via a number of tuning parameters.

To use this implementation,

  1. create a instance of the class and provide the sampling time and, optionally, parameters
  2. for every sample, call one of the update functions to feed the algorithm with IMU data
  3. access the estimation results with quat_6d(), quat_9d() and the other getter methods.

This class is a port of the official, original C++ implementation of the algorithm. For usage in C++/Python/MATLAB, the original implementations should be used.

Implementations§

Source§

impl VQF

Source

pub fn new( gyr_ts: Float, acc_ts: Option<Float>, mag_ts: Option<Float>, params: Option<Params>, ) -> Self

Creates a new VQF instance.

In the most common case (using the default parameters and all data being sampled with the same frequency, create the class like this:

let vqf = VQF::new(0.01, None, None, None); // 0.01 s sampling time, i.e. 100 Hz
§Panics

Panics if gyr_ts, acc_ts, or mag_ts is negative.

Source

pub fn update_gyr(&mut self, gyr: [Float; 3])

Performs gyroscope update step, using the measurement in rad/s.

It is only necessary to call this function directly if gyroscope, accelerometers and magnetometers have different sampling rates. Otherwise, simply use update().

Source

pub fn update_gyr_with_ts(&mut self, gyr: [Float; 3], ts: Float)

Performs gyroscope update step, using a specified timestep for integration.

Source

pub fn update_acc(&mut self, acc: [Float; 3])

Performs accelerometer update step, using the measurement in m/s².

It is only necessary to call this function directly if gyroscope, accelerometers and magnetometers have different sampling rates. Otherwise, simply use update().

Should be called after update_gyr() and before update_mag().

Source

pub fn update_mag(&mut self, mag: [Float; 3])

Performs magnetometer update step.

It is only necessary to call this function directly if gyroscope, accelerometers and magnetometers have different sampling rates. Otherwise, simply use update().

Should be called after update_acc().

Source

pub fn update( &mut self, gyr: [Float; 3], acc: [Float; 3], mag: Option<[Float; 3]>, )

Performs filter update step for one sample.

Source

pub fn quat_3d(&self) -> Quaternion

Returns the angular velocity strapdown integration quaternion $^{\mathcal{S}_i}_{\mathcal{I}_i}\mathbf{q}$.

Source

pub fn quat_6d(&self) -> Quaternion

Returns the 6D (magnetometer-free) orientation quaternion $^{\mathcal{S}_i}_{\mathcal{E}_i}\mathbf{q}$.

Source

pub fn quat_9d(&self) -> Quaternion

Returns the 9D (with magnetometers) orientation quaternion $^{\mathcal{S}_i}_{\mathcal{E}}\mathbf{q}$.

Source

pub fn delta(&self) -> Float

Returns the heading difference $\delta$ between $\mathcal{E}_i$ and $\mathcal{E}$ in radians.

$^{\mathcal{E}_i}_{\mathcal{E}}\mathbf{q} = \begin{bmatrix}\cos\frac{\delta}{2} & 0 & 0 & \sin\frac{\delta}{2}\end{bmatrix}^T$.

Source

pub fn bias_estimate(&self) -> ([Float; 3], Float)

Returns the current gyroscope bias estimate and the uncertainty in rad/s.

The returned standard deviation sigma represents the estimation uncertainty in the worst direction and is based on an upper bound of the largest eigenvalue of the covariance matrix.

Source

pub fn set_bias_estimate(&mut self, bias: [Float; 3], sigma: Option<Float>)

Sets the current gyroscope bias estimate and the uncertainty in rad/s.

If a value for the uncertainty sigma is given in sigma, the covariance matrix is set to a corresponding scaled identity matrix.

Source

pub fn rest_detected(&self) -> bool

Returns true if rest was detected.

Source

pub fn mag_dist_detected(&self) -> bool

Returns true if a disturbed magnetic field was detected.

Source

pub fn relative_rest_deviations(&self) -> [Float; 2]

Returns the relative deviations used in rest detection.

Looking at those values can be useful to understand how rest detection is working and which thresholds are suitable. The output array is filled with the last values for gyroscope and accelerometer, relative to the threshold. In order for rest to be detected, both values must stay below 1.

Source

pub fn mag_ref_norm(&self) -> Float

Returns the norm of the currently accepted magnetic field reference.

Source

pub fn mag_ref_dip(&self) -> Float

Returns the dip angle of the currently accepted magnetic field reference.

Source

pub fn set_mag_ref(&mut self, norm: Float, dip: Float)

Overwrites the current magnetic field reference.

Source

pub fn set_tau_acc(&mut self, tau_acc: Float)

Sets the time constant $\tau_\mathrm{acc}$ in seconds for accelerometer low-pass filtering.

For more details, see Params::tau_acc.

Source

pub fn set_tau_mag(&mut self, tau_mag: Float)

Sets the time constant $\tau_\mathrm{mag}$ in seconds for the magnetometer update.

For more details, see Params::tau_mag.

Source

pub fn set_motion_bias_est_enabled(&mut self, enabled: bool)

Enables/disables gyroscope bias estimation during motion.

Source

pub fn set_rest_bias_est_enabled(&mut self, enabled: bool)

Enables/disables rest detection and bias estimation during rest.

Source

pub fn set_mag_dist_rejection_enabled(&mut self, enabled: bool)

Enables/disables magnetic disturbance detection and rejection.

Source

pub fn set_rest_detection_thresholds(&mut self, th_gyr: Float, th_acc: Float)

Sets the current thresholds for rest detection.

For details about the parameters, see Params::rest_th_gyr and Params::rest_th_acc.

Source

pub fn params(&self) -> &Params

Returns the current parameters.

Source

pub fn coeffs(&self) -> &Coefficients

Returns the coefficients used by the algorithm.

Source

pub fn state(&self) -> &State

Returns the current state.

Source

pub fn state_mut(&mut self) -> &mut State

Gets the current state for modification.

This method allows to set a completely arbitrary filter state and is intended for debugging purposes.

Source

pub fn reset_state(&mut self)

Resets the state to the default values at initialization.

Resetting the state is equivalent to creating a new instance of this struct.

Auto Trait Implementations§

§

impl Freeze for VQF

§

impl RefUnwindSafe for VQF

§

impl Send for VQF

§

impl Sync for VQF

§

impl Unpin for VQF

§

impl UnwindSafe for VQF

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.