8 releases

Uses old Rust 2015

0.2.2 Jun 12, 2020
0.2.1 Sep 5, 2018
0.1.5 Sep 4, 2018

#8 in #low-cost

Download history 62/week @ 2023-11-01 28/week @ 2023-11-08 13/week @ 2023-11-15 36/week @ 2023-11-22 35/week @ 2023-11-29 10/week @ 2023-12-06 19/week @ 2023-12-13 22/week @ 2023-12-20 15/week @ 2023-12-27 17/week @ 2024-01-03 13/week @ 2024-01-10 31/week @ 2024-01-17 26/week @ 2024-01-24 21/week @ 2024-01-31 13/week @ 2024-02-07 83/week @ 2024-02-14

144 downloads per month
Used in icm42688

MIT license

54KB
1K SLoC

dcmimu

An algorithm for fusing low-cost triaxial MEMS gyroscope and accelerometer measurements.

A no_std Rust port of the original.

Build Status

NOTE: libm still doesn't work with overflow checks, so you have to compile your project with --release. Leave a comment in the linked issue to raise awareness.

Credentials

Heikki Hyyti and Arto Visala, "A DCM Based Attitude Estimation Algorithm for Low-Cost MEMS IMUs," International Journal of Navigation and Observation, vol. 2015, Article ID 503814, 18 pages, 2015.

Usage

Library is available via crates.io crates.io.


# Create DCMIMU:
let mut dcmimu = DCMIMU::new();
let mut prev_t_ms = now();
loop {
    # get gyroscope and accelerometer measurement from your sensors:
    let gyro = sensor.read_gyro();
    let accel = sensor.read_accel();
    # Convert measurements to SI if needed.
    # Get time difference since last update:
    let t_ms = now();
    let dt_ms = t_ms - prev_t_ms
    prev_t_ms = t_ms
    # Update dcmimu states (don't forget to use SI):
    let (dcm, _gyro_biases) = dcmimu.update((gyro.x, gyro.y, gyro.z),
                                            (accel.x, accel.y, accel.z),
                                            dt_ms.seconds());
    println!("Roll: {}; yaw: {}; pitch: {}", dcm.roll, dcm.yaw, dcm.pitch);
    # Measurements can also be queried without updating:
    println!("{:?} == {}, {}, {}", dcmimu.all(), dcmimu.roll(), dcmimu.yaw(), dcmimu.pitch());
}

Check out mpu9250 for accelerometer/gyroscrope sensors driver.

Documentation

Available via docs.rs.

License

MIT license.

Dependencies

~435KB