pub struct WindEstimator { /* private fields */ }Expand description
Estimates the wind from the vehicle state while the caller says it is airborne on rotors.
The config is passed to each call rather than stored, so the owner’s config stays the single source of truth.
§Examples
use stable_flight::estimation::wind::{WindConfig, WindEstimator};
use stable_flight::{Vec2, Vec3, VehicleState};
// A level quad with momentum drag 0.3/s, not moving, pushed east at 0.6 m/s²: the air
// moves east at 2 m/s.
let config = WindConfig {
momentum_per_s: Vec2::new(0.3, 0.3),
..Default::default()
};
let state = VehicleState {
acceleration_mps2: Vec3::new(0.0, 0.6, 0.0),
..Default::default()
};
let mut estimator = WindEstimator::default();
for _ in 0..2500 {
estimator.update(0.004, &config, &state);
}
let wind = estimator.estimate().expect("updated").velocity_mps;
assert!((wind - Vec2::new(0.0, 2.0)).norm() < 0.01);Implementations§
Source§impl WindEstimator
impl WindEstimator
Sourcepub fn update(&mut self, dt: f32, config: &WindConfig, state: &VehicleState)
pub fn update(&mut self, dt: f32, config: &WindConfig, state: &VehicleState)
Adds this tick’s state, state.attitude taken as the thrust frame (thrust along its
z), and once UPDATE_PERIOD_S has gathered, updates the wind from the period’s
average. A tick with a non-finite attitude, velocity, or acceleration, with the thrust
axis tilted more than 45° from vertical, or moving along it faster than
max_axial_speed_mps, is skipped. Does nothing while
config has no drag coefficient.
Each axis’s measurement counts by the drag’s slope at the air velocity the estimate
predicts, as both EKFs linearize their drag at the state (ArduPilot’s
NavEKF3_core::FuseDragForces, PX4’s Ekf::fuseDrag), or at the measured one where
that is steeper. Bluff-body drag has no slope in still air: taken at a measured push near
zero alone, the slope would leave a wrong estimate there for good, and taken at the
prediction alone, a fresh estimate of no wind would discount a real wind’s push (#608).
Sourcepub fn estimate(&self) -> Option<WindEstimate>
pub fn estimate(&self) -> Option<WindEstimate>
The wind, once a measurement has been taken.
Trait Implementations§
Source§impl Clone for WindEstimator
impl Clone for WindEstimator
impl Copy for WindEstimator
Source§impl Debug for WindEstimator
impl Debug for WindEstimator
Source§impl Default for WindEstimator
impl Default for WindEstimator
Source§impl PartialEq for WindEstimator
impl PartialEq for WindEstimator
impl StructuralPartialEq for WindEstimator
Auto Trait Implementations§
impl Forget for WindEstimator
impl Freeze for WindEstimator
impl Move for WindEstimator
impl RefUnwindSafe for WindEstimator
impl Send for WindEstimator
impl Sync for WindEstimator
impl Unpin for WindEstimator
impl UnsafeUnpin for WindEstimator
impl UnwindSafe for WindEstimator
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,
impl<T> Scalar for T
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.