10 releases

0.3.0 Mar 17, 2025
0.2.5 Mar 5, 2025
0.2.2 Jun 12, 2020
0.2.1 Sep 5, 2018
0.1.5 Sep 4, 2018

#423 in Embedded development

Download history 83/week @ 2025-12-03 399/week @ 2025-12-10 189/week @ 2025-12-17 136/week @ 2025-12-24 556/week @ 2025-12-31 1073/week @ 2026-01-07 1381/week @ 2026-01-14 1838/week @ 2026-01-21 334/week @ 2026-01-28 407/week @ 2026-02-04 478/week @ 2026-02-11 765/week @ 2026-02-18 1469/week @ 2026-02-25 202/week @ 2026-03-04 152/week @ 2026-03-11 368/week @ 2026-03-18

2,256 downloads per month
Used in icm42688

MIT license

55KB
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 .

// 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):
    dcmimu.update_only((gyro.x, gyro.y, gyro.z), (accel.x, accel.y, accel.z), dt_ms.seconds());
    let dcm = dcmimu.to_euler_angles();
    println!("Roll: {}; yaw: {}; pitch: {}", dcm.roll, dcm.yaw, dcm.pitch);
}

Check out mpu9250 for accelerometer/gyroscrope sensors driver.

Documentation

Available via docs.rs.

License

MIT license.

Dependencies

~580KB
~12K SLoC