pub trait MotionProfile: Sized {
type Velocity;
type Delay;
// Required methods
fn enter_position_mode(
&mut self,
max_velocity: Self::Velocity,
num_steps: u32,
);
fn next_delay(&mut self) -> Option<Self::Delay>;
// Provided methods
fn delays(&mut self) -> Delays<'_, Self> ⓘ { ... }
fn velocities(&mut self) -> Velocities<'_, Self> ⓘ { ... }
fn accelerations<Accel>(&mut self) -> Accelerations<'_, Self, Accel> ⓘ { ... }
}
Expand description
Abstract interface for motion profiles
Implemented by all motion profiles in this library. Can be used to write abstract code that doesn’t care about the specific motion profile used.
Required Associated Types§
Required Methods§
Sourcefn enter_position_mode(&mut self, max_velocity: Self::Velocity, num_steps: u32)
fn enter_position_mode(&mut self, max_velocity: Self::Velocity, num_steps: u32)
Enter position mode
In position mode, the motion profile will attempt to move for a specific number of steps and come to a stand-still at the target step.
The number of steps given here is always relative to the current position, as implementations of this trait are not expected to keep track of an absolute position.
Sourcefn next_delay(&mut self) -> Option<Self::Delay>
fn next_delay(&mut self) -> Option<Self::Delay>
Return the next step delay
Produces the delay for the next step. The unit of this delay is
implementation-defined. None
is returned, if no more steps need to be
taken. This should only happen, if the motion has ended.
Please note that motion profiles yield one value per step, even though only n-1 delay values are needed for n steps. The additional delay value will lead to an unnecessary delay before the first or after the last step. This was done to make accidental misuse of this trait less likely, as the most straight-forward use is to make one step per delay value in a loop.
All other details of the motion profile are implementation-defined.
If you need an iterator that produces the step delays, you can get one
by calling MotionProfile::delays
, which internally calls this
method.
Provided Methods§
Sourcefn delays(&mut self) -> Delays<'_, Self> ⓘ
fn delays(&mut self) -> Delays<'_, Self> ⓘ
Return an iterator over delay values of each step
This is a convenience method that returns an iterator which internally
just calls MotionProfile::next_delay
.
Sourcefn velocities(&mut self) -> Velocities<'_, Self> ⓘ
fn velocities(&mut self) -> Velocities<'_, Self> ⓘ
Return an iterator over velocity values of each step
This is a convenience method that returns an iterator which internally
calls MotionProfile::next_delay
and converts the delay to a
velocity.
This is mainly useful for testing and debugging.
Sourcefn accelerations<Accel>(&mut self) -> Accelerations<'_, Self, Accel> ⓘ
fn accelerations<Accel>(&mut self) -> Accelerations<'_, Self, Accel> ⓘ
Return an iterator over the acceleration values between steps
This is a convenience method that returns an iterator which internally
calls MotionProfile::next_delay
and computes the acceleration from
each pair of delay values.
This is mainly useful for testing and debugging.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.