pub struct ModelBasedControl { /* private fields */ }Expand description
Learn a plant model from data, tune a PID inside it, and deploy on the true plant.
Implementations§
Source§impl ModelBasedControl
impl ModelBasedControl
Sourcepub fn new(mass: f64, damping: f64, disturbance: f64, setpoint: f64) -> Self
pub fn new(mass: f64, damping: f64, disturbance: f64, setpoint: f64) -> Self
A task on a hidden damped point mass, with the controller starting proportional-only.
Sourcepub fn identify(&mut self)
pub fn identify(&mut self)
Stage 1 — identify ẍ = a·x + b·v + c·u + d from data by least squares.
Sourcepub fn learned_coeffs(&self) -> [f64; 4]
pub fn learned_coeffs(&self) -> [f64; 4]
The learned model coefficients [a, b, c, d].
Sourcepub fn true_coeffs(&self) -> [f64; 4]
pub fn true_coeffs(&self) -> [f64; 4]
The true coefficients (for comparison): a=0, b=−damping/m, c=1/m, d=−disturbance/m.
pub fn gains(&self) -> [f64; 3]
Sourcepub fn deploy_error(&self) -> f64
pub fn deploy_error(&self) -> f64
Steady-state error on the true plant.
Sourcepub fn train_step(&mut self, lr: f64) -> f64
pub fn train_step(&mut self, lr: f64) -> f64
Stage 2 — one Adam step tuning the PID by differentiating through the LEARNED model. Returns the cost.
Auto Trait Implementations§
impl Freeze for ModelBasedControl
impl RefUnwindSafe for ModelBasedControl
impl Send for ModelBasedControl
impl Sync for ModelBasedControl
impl Unpin for ModelBasedControl
impl UnsafeUnpin for ModelBasedControl
impl UnwindSafe for ModelBasedControl
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
Mutably borrows from an owned value. Read more
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.