Files
kaptan/firmware/libs/kaptan-sensor/src/imu.rs
T
Onur Özkan f9a61a086f feat(firmware): validate configuration and migrate sensor-driven flight APIs
Validate configuration through its owning schemas and keep board
declarations separate from shared F722 resource ownership. Bound USB
transitions, isolate transport failures and retain restart-only activation.

Migrate navigation and flight consumers with the sensor and schema
contracts. Require explicit installation data and synchronous output
authority; board motor outputs remain inhibited.

Validation: assembled-prefix host tests, strict Clippy, platform/USB tests
and both ARM release builds. Final-source coverage and scoped Miri/Kani
evidence are retained separately from hardware qualification.
2026-11-07 18:12:11 +03:00

48 lines
1.9 KiB
Rust

//! Inertial measurement unit observations.
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.
///
/// Current MPU6000 and ICM-42688-P decoders round integer conversions toward
/// zero. Across their configured ranges, decoded acceleration is within
/// ±16,000 mg and angular rate within ±34,871 mrad/s, including mounting sign
/// changes. Temperature is within -22,234..=27,233 cdegC. These are backend
/// representation bounds over every raw i16 value, not physical operating
/// limits or validation performed by this public snapshot type.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct ImuSnapshot {
/// Host monotonic acquisition-request time, captured immediately before the
/// accepted register read is submitted by the worker. This is neither DRDY
/// ISR entry nor the sensor's physical sampling epoch. Register updates,
/// filtering and deferred/coalesced interrupts prevent that inference.
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: [i32; 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: [i32; 3],
temperature_centidegrees_celsius: i16,
) -> Self {
Self {
timestamp,
acceleration_milligravity,
angular_rate_milliradians_per_second,
temperature_centidegrees_celsius,
}
}
}