MotionProfile

Struct MotionProfile 

Source
pub struct MotionProfile {
    pub total_steps: u32,
    pub direction: Direction,
    pub accel_steps: u32,
    pub cruise_steps: u32,
    pub decel_steps: u32,
    pub initial_interval_ns: u32,
    pub cruise_interval_ns: u32,
    pub accel_rate: f32,
    pub decel_rate: f32,
}
Expand description

Computed motion profile for a move (asymmetric trapezoidal).

Fields§

§total_steps: u32

Total steps to move (absolute value).

§direction: Direction

Direction of motion.

§accel_steps: u32

Steps in acceleration phase.

§cruise_steps: u32

Steps in cruise phase (constant velocity).

§decel_steps: u32

Steps in deceleration phase.

§initial_interval_ns: u32

Initial step interval (nanoseconds) - at start of acceleration.

§cruise_interval_ns: u32

Cruise step interval (nanoseconds) - at max velocity.

§accel_rate: f32

Acceleration rate in steps/sec².

§decel_rate: f32

Deceleration rate in steps/sec².

Implementations§

Source§

impl MotionProfile

Source

pub fn asymmetric_trapezoidal( total_steps: i64, max_velocity: f32, acceleration: f32, deceleration: f32, ) -> Self

Create an asymmetric trapezoidal motion profile.

§Arguments
  • total_steps - Signed step count (positive = CW, negative = CCW)
  • max_velocity - Maximum velocity in steps/sec
  • acceleration - Acceleration rate in steps/sec²
  • deceleration - Deceleration rate in steps/sec²
Source

pub fn symmetric_trapezoidal( total_steps: i64, max_velocity: f32, acceleration: f32, ) -> Self

Create a symmetric trapezoidal profile (same accel and decel).

Source

pub fn zero() -> Self

Create a zero-length profile (no motion).

Source

pub fn is_zero(&self) -> bool

Check if this is a zero-length profile.

Source

pub fn phase_at(&self, step: u32) -> MotionPhase

Get the phase at a given step number.

Source

pub fn interval_at(&self, step: u32) -> u32

Calculate step interval for a given step number.

Uses the step timing formula for trapezoidal acceleration.

Source

pub fn estimated_duration_secs(&self) -> f32

Estimate total duration of the motion profile in seconds.

This is an approximation based on the trapezoidal profile phases.

Trait Implementations§

Source§

impl Clone for MotionProfile

Source§

fn clone(&self) -> MotionProfile

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MotionProfile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.