libs/kaptan-sensor: add optical-flow observations
This commit is contained in:
1 parent
f8ee799208
commit
86dee45000
2 files changed
+39
No files matched your search
@@ -8,5 +8,7 @@
|
||||
|
||||
/// 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user