14个版本
| 0.6.0 | 2023年1月13日 | 
|---|---|
| 0.5.0 | 2022年2月9日 | 
| 0.4.0 | 2021年10月4日 | 
| 0.3.0 | 2020年10月25日 | 
| 0.1.3 | 2016年11月17日 | 
在 算法 中排名 934
每月下载量 69
在 3 个 包(2个直接使用)中使用
24KB
408 行
ahrs-rs
Sebastian Madgwick的AHRS算法的Rust移植版。
用法
将ahrs-rs添加到您的 Cargo.toml
[dependencies]
ahrs = "0.6"
以下是一个示例,演示如何使用任意传感器数据更新滤波器状态
use ahrs::{Ahrs, Madgwick};
use nalgebra::Vector3;
use std::f64;
fn main() {
    // Initialize filter with default values
    let mut ahrs = Madgwick::default();
    // Obtain sensor values from a source
    let gyroscope = Vector3::new(60.1, 30.2, 20.3);
    let accelerometer = Vector3::new(0.1, 0.2, 0.3);
    let magnetometer = Vector3::new(0.5, 0.6, 0.7);
    // Run inputs through AHRS filter (gyroscope must be radians/s)
    let quat = ahrs
        .update(
            &(gyroscope * (f64::consts::PI / 180.0)),
            &accelerometer,
            &magnetometer,
        )
        .unwrap();
    let (roll, pitch, yaw) = quat.euler_angles();
    // Do something with the updated state quaternion
    println!("pitch={}, roll={}, yaw={}", pitch, roll, yaw);
}
需要Crate nalgebra 作为依赖项,用于其代数类型 Vector3 和 Quaternion。
功能标志
field_access
提供对通常未公开的内部算法结构字段的可变访问。公开的API目前被视为不稳定,但仍然是一个有用的功能。例如
use ahrs::Madgwick;
let mut ahrs = Madgwick::default();
#[cfg(feature = "field_access")]
{
    let sample_period: &mut f64 = ahrs.sample_period_mut();
    *sample_period = 0.5;
}
许可证
MIT
依赖项
~3MB
~65K SLoC