pub struct ControlState {
pub setpoint: f64,
pub process_variable: f64,
pub error: f64,
pub integral: f64,
pub derivative: f64,
pub last_error: f64,
pub last_time: u64,
}Expand description
Control system state for feedback loops
Fields§
§setpoint: f64§process_variable: f64§error: f64§integral: f64§derivative: f64§last_error: f64§last_time: u64Implementations§
Source§impl ControlState
impl ControlState
Sourcepub fn new(setpoint: f64, initial_value: f64) -> Self
pub fn new(setpoint: f64, initial_value: f64) -> Self
Create a new control state.
last_time is initialised to 0 so that the first update() call with any
non-zero current_time produces a well-defined dt. Callers that need
wall-clock alignment should call state.last_time = current_unix_secs after
construction.
Sourcepub fn update(&mut self, new_value: f64, current_time: u64)
pub fn update(&mut self, new_value: f64, current_time: u64)
Update control state with new measurement
Sourcepub fn reset_integral(&mut self)
pub fn reset_integral(&mut self)
Reset integral term to prevent windup
Trait Implementations§
Source§impl Clone for ControlState
impl Clone for ControlState
Source§fn clone(&self) -> ControlState
fn clone(&self) -> ControlState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ControlState
impl RefUnwindSafe for ControlState
impl Send for ControlState
impl Sync for ControlState
impl Unpin for ControlState
impl UnsafeUnpin for ControlState
impl UnwindSafe for ControlState
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more