pub struct ImuSample {
pub timestamp: f64,
pub accel: [f64; 3],
pub gyro: [f64; 3],
pub mag: [f64; 3],
}Expand description
A single sample from a 9-axis IMU.
All coordinate frames are body-fixed (right-hand rule, X forward, Y left, Z up) unless otherwise stated.
Fields§
§timestamp: f64Timestamp in seconds.
accel: [f64; 3]Accelerometer reading [ax, ay, az] in m/s².
gyro: [f64; 3]Gyroscope reading [ωx, ωy, ωz] in rad/s.
mag: [f64; 3]Magnetometer reading [bx, by, bz] in µT.
Implementations§
Source§impl ImuSample
impl ImuSample
Sourcepub fn new(
timestamp: f64,
accel: [f64; 3],
gyro: [f64; 3],
mag: [f64; 3],
) -> Self
pub fn new( timestamp: f64, accel: [f64; 3], gyro: [f64; 3], mag: [f64; 3], ) -> Self
Construct a new sample from component arrays.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize to 80 bytes of little-endian f64.
Layout: [t, ax, ay, az, ωx, ωy, ωz, bx, by, bz] (10 × 8 bytes).
Sourcepub fn from_bytes(data: &[u8]) -> Option<Self>
pub fn from_bytes(data: &[u8]) -> Option<Self>
Deserialize from 80 bytes. Returns None on truncated input.
Sourcepub fn accel_magnitude(&self) -> f64
pub fn accel_magnitude(&self) -> f64
Magnitude of the accelerometer vector in m/s².
Sourcepub fn gyro_magnitude(&self) -> f64
pub fn gyro_magnitude(&self) -> f64
Magnitude of the angular-rate vector in rad/s.
Trait Implementations§
impl StructuralPartialEq for ImuSample
Auto Trait Implementations§
impl Freeze for ImuSample
impl RefUnwindSafe for ImuSample
impl Send for ImuSample
impl Sync for ImuSample
impl Unpin for ImuSample
impl UnsafeUnpin for ImuSample
impl UnwindSafe for ImuSample
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.