pub struct TouchdownDetector { /* private fields */ }Expand description
Detects touchdown during a land (ControlInput::Land) from
the vertical speed alone.
Landing guidance keeps lowering its altitude target, so a vehicle still in the air can’t
hold a vertical speed near zero for long: its thrust falls until it sinks. Once the vehicle
has sunk faster than DESCENDING_MPS, staying within
±stopped_mps for hold_s means
the ground stopped it. Before the descent begins (the hover the land started from), nothing
counts. Touchdown latches until reset.
It works only while a land is flown; hovering would read as touchdown. A non-finite speed restarts the stopped timer without clearing the descent.
§Examples
use stable_flight::commanders::TouchdownDetector;
let mut detector = TouchdownDetector::default();
assert!(!detector.update(0.5, 0.0)); // hovering before the descent: not down
assert!(!detector.update(0.5, -0.7)); // descending
assert!(!detector.update(0.5, 0.0)); // stopped for 0.5 s
assert!(detector.update(0.6, 0.0)); // stopped for 1.1 s: downImplementations§
Source§impl TouchdownDetector
impl TouchdownDetector
Sourcepub fn new(config: TouchdownConfig) -> Result<Self, InvalidConfig>
pub fn new(config: TouchdownConfig) -> Result<Self, InvalidConfig>
A detector that reads touchdown per config; Default uses
TouchdownConfig::default.
§Errors
InvalidConfig if config fails TouchdownConfig::validate.
Sourcepub fn update(&mut self, dt: f32, vertical_speed_mps: f32) -> bool
pub fn update(&mut self, dt: f32, vertical_speed_mps: f32) -> bool
Advances by dt seconds with the vertical speed vertical_speed_mps (up positive) and
returns whether the vehicle has touched down.
Sourcepub fn touched_down(&self) -> bool
pub fn touched_down(&self) -> bool
Whether touchdown has been detected.
Trait Implementations§
Source§impl Clone for TouchdownDetector
impl Clone for TouchdownDetector
Source§impl Debug for TouchdownDetector
impl Debug for TouchdownDetector
Auto Trait Implementations§
impl Forget for TouchdownDetector
impl Freeze for TouchdownDetector
impl Move for TouchdownDetector
impl RefUnwindSafe for TouchdownDetector
impl Send for TouchdownDetector
impl Sync for TouchdownDetector
impl Unpin for TouchdownDetector
impl UnsafeUnpin for TouchdownDetector
impl UnwindSafe for TouchdownDetector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.