Struct 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: bool§target: f32§error: f32§derivative: f32§dt: f32§info: Info§slew_limiter: SlewLimiter<2>§slew_limit_scale: f32§integrator: f32§kp: f32§ki: f32§kd: f32§ki_max: f32§kff: f32§filter_t_hz: f32§filter_e_hz: f32§filter_d_hz: f32

Implementations§

Source§

impl PID

Source

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

Source

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

Source§

impl PID

Source

pub fn target_filter_alpha(&self) -> f32

Source

pub fn error_filter_alpha(&self) -> f32

Source

pub fn derivative_filter_alpha(&self) -> f32

Source

pub fn feed_forward(&self) -> f32

Source

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.

Source

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 Freeze for PID

§

impl RefUnwindSafe for PID

§

impl Send for PID

§

impl Sync for PID

§

impl Unpin for PID

§

impl UnwindSafe for PID

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.