refactor: move firmware workspace under firmware

This commit is contained in:
Onur Özkan committed 2026-08-10 16:58:55 +03:00
1 parent 153b0bf262
commit f03fc119a4
222 files changed
+56 -13

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
[package]
name = "kaptan-sensor"
edition.workspace = true
license.workspace = true
rust-version.workspace = true
version.workspace = true
[lints]
workspace = true
[dependencies]
kaptan-time = { path = "../kaptan-time" }
+37
View File
@@ -0,0 +1,37 @@
//! 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.
#[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,
}
}
}
+14
View File
@@ -0,0 +1,14 @@
//! 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]
/// Inertial measurement unit observations.
pub mod imu;
/// Optical-flow observations.
pub mod optical_flow;
/// Distance sensor observations.
pub mod range;
@@ -0,0 +1,37 @@
//! Optical-flow observations.
use kaptan_time::Timestamp;
/// Coherent ground-referenced optical-flow observation in the sensor frame.
///
/// Linear velocity and ground distance use integer SI subunits so acquisition
/// remains independent of the floating-point representation required by some
/// outbound wire protocols.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct OpticalFlowSnapshot {
/// Flight-controller monotonic time at observation reception.
pub timestamp: Timestamp,
/// Ground-referenced velocity along sensor X/Y, in millimetres per second.
pub velocity_millimetres_per_second: [i32; 2],
/// Ground distance, in millimetres.
pub ground_distance_millimetres: u32,
/// Device-reported observation quality, from 0 through 255.
pub quality: u8,
}
impl OpticalFlowSnapshot {
/// Creates one valid optical-flow observation.
pub const fn new(
timestamp: Timestamp,
velocity_millimetres_per_second: [i32; 2],
ground_distance_millimetres: u32,
quality: u8,
) -> Self {
Self {
timestamp,
velocity_millimetres_per_second,
ground_distance_millimetres,
quality,
}
}
}
+26
View File
@@ -0,0 +1,26 @@
//! Distance sensor observations.
use kaptan_time::Timestamp;
/// Coherent range observation in the sensor frame.
///
/// The timestamp is captured when the measurement is requested. Distance is
/// expressed in millimetres so rangefinders with centimetre resolution can be
/// published without floating-point conversion.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct RangeSnapshot {
/// Monotonic timestamp captured when the acquisition was requested.
pub timestamp: Timestamp,
/// Measured distance in millimetres.
pub distance_millimetres: u32,
}
impl RangeSnapshot {
/// Creates one accepted range observation.
pub const fn new(timestamp: Timestamp, distance_millimetres: u32) -> Self {
Self {
timestamp,
distance_millimetres,
}
}
}