1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
use nalgebra::{Quaternion, Scalar, Vector3}; use simba::simd::SimdValue; /// Trait for implementing an AHRS filter. pub trait Ahrs<N: Scalar + SimdValue> { /// Attempts to update the current state quaternion using 9dof IMU values, made up by `gyroscope`, /// `accelerometer`, and `magnetometer`. /// /// Returns a reference to the updated quaternion on success, or in the case of failure, an /// `Err(&str)` containing the reason. fn update( &mut self, gyroscope: &Vector3<N>, accelerometer: &Vector3<N>, magnetometer: &Vector3<N>, ) -> Result<&Quaternion<N>, &str>; /// Attempts to update the current state quaternion using 6dof IMU values, made up by `gyroscope` & /// `accelerometer`. /// /// Returns a reference to the updated quaternion on success, or in the case of failure, an /// `Err(&str)` containing the reason. fn update_imu( &mut self, gyroscope: &Vector3<N>, accelerometer: &Vector3<N>, ) -> Result<&Quaternion<N>, &str>; }