libs/kaptan-sensor: add immutable IMU snapshot

This commit is contained in:
Onur Özkan committed 2026-07-19 22:39:55 +03:00
1 parent 66c4e73ae1
commit 95f94dfc81
2 files changed
+56

No files matched your search

+13
View File
@@ -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" }
+43
View File
@@ -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,
}
}
}