Skip to main content

LinearController

Struct LinearController 

Source
pub struct LinearController<CS: CsControl, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> {
    pub actuator: ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>,
    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, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>§pid: Pid§mode: LinearMode§target_position_mm: f32§min_position_mm: f32§max_position_mm: f32§on_target_tolerance_mm: f32

Implementations§

Source§

impl<CS: CsControl, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> LinearController<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: _embedded_hal_PwmPin<Duty = u16>, Pwm2: _embedded_hal_PwmPin<Duty = u16>, ReadPos: FnMut() -> [u16; N],

Source

pub fn new( actuator: ActuonixLinear<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>, 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) -> Result<(), ControlError>

Run one control step. Returns Err(NoPositionFeedback) if the mode is PositionControl but the actuator has no enabled pot channels; in that case the actuator is braked for safety.

Auto Trait Implementations§

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> Freeze for LinearController<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: Freeze, Pwm2: Freeze, ReadPos: Freeze, CS: Freeze,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> RefUnwindSafe for LinearController<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: RefUnwindSafe, Pwm2: RefUnwindSafe, ReadPos: RefUnwindSafe, CS: RefUnwindSafe,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> Send for LinearController<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: Send, Pwm2: Send, ReadPos: Send, CS: Send,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> Sync for LinearController<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: Sync, Pwm2: Sync, ReadPos: Sync, CS: Sync,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> Unpin for LinearController<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: Unpin, Pwm2: Unpin, ReadPos: Unpin, CS: Unpin,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> UnsafeUnpin for LinearController<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: UnsafeUnpin, Pwm2: UnsafeUnpin, ReadPos: UnsafeUnpin, CS: UnsafeUnpin,

§

impl<CS, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos, const N: usize> UnwindSafe for LinearController<CS, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos, N>
where Pwm1: UnwindSafe, Pwm2: UnwindSafe, ReadPos: UnwindSafe, CS: 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.