Struct stspin220::ramp_maker::Flat
[−]pub struct Flat<Num = FixedU32<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>> { /* 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
Trait Implementations
impl<Num> MotionProfile for Flat<Num> where
Num: Copy + Zero + Inv<Output = Num>,
impl<Num> MotionProfile for Flat<Num> where
Num: Copy + Zero + Inv<Output = Num>,
type Velocity = Num
type Velocity = Num
The type used for representing velocities
type Delay = Num
type Delay = Num
The type used for representing delay values
fn enter_position_mode(
&mut self,
max_velocity: <Flat<Num> as MotionProfile>::Velocity,
num_steps: u32
)
fn enter_position_mode(
&mut self,
max_velocity: <Flat<Num> as MotionProfile>::Velocity,
num_steps: u32
)
Enter position mode Read more
fn next_delay(&mut self) -> Option<<Flat<Num> as MotionProfile>::Delay>
fn next_delay(&mut self) -> Option<<Flat<Num> as MotionProfile>::Delay>
Return the next step delay Read more
fn delays(&mut self) -> Delays<'_, Self>ⓘNotable traits for Delays<'r, Profile>impl<'r, Profile> Iterator for Delays<'r, Profile> where
Profile: MotionProfile, type Item = <Profile as MotionProfile>::Delay;
fn delays(&mut self) -> Delays<'_, Self>ⓘNotable traits for Delays<'r, Profile>impl<'r, Profile> Iterator for Delays<'r, Profile> where
Profile: MotionProfile, type Item = <Profile as MotionProfile>::Delay;
Profile: MotionProfile, type Item = <Profile as MotionProfile>::Delay;
Return an iterator over delay values of each step Read more
fn velocities(&mut self) -> Velocities<'_, Self>ⓘNotable traits for Velocities<'r, Profile>impl<'r, Profile> Iterator for Velocities<'r, Profile> where
Profile: MotionProfile,
<Profile as MotionProfile>::Delay: Inv,
<<Profile as MotionProfile>::Delay as Inv>::Output == <Profile as MotionProfile>::Velocity, type Item = <Profile as MotionProfile>::Velocity;
fn velocities(&mut self) -> Velocities<'_, Self>ⓘNotable traits for Velocities<'r, Profile>impl<'r, Profile> Iterator for Velocities<'r, Profile> where
Profile: MotionProfile,
<Profile as MotionProfile>::Delay: Inv,
<<Profile as MotionProfile>::Delay as Inv>::Output == <Profile as MotionProfile>::Velocity, type Item = <Profile as MotionProfile>::Velocity;
Profile: MotionProfile,
<Profile as MotionProfile>::Delay: Inv,
<<Profile as MotionProfile>::Delay as Inv>::Output == <Profile as MotionProfile>::Velocity, type Item = <Profile as MotionProfile>::Velocity;
Return an iterator over velocity values of each step Read more
fn accelerations<Accel>(&mut self) -> Accelerations<'_, Self, Accel>ⓘNotable traits for Accelerations<'r, Profile, Accel>impl<'r, Profile, Accel> Iterator for Accelerations<'r, Profile, Accel> where
Profile: MotionProfile,
<Profile as MotionProfile>::Delay: Inv,
<Profile as MotionProfile>::Delay: Add<<Profile as MotionProfile>::Delay>,
<Profile as MotionProfile>::Delay: Div<<Profile as MotionProfile>::Delay>,
<Profile as MotionProfile>::Velocity: Sub<<Profile as MotionProfile>::Velocity>,
<Profile as MotionProfile>::Velocity: Div<<Profile as MotionProfile>::Delay>,
<Profile as MotionProfile>::Delay: Copy,
<Profile as MotionProfile>::Delay: One,
<<Profile as MotionProfile>::Delay as Inv>::Output == <Profile as MotionProfile>::Velocity,
<<Profile as MotionProfile>::Delay as Add<<Profile as MotionProfile>::Delay>>::Output == <Profile as MotionProfile>::Delay,
<<Profile as MotionProfile>::Delay as Div<<Profile as MotionProfile>::Delay>>::Output == <Profile as MotionProfile>::Delay,
<<Profile as MotionProfile>::Velocity as Sub<<Profile as MotionProfile>::Velocity>>::Output == <Profile as MotionProfile>::Velocity,
<<Profile as MotionProfile>::Velocity as Div<<Profile as MotionProfile>::Delay>>::Output == Accel, type Item = Accel;
fn accelerations<Accel>(&mut self) -> Accelerations<'_, Self, Accel>ⓘNotable traits for Accelerations<'r, Profile, Accel>impl<'r, Profile, Accel> Iterator for Accelerations<'r, Profile, Accel> where
Profile: MotionProfile,
<Profile as MotionProfile>::Delay: Inv,
<Profile as MotionProfile>::Delay: Add<<Profile as MotionProfile>::Delay>,
<Profile as MotionProfile>::Delay: Div<<Profile as MotionProfile>::Delay>,
<Profile as MotionProfile>::Velocity: Sub<<Profile as MotionProfile>::Velocity>,
<Profile as MotionProfile>::Velocity: Div<<Profile as MotionProfile>::Delay>,
<Profile as MotionProfile>::Delay: Copy,
<Profile as MotionProfile>::Delay: One,
<<Profile as MotionProfile>::Delay as Inv>::Output == <Profile as MotionProfile>::Velocity,
<<Profile as MotionProfile>::Delay as Add<<Profile as MotionProfile>::Delay>>::Output == <Profile as MotionProfile>::Delay,
<<Profile as MotionProfile>::Delay as Div<<Profile as MotionProfile>::Delay>>::Output == <Profile as MotionProfile>::Delay,
<<Profile as MotionProfile>::Velocity as Sub<<Profile as MotionProfile>::Velocity>>::Output == <Profile as MotionProfile>::Velocity,
<<Profile as MotionProfile>::Velocity as Div<<Profile as MotionProfile>::Delay>>::Output == Accel, type Item = Accel;
Profile: MotionProfile,
<Profile as MotionProfile>::Delay: Inv,
<Profile as MotionProfile>::Delay: Add<<Profile as MotionProfile>::Delay>,
<Profile as MotionProfile>::Delay: Div<<Profile as MotionProfile>::Delay>,
<Profile as MotionProfile>::Velocity: Sub<<Profile as MotionProfile>::Velocity>,
<Profile as MotionProfile>::Velocity: Div<<Profile as MotionProfile>::Delay>,
<Profile as MotionProfile>::Delay: Copy,
<Profile as MotionProfile>::Delay: One,
<<Profile as MotionProfile>::Delay as Inv>::Output == <Profile as MotionProfile>::Velocity,
<<Profile as MotionProfile>::Delay as Add<<Profile as MotionProfile>::Delay>>::Output == <Profile as MotionProfile>::Delay,
<<Profile as MotionProfile>::Delay as Div<<Profile as MotionProfile>::Delay>>::Output == <Profile as MotionProfile>::Delay,
<<Profile as MotionProfile>::Velocity as Sub<<Profile as MotionProfile>::Velocity>>::Output == <Profile as MotionProfile>::Velocity,
<<Profile as MotionProfile>::Velocity as Div<<Profile as MotionProfile>::Delay>>::Output == Accel, type Item = Accel;
Return an iterator over the acceleration values between steps Read more
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcefn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
sourcefn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
sourcefn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
sourceimpl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
sourcefn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcefn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
sourcefn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcefn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
sourcefn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcefn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
sourcefn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcefn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
sourcefn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.