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: Vec2Ballistic 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: Vec2Momentum 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: f32Specific-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: f32How 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: f32Standard 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: f32How 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: f32Most 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
impl WindConfig
Sourcepub fn validate(&self) -> Result<(), InvalidConfig>
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());Sourcepub fn drag_mps2(&self, air_mps: Vec2) -> Vec2
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
impl Clone for WindConfig
impl Copy for WindConfig
Source§impl Debug for WindConfig
impl Debug for WindConfig
Source§impl Default for WindConfig
impl Default for WindConfig
Source§impl<'de> Deserialize<'de> for WindConfig
impl<'de> Deserialize<'de> for WindConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for WindConfig
impl PartialEq for WindConfig
Source§impl Serialize for WindConfig
impl Serialize for WindConfig
impl StructuralPartialEq for WindConfig
Auto Trait Implementations§
impl Forget for WindConfig
impl Freeze for WindConfig
impl Move for WindConfig
impl RefUnwindSafe for WindConfig
impl Send for WindConfig
impl Sync for WindConfig
impl Unpin for WindConfig
impl UnsafeUnpin for WindConfig
impl UnwindSafe for WindConfig
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.