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
impl WingDesign
Sourcepub fn new(model: WingModel, config: WingDesignConfig) -> Self
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).
Sourcepub fn advance(&mut self, candidates: usize) -> WingDesignStatus
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
impl Clone for WingDesign
impl Copy for WingDesign
Source§impl Debug for WingDesign
impl Debug for WingDesign
Source§impl PartialEq for WingDesign
impl PartialEq for WingDesign
impl StructuralPartialEq for WingDesign
Auto Trait Implementations§
impl Forget for WingDesign
impl Freeze for WingDesign
impl Move for WingDesign
impl RefUnwindSafe for WingDesign
impl Send for WingDesign
impl Sync for WingDesign
impl Unpin for WingDesign
impl UnsafeUnpin for WingDesign
impl UnwindSafe for WingDesign
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.