pub struct PidController { /* private fields */ }Expand description
A PID controller (gains [Kp, Ki, Kd]) tuned by differentiating through the plant rollout.
Implementations§
Source§impl PidController
impl PidController
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 controller for a damped point mass mass·ẍ = u − damping·ẋ − disturbance, tasked to hold
setpoint. Starts proportional-only (Kp=1, Ki=0, Kd=0).
pub fn gains(&self) -> [f64; 3]
Sourcepub fn simulate(&self) -> Vec<f64>
pub fn simulate(&self) -> Vec<f64>
Roll out the closed loop in plain f64 and return the position trajectory (for plotting).
Sourcepub fn final_error(&self) -> f64
pub fn final_error(&self) -> f64
Steady-state tracking error (distance of the final position from the setpoint).
Sourcepub fn train_step(&mut self, lr: f64) -> f64
pub fn train_step(&mut self, lr: f64) -> f64
One Adam step of the tracking cost, differentiating through the closed-loop rollout. Returns the cost.
Auto Trait Implementations§
impl Freeze for PidController
impl RefUnwindSafe for PidController
impl Send for PidController
impl Sync for PidController
impl Unpin for PidController
impl UnsafeUnpin for PidController
impl UnwindSafe for PidController
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.