Skip to content

jettify/uf-ahrs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uf-ahrs

CI codecov

uf-ahrs rust no_std library for orientation estimation using gyroscope, accelerometer and magnetometer.

Features

  • no_std and allocator-free for embedded systems.
  • IO and MCU agnostic.
  • Implements Mahony, Madgwick and VQF filters.
  • Filters evaluated using BROAD dataset.

Note

Library is under active development and testing, API might change at any time.

Installation

Add uf-ahrs to your Cargo.toml:

[dependencies]
uf-ahrs = "*" # replace * by the latest version of the crate.

Or use the command line:

cargo add uf-ahrs

Usage

Here is a simple example showing how to initialize and use Mahony, Madgwick, and VQF filters.

use core::time::Duration;
use nalgebra::Vector3;
use uf_ahrs::{Ahrs, Madgwick, MadgwickParams, Mahony, MahonyParams, Vqf, VqfParameters};

fn main() {
    let dt = Duration::from_secs_f32(1.0 / 100.0);

    let mut mahony = Mahony::new(dt, MahonyParams::default());
    let mut madgwick = Madgwick::new(dt, MadgwickParams::default());
    let mut vqf = Vqf::new(dt, VqfParameters::default());

    // Sensor data
    let gyr = Vector3::new(0.0, 0.0, 0.0);
    let acc = Vector3::new(0.0, 0.0, 9.81);
    let mag = Vector3::new(20.0, 0.0, 0.0);

    mahony.update(gyr, acc, mag);
    madgwick.update(gyr, acc, mag);
    vqf.update(gyr, acc, mag);

    // Get orientation as UnitQuaternion
    let q_mahony = mahony.orientation();
    let q_madgwick = madgwick.orientation();
    let q_vqf = vqf.orientation();

    println!("Mahony:   {:?}", q_mahony.euler_angles());
    println!("Madgwick: {:?}", q_madgwick.euler_angles());
    println!("VQF:      {:?}", q_vqf.euler_angles());
}

License

This project is licensed under the Apache 2.0. See the LICENSE file for details.

References

This library incorporates ideas and data from the following projects and publications.

Publications

  • BROAD - A benchmark for robust inertial orientation estimation D. Laidig, M. Caruso, A. Cereatti, and T. Seel, Data, vol. 6, no. 7, p. 72, 2021.

  • Nonlinear complementary filters on the special orthogonal group R. Mahony, T. Hamel, and J.-M. Pflimlin, IEEE Transactions on Automatic Control, vol. 53, no. 5, pp. 1203–1218, 2008.

  • An efficient orientation filter for inertial and inertial/magnetic sensor arrays S. O. H. Madgwick et al., 2010.

  • VQF: Highly accurate IMU orientation estimation with bias estimation and magnetic disturbance rejection D. Laidig and T. Seel, Information Fusion, vol. 91, pp. 187–204, 2023.

Related Projects

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published