Skip to main content

WingDesign

Struct WingDesign 

Source
pub struct WingDesign { /* private fields */ }
Expand description

Designs one wing axis’s rate gains and attitude time constant on its fitted WingModel, by stepping the attitude loop on the model rather than in flight.

The feedforward is the model’s: the moment that holds a rate against the damping. On a stiff axis (stiffness above 0, a wing’s pitch) a damping fitted at or below 0 is read as none, so no feedforward: the angle of attack follows the rate, and the fit splits the damping loosely between the two. For P, I, and the time constant τ, each candidate flies an attitude step on the model through the plane’s loops (the rate target the error over τ within the rate limit, the moment its P, I, and feedforward terms within the limit) and passes when the step overshoots by no more than the allowance, settles, rises within rise_per_time_constant × τ, and clips for no longer than allowed: the plane spec’s targets. τ is bisected to the quickest at which some P and I on a coarse grid pass (16 × 12), then raised by 15% for margin; at that τ the design takes the passing P and I farthest from any failing one on the grid, the middle of what works, so a model a little off still flies. An I too small to hold the model’s trim (beyond the static trim) within half the integral limit never passes: the integral would clip holding it. The airplane’s pitch designed at I 0.25 against a 2 rad limit sat 1.75° off its held attitude, slowed 1.75 m/s, and its stage timed out settling (#534).

Each candidate is a step of up to step_duration_s on the model at 250 Hz, a few thousand multiplies; a design takes up to about 1,350. advance runs a given number of candidates, so a host spreads the design over its updates.

§Examples

use stable_flight::tuning::{WingDesign, WingDesignConfig, WingDesignStatus, WingModel};

let model = WingModel {
    stiffness_per_s2: 0.0,
    damping_per_s: 8.0,
    control_radps2: 40.0,
    lag_s: 0.02,
    delay_s: 0.0,
    path_turn_per_s: 0.0,
    trim_moment: 0.0,
};
let config = WingDesignConfig {
    amplitude_rad: 0.5,
    step_duration_s: 4.0,
    max_rate_radps: 1.2,
    max_moment: 0.8,
    max_integral: 2.0,
    static_trim: 0.0,
    max_overshoot: 0.05,
    max_saturated_s: 0.042,
    time_constant_range_s: [0.2, 1.5],
    rise_per_time_constant: 2.2,
};
let mut design = WingDesign::new(model, config);
while design.advance(100) == WingDesignStatus::Running {}
let WingDesignStatus::Done(gains) = design.advance(1) else { panic!("no design") };
assert_eq!(gains.rate.ff, model.feedforward());

Implementations§

Source§

impl WingDesign

Source

pub fn new(model: WingModel, config: WingDesignConfig) -> Self

A design of model’s axis to config’s targets, ready to advance.

§Panics

If config is invalid (WingDesignConfig::validate).

Source

pub fn advance(&mut self, candidates: usize) -> WingDesignStatus

Steps up to candidates candidates on the model, and returns where the design stands.

Trait Implementations§

Source§

impl Clone for WingDesign

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 WingDesign

Source§

impl Debug for WingDesign

Source§

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

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

impl PartialEq for WingDesign

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 StructuralPartialEq for WingDesign

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> 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.