LiftController

Struct LiftController 

Source
pub struct LiftController<const CS_P: char, const CS_N: u8, const IN1_P: char, const IN1_N: u8, const IN2_P: char, const IN2_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8> { /* private fields */ }
Expand description

Controller state and configuration.

Implementations§

Source§

impl<const CS_P: char, const CS_N: u8, const IN1_P: char, const IN1_N: u8, const IN2_P: char, const IN2_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8> LiftController<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>

Source

pub fn new( motor: LiftMotor<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>, pid: Pid, min_height_mm: f32, max_height_mm: f32, on_target_tolerance_mm: f32, ) -> Self

Create a new lift controller with PID gains and limits.

Source

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

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

Source

pub fn disable(&mut self)

Directly disable the lift (coast).

Source

pub fn enable(&mut self)

Re-enable position control.

Source

pub fn height_mm(&self) -> f32

Current measured height (mm).

Source

pub fn on_target(&self) -> bool

Returns true if the lift is within tolerance of its commanded height.

Source

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

Run one control step.

dt — time delta in seconds since the previous call, e.g. 0.01 for 10ms.

Source

pub fn motor( &self, ) -> &LiftMotor<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>

Expose the underlying LiftMotor.

Source

pub fn motor_mut( &mut self, ) -> &mut LiftMotor<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>

Mutable access to the underlying LiftMotor.

Auto Trait Implementations§

§

impl<const CS_P: char, const CS_N: u8, const IN1_P: char, const IN1_N: u8, const IN2_P: char, const IN2_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8> Freeze for LiftController<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>

§

impl<const CS_P: char, const CS_N: u8, const IN1_P: char, const IN1_N: u8, const IN2_P: char, const IN2_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8> RefUnwindSafe for LiftController<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>

§

impl<const CS_P: char, const CS_N: u8, const IN1_P: char, const IN1_N: u8, const IN2_P: char, const IN2_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8> Send for LiftController<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>

§

impl<const CS_P: char, const CS_N: u8, const IN1_P: char, const IN1_N: u8, const IN2_P: char, const IN2_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8> !Sync for LiftController<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>

§

impl<const CS_P: char, const CS_N: u8, const IN1_P: char, const IN1_N: u8, const IN2_P: char, const IN2_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8> Unpin for LiftController<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>

§

impl<const CS_P: char, const CS_N: u8, const IN1_P: char, const IN1_N: u8, const IN2_P: char, const IN2_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8> UnwindSafe for LiftController<CS_P, CS_N, IN1_P, IN1_N, IN2_P, IN2_N, SLP_P, SLP_N, DIS_P, DIS_N>

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.