diff --git a/libs/kaptan-sensor/Cargo.toml b/libs/kaptan-sensor/Cargo.toml new file mode 100644 index 0000000..37afd35 --- /dev/null +++ b/libs/kaptan-sensor/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "kaptan-sensor" +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true + +[lints] +workspace = true + +[dependencies] +kaptan-time = { path = "../kaptan-time" } diff --git a/libs/kaptan-sensor/src/lib.rs b/libs/kaptan-sensor/src/lib.rs new file mode 100644 index 0000000..9d6e878 --- /dev/null +++ b/libs/kaptan-sensor/src/lib.rs @@ -0,0 +1,43 @@ +//! Hardware-independent sensor observations and units. +//! +//! Sensor data is immutable after publication. Bus transactions, queueing, +//! protocol encoding, PAC access, RTIC mechanics, and board transforms do not +//! belong in this crate. + +#![no_std] + +use kaptan_time::Timestamp; + +/// Coherent IMU observation in the board body frame. +/// +/// Acceleration is milligravity, angular rate is milliradians per second, and +/// temperature is centidegrees Celsius. The board-frame transform is complete +/// before this value is published. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct ImuSnapshot { + /// Monotonic timestamp captured at acquisition interrupt entry. + pub timestamp: Timestamp, + /// Body-frame acceleration in milligravity. + pub acceleration_milligravity: [i16; 3], + /// Body-frame angular rate in milliradians per second. + pub angular_rate_milliradians_per_second: [i16; 3], + /// Sensor temperature in centidegrees Celsius. + pub temperature_centidegrees_celsius: i16, +} + +impl ImuSnapshot { + /// Creates one accepted IMU observation. + pub const fn new( + timestamp: Timestamp, + acceleration_milligravity: [i16; 3], + angular_rate_milliradians_per_second: [i16; 3], + temperature_centidegrees_celsius: i16, + ) -> Self { + Self { + timestamp, + acceleration_milligravity, + angular_rate_milliradians_per_second, + temperature_centidegrees_celsius, + } + } +}