pub struct IdentifyProbe { /* private fields */ }Expand description
Excites one loop with a square wave on its setpoint while recording its axis’s body rate and
moment command, then fits a RateModel to them.
Each tick the host hands it the axis’s body rate and the moment it commanded on the last
tick; the probe returns the offset to add to the loop’s setpoint. Every loop stays closed, so
the fit sees the airframe through its own controllers. It fits each delay from 1 to
MAX_DELAY_TICKS on the same ticks and keeps the one with the least residual (the
shortest of a near-tie) among those whose moment pushes the axis the way it was pushed (among
all when none does): a fit with a negative moment effect can’t be designed from.
The fit takes the rate’s change y[k] − y[k−1] as its target and y[k−1], y[k−1] − y[k−2] as its rate terms: at 250 Hz the last two rates are nearly equal, and fitting them
side by side loses the lag in f32 (#516). It keeps only the sums of each delay’s least
squares (about 1.7 KB), not the record, and solves them when the excitation ends. A
constant term takes up the trim moment. A non-finite rate or moment drops that tick and the
next MAX_DELAY_TICKS + 2 ticks while the history refills.
§Examples
use stable_flight::tuning::autotune::COPTER_IDENTIFY;
use stable_flight::tuning::{IdentifyProbe, IdentifyStatus};
let mut probe = IdentifyProbe::new(COPTER_IDENTIFY);
// The square wave starts high: the first tick's offset is the step less its washout.
let offset = probe.step(0.004, 0.0, 0.0);
assert!(offset > 0.0 && offset <= COPTER_IDENTIFY.amplitude);
assert!(matches!(probe.status(), IdentifyStatus::Running { .. }));Implementations§
Source§impl IdentifyProbe
impl IdentifyProbe
Sourcepub fn new(config: IdentifyConfig) -> Self
pub fn new(config: IdentifyConfig) -> Self
Sourcepub fn step(&mut self, dt: f32, rate_radps: f32, last_moment: f32) -> f32
pub fn step(&mut self, dt: f32, rate_radps: f32, last_moment: f32) -> f32
Advances the probe by dt seconds with the axis’s body rate this tick (rad/s) and its
moment command on the last tick, and returns the offset to add to the loop’s setpoint
(0 once it has finished). Fits the model on the tick the excitation ends.
§Panics
If dt is not positive and finite.
Sourcepub fn status(&self) -> IdentifyStatus
pub fn status(&self) -> IdentifyStatus
Where the probe stands.
Trait Implementations§
Source§impl Clone for IdentifyProbe
impl Clone for IdentifyProbe
Source§impl Debug for IdentifyProbe
impl Debug for IdentifyProbe
Source§impl PartialEq for IdentifyProbe
impl PartialEq for IdentifyProbe
impl StructuralPartialEq for IdentifyProbe
Auto Trait Implementations§
impl Freeze for IdentifyProbe
impl RefUnwindSafe for IdentifyProbe
impl Send for IdentifyProbe
impl Sync for IdentifyProbe
impl Unpin for IdentifyProbe
impl UnsafeUnpin for IdentifyProbe
impl UnwindSafe for IdentifyProbe
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.