LinearController

Struct LinearController 

Source
pub struct LinearController<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> {
    pub actuator: ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>,
    pub pid: Pid,
    pub mode: LinearMode,
    pub target_position_mm: f32,
    pub min_position_mm: f32,
    pub max_position_mm: f32,
    pub on_target_tolerance_mm: f32,
}
Expand description

PID position controller for an Actuonix linear actuator. Call step periodically.

Fields§

§actuator: ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>§pid: Pid§mode: LinearMode§target_position_mm: f32§min_position_mm: f32§max_position_mm: f32§on_target_tolerance_mm: f32

Implementations§

Source§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> LinearController<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: _embedded_hal_PwmPin<Duty = u16>, Pwm2: _embedded_hal_PwmPin<Duty = u16>, ReadPos: FnMut() -> u16,

Source

pub fn new( actuator: ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>, pid: Pid, min_position_mm: f32, max_position_mm: f32, on_target_tolerance_mm: f32, ) -> Self

Create a new linear controller with PID gains and limits.

Source

pub fn set_target_position_mm(&mut self, mm: f32)

Set a new target position (mm), automatically clamped to limits.

Source

pub fn step(&mut self, dt: f32)

Run one control step.

Auto Trait Implementations§

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> Freeze for LinearController<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: Freeze, Pwm2: Freeze, ReadPos: Freeze,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> RefUnwindSafe for LinearController<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: RefUnwindSafe, Pwm2: RefUnwindSafe, ReadPos: RefUnwindSafe,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> Send for LinearController<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: Send, Pwm2: Send, ReadPos: Send,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> Sync for LinearController<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: Sync, Pwm2: Sync, ReadPos: Sync,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> Unpin for LinearController<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: Unpin, Pwm2: Unpin, ReadPos: Unpin,

§

impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> UnwindSafe for LinearController<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
where Pwm1: UnwindSafe, Pwm2: UnwindSafe, ReadPos: UnwindSafe,

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, 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.