Skip to content

Commit

Permalink
nalgebra example added
Browse files Browse the repository at this point in the history
  • Loading branch information
mark2b committed Dec 5, 2023
1 parent 3c30753 commit 529c077
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ path = "examples/simple.rs"
name = "advanced"
path = "examples/advanced.rs"

[[example]]
name = "nalgebra"
path = "examples/nalgebra.rs"

[[test]]
name = "test-1"
path = "tests/fusion-rs/test_1.rs"
Expand Down
16 changes: 16 additions & 0 deletions examples/nalgebra.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use imu_fusion::FusionAhrsSettings;
use nalgebra::{Vector3};

const SAMPLE_RATE_HZ: u32 = 100;

fn main() {
let ahrs_settings = FusionAhrsSettings::new();
let mut fusion = imu_fusion::Fusion::new(SAMPLE_RATE_HZ, ahrs_settings);
loop {
let gyr = Vector3::new(0f32, 0f32, 0f32); // replace this with actual gyroscope data in degrees/s
let acc = Vector3::new(0f32, 0f32, 1.0f32); // replace this with actual accelerometer data in g
fusion.update_no_mag(gyr.into(), acc.into(), 1.0 / SAMPLE_RATE_HZ as f32);
let euler = fusion.euler();
println!("Roll {}, Pitch {}, Yaw {}", euler.angle.roll, euler.angle.pitch, euler.angle.yaw);
}
}

0 comments on commit 529c077

Please sign in to comment.