Flat

Struct Flat 

Source
pub struct Flat<Num = DefaultNum> { /* private fields */ }
Expand description

Flat motion profile

This is the simplest possible motion profile, as it produces just a constant velocity. Please note that this is of limited use, and should probably be restricted to testing.

Theoretically, this profile produces infinite acceleration/deceleration at the beginning and end of the movement. In practice, you might get away with this, if the velocity and the load on the motor are low enough. Otherwise, this will definitely produce missed steps.

Create an instance of this struct using Flat::new, then use the API defined by MotionProfile (which this struct implements) to generate the acceleration ramp.

§Unit of Time

This code is agnostic on which unit of time is used. If you provide the target velocity in steps per second, the unit of the delay returned will be seconds.

This allows you to pass the target velocity in steps per number of timer counts for the timer you’re using, completely eliminating any conversion overhead for the delay.

§Type Parameter

The type parameter Num defines the type that is used to represent the target velocity and the delay per step. It is set to a 32-bit fixed-point number type by default.

This default is appropriate for 32-bit microcontrollers, but it might not be ideal for 8- or 16-bit microcontrollers, or target platforms where hardware support for floating point numbers is available. You can override it with other types from the fixed crate, or f32/f64, for example.

Implementations§

Source§

impl<Num> Flat<Num>

Source

pub fn new() -> Self

Create a new instance of Flat

Trait Implementations§

Source§

impl Default for Flat<f32>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Num> MotionProfile for Flat<Num>
where Num: Copy + Zero + Inv<Output = Num>,

Source§

type Velocity = Num

The type used for representing velocities
Source§

type Delay = Num

The type used for representing delay values
Source§

fn enter_position_mode(&mut self, max_velocity: Self::Velocity, num_steps: u32)

Enter position mode Read more
Source§

fn next_delay(&mut self) -> Option<Self::Delay>

Return the next step delay Read more
Source§

fn delays(&mut self) -> Delays<'_, Self>

Return an iterator over delay values of each step Read more
Source§

fn velocities(&mut self) -> Velocities<'_, Self>

Return an iterator over velocity values of each step Read more
Source§

fn accelerations<Accel>(&mut self) -> Accelerations<'_, Self, Accel>

Return an iterator over the acceleration values between steps Read more

Auto Trait Implementations§

§

impl<Num> Freeze for Flat<Num>
where Num: Freeze,

§

impl<Num> RefUnwindSafe for Flat<Num>
where Num: RefUnwindSafe,

§

impl<Num> Send for Flat<Num>
where Num: Send,

§

impl<Num> Sync for Flat<Num>
where Num: Sync,

§

impl<Num> Unpin for Flat<Num>
where Num: Unpin,

§

impl<Num> UnwindSafe for Flat<Num>
where Num: 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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.