Struct pid_loop::PID [−][src]
pub struct PID<F, const W: usize> {
pub kp: F,
pub ki: F,
pub kd: F,
pub kf: F,
pub kv: F,
// some fields omitted
}Expand description
PID controller
Examples
use pid_loop::PID;
let target = 42.0;
let mut controller = PID::<f64, 1>::new(2.0, 0.7, 0.3, 0.0, 0.0);
let correction = controller.next(target, measure());
fn measure() -> f64 { todo!() }Fields
kp: FProportional gain.
ki: FIntegral gain.
kd: FDerivative gain.
kf: FFeed forward gain
kv: FVelocity
Implementations
Create a new instance of PID.
Examples
#![allow(unused_assignments)]
use pid_loop::PID;
let mut controller = PID::<f32, 1>::new(0.7, 0.034, 0.084, 0.1, 0.0);Reset controller internal state.
Examples
#![allow(unused_assignments)]
use pid_loop::PID;
let target = 30.0;
let mut controller = PID::<f32, 1>::new(0.7, 0.034, 0.084, 0.1, 0.0);
controller.next(target, 42.0);
controller.reset();
Push next measurement into the controller and return correction.
Examples
#![allow(unused_assignments)]
use pid_loop::PID;
let target = 30.0;
let mut controller = PID::<f64, 1>::new(0.7, 0.034, 0.084, 0.1, 0.1);
let correction = controller.next(target, 42.0);