Struct embedded_flight_control::pid::PID
source · [−]pub struct PID {Show 17 fields
pub reset_filter: bool,
pub target: f32,
pub error: f32,
pub derivative: f32,
pub dt: f32,
pub info: Info,
pub slew_limiter: SlewLimiter<2>,
pub slew_limit_scale: f32,
pub integrator: f32,
pub kp: f32,
pub ki: f32,
pub kd: f32,
pub ki_max: f32,
pub kff: f32,
pub filter_t_hz: f32,
pub filter_e_hz: f32,
pub filter_d_hz: f32,
}Fields
reset_filter: booltarget: f32error: f32derivative: f32dt: f32info: Infoslew_limiter: SlewLimiter<2>slew_limit_scale: f32integrator: f32kp: f32ki: f32kd: f32ki_max: f32kff: f32filter_t_hz: f32filter_e_hz: f32filter_d_hz: f32Implementations
sourceimpl PID
impl PID
pub fn new(
initial_p: f32,
initial_i: f32,
initial_d: f32,
initial_ff: f32,
initial_imax: f32,
initial_filt_T_hz: f32,
initial_filt_E_hz: f32,
initial_filt_D_hz: f32,
dt: f32
) -> Self
pub fn with_slew_rate(
initial_p: f32,
initial_i: f32,
initial_d: f32,
initial_ff: f32,
initial_imax: f32,
initial_filt_T_hz: f32,
initial_filt_E_hz: f32,
initial_filt_D_hz: f32,
dt: f32,
initial_srmax: f32,
initial_srtau: f32
) -> Self
sourceimpl PID
impl PID
pub fn target_filter_alpha(&self) -> f32
pub fn error_filter_alpha(&self) -> f32
pub fn derivative_filter_alpha(&self) -> f32
pub fn feed_forward(&self) -> f32
sourcepub fn update_integral(&mut self, limit: bool)
pub fn update_integral(&mut self, limit: bool)
Update the integral part of this PID. If the limit flag is set the integral is only allowed to shrink.
sourcepub fn update(
&mut self,
target: f32,
measurement: f32,
limit: bool,
now_ms: u32
) -> f32
pub fn update(
&mut self,
target: f32,
measurement: f32,
limit: bool,
now_ms: u32
) -> f32
Update target and measured inputs to the PID controller and calculate output. Target and error are filtered, then derivative is calculated and filtered, then the integral is then updated based on the setting of the limit flag
Auto Trait Implementations
impl RefUnwindSafe for PID
impl Send for PID
impl Sync for PID
impl Unpin for PID
impl UnwindSafe for PID
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
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 more
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).
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.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self to the equivalent element of its superset.