38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
//! 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,
|
|
}
|
|
}
|
|
}
|