Skip to main content

WindConfig

Struct WindConfig 

Source
pub struct WindConfig {
    pub ballistic_kgpm2: Vec2,
    pub momentum_per_s: Vec2,
    pub force_noise_mps2: f32,
    pub process_noise_mps_per_rt_s: f32,
    pub initial_sd_mps: f32,
    pub gate_sigma: f32,
    pub max_axial_speed_mps: f32,
}
Expand description

The drag model, per thrust-frame axis (x, y), and the filter’s noise.

With every coefficient 0 (the default, as both stacks ship drag fusion off) the estimator never updates.

Fields§

§ballistic_kgpm2: Vec2

Ballistic coefficient along x and y, in kg/m²: mass over drag coefficient times area, so the bluff-body drag along the axis is ½ρ·v·|V|/B per kg, v the air along the axis and |V| the airspeed with the air along the thrust axis counted in (the vehicle’s climb or sink, the wind taken as horizontal), as PX4’s Ekf::fuseDrag predicts it (PX4 counts the other axis’s air too, which inverting one axis at a time can’t). 0 leaves the term out. Must be non-negative and finite.

§momentum_per_s: Vec2

Momentum drag along x and y, in 1/s: drag acceleration per m/s of air velocity. 0 leaves the term out. Must be non-negative and finite.

§force_noise_mps2: f32

Specific-force noise on each averaged measurement, in m/s². Must be positive and finite. Defaults to DEFAULT_FORCE_NOISE_MPS2.

§process_noise_mps_per_rt_s: f32

How fast the wind may wander, in m/s per √s (process noise). Must be non-negative and finite. Defaults to DEFAULT_PROCESS_NOISE_MPS_PER_RT_S.

§initial_sd_mps: f32

Standard deviation of each wind component, in m/s, before the first measurement; it applies from the estimator’s next reset. Higher: the first measurements move the estimate more. Must be positive and finite. Defaults to DEFAULT_INITIAL_SD_MPS.

§gate_sigma: f32

How many standard deviations an averaged measurement may be off the estimate before it is rejected. Higher: takes in a sudden gust sooner, and a bad measurement with it. Must be positive and finite. Defaults to DEFAULT_GATE_SIGMA.

§max_axial_speed_mps: f32

Most ground speed along the thrust axis, in m/s, a tick is used at: the drag model is a hover’s, and climbing or sinking a cambered wing lifts toward its belly, which reads as wind. Higher: uses more of a climb, and its lift; lower: holds the estimate through gentler climbs and descents. Must be positive and finite. Defaults to DEFAULT_MAX_AXIAL_SPEED_MPS.

Implementations§

Source§

impl WindConfig

Source

pub fn validate(&self) -> Result<(), InvalidConfig>

Checks that the coefficients and process_noise_mps_per_rt_s are non-negative and finite, and that force_noise_mps2, initial_sd_mps, gate_sigma, and max_axial_speed_mps are positive and finite.

§Examples
use stable_flight::estimation::wind::WindConfig;

let mut config = WindConfig::default();
assert!(config.validate().is_ok());
config.force_noise_mps2 = 0.0;
assert!(config.validate().is_err());
Source

pub fn is_on(&self) -> bool

Whether any drag coefficient is set, so the estimator can update.

Source

pub fn drag_mps2(&self, air_mps: Vec2) -> Vec2

The drag per kg, in m/s² along the thrust frame’s x and y, on a vehicle moving through the air at air_mps along those axes (its velocity less the wind’s), level: −(k|v| + μ)v per axis, opposing the air velocity. Zero on an axis without a coefficient.

§Examples
use stable_flight::Vec2;
use stable_flight::estimation::wind::WindConfig;

// Momentum drag 0.3/s: 2 m/s forward through the air is pushed back at 0.6 m/s².
let config = WindConfig { momentum_per_s: Vec2::new(0.3, 0.3), ..Default::default() };
let drag = config.drag_mps2(Vec2::new(2.0, 0.0));
assert!((drag - Vec2::new(-0.6, 0.0)).norm() < 1e-6);

Trait Implementations§

Source§

impl Clone for WindConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WindConfig

Source§

impl Debug for WindConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WindConfig

Source§

fn default() -> Self

No drag model (the estimator off), and the default noises.

Source§

impl<'de> Deserialize<'de> for WindConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for WindConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for WindConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for WindConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.