pub struct PidController { /* private fields */ }Expand description
A stateful PID controller.
Implementations§
Source§impl PidController
A stateful PID controller.
impl PidController
A stateful PID controller.
Sourcepub fn new(config: PidConfig) -> Self
pub fn new(config: PidConfig) -> Self
Initializes a new controller with the provided gains and zeroed state.
Sourcepub fn update(&mut self, setpoint: f32, measurement: f32, dt: f32) -> f32
pub fn update(&mut self, setpoint: f32, measurement: f32, dt: f32) -> f32
Calculates the corrective signal based on a setpoint and measurement.
§Parameters
setpoint- The desired value (Target).measurement- The current estimated value (Feedback).dt- Time delta since the last update in seconds.
Sourcepub fn update_with_error(&mut self, error: f32, dt: f32) -> f32
pub fn update_with_error(&mut self, error: f32, dt: f32) -> f32
Primary calculation engine for the PID signal.
This method performs the following:
- Proportional: $K_p \times error$
- Integral: Accumulates $error \times dt$, clamped by
max_integral. - Derivative: $K_d \times \frac{\Delta error}{dt}$
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