Struct pid_loop::PID [−][src]
pub struct PID<F> {
pub kp: F,
pub ki: F,
pub kd: F,
// some fields omitted
}
Expand description
PID controller
Examples
use pid_loop::PID;
let target = 42.0;
let mut controller = PID::<f64>::new(2.0, 0.7, 0.3);
let correction = controller.next(target, measure());
fn measure() -> f64 { todo!() }
Fields
kp: F
Proportional gain.
ki: F
Integral gain.
kd: F
Derivative gain.
Implementations
Create a new instance of PID
.
Examples
#![allow(unused_assignments)]
use pid_loop::PID;
let mut controller = PID::<f32>::new(0.7, 0.034, 0.084);
Reset controller internal state.
Examples
#![allow(unused_assignments)]
use pid_loop::PID;
let target = 30.0;
let mut controller = PID::<f32>::new(0.7, 0.034, 0.084);
controller.next(target, 42.0);
controller.reset();
Set minimum limit for error sum.
Examples
#![allow(unused_assignments)]
use pid_loop::PID;
let target = 30;
let mut controller = PID::<i128>::new(7, 34, 4);
controller.set_min_error_sum(Some(-300));
Set maximum limit for error sum.
Examples
#![allow(unused_assignments)]
use pid_loop::PID;
let target = 30.0;
let mut controller = PID::<f32>::new(0.7, 0.034, 0.084);
controller.set_max_error_sum(Some(300.0));
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>::new(0.7, 0.034, 0.084);
let correction = controller.next(target, 42.0);