Trait MotionControl

Source
pub trait MotionControl {
    type Velocity: Copy;
    type Error;

    // Required methods
    fn move_to_position(
        &mut self,
        max_velocity: Self::Velocity,
        target_step: i32,
    ) -> Result<(), Self::Error>;
    fn reset_position(&mut self, step: i32) -> Result<(), Self::Error>;
    fn update(&mut self) -> Result<bool, Self::Error>;
}
Expand description

Implemented by drivers that have motion control capabilities

A software-based fallback implementation exists in the motion_control module, for drivers that implement SetDirection and Step.

Required Associated Types§

Source

type Velocity: Copy

The type used by the driver to represent velocity

Source

type Error

The type error that can happen when using this trait

Required Methods§

Source

fn move_to_position( &mut self, max_velocity: Self::Velocity, target_step: i32, ) -> Result<(), Self::Error>

Move to the given position

This method must arrange for the motion to start, but must not block until it is completed. If more attention is required during the motion, this should be handled in MotionControl::update.

Source

fn reset_position(&mut self, step: i32) -> Result<(), Self::Error>

Reset internal position to the given value

This method must not start a motion. Its only purpose is to change the driver’s internal position value, for example for homing.

Source

fn update(&mut self) -> Result<bool, Self::Error>

Update an ongoing motion

This method may contain any code required to maintain an ongoing motion, if required, or it might just check whether a motion is still ongoing.

Return true, if motion is ongoing, false otherwise. If false is returned, the caller may assume that this method doesn’t need to be called again, until starting another motion.

Implementors§

Source§

impl<'r, T> MotionControl for RefMut<'r, T>
where T: MotionControl,

Source§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> MotionControl for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Driver: SetDirection + Step, Profile: MotionProfile, Timer: Timer<TIMER_HZ>, <Profile as MotionProfile>::Velocity: Copy, Convert: DelayToTicks<<Profile as MotionProfile>::Delay, TIMER_HZ>,

Source§

type Velocity = <Profile as MotionProfile>::Velocity

Source§

type Error = Error<<Driver as SetDirection>::Error, <<Driver as SetDirection>::Dir as ErrorType>::Error, <Driver as Step>::Error, <<Driver as Step>::Step as ErrorType>::Error, <Timer as Timer<TIMER_HZ>>::Error, <Convert as DelayToTicks<<Profile as MotionProfile>::Delay, TIMER_HZ>>::Error>