pub struct Trapezoidal<Num = FixedU64<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>> { /* private fields */ }
Expand description

Trapezoidal motion profile

Generates an approximation of a trapezoidal ramp, following the algorithm laid out here: http://hwml.com/LeibRamp.htm

A PDF version of that page is available: http://hwml.com/LeibRamp.pdf

This implementation makes the following simplifications:

  • The unit of time used is left to the user (see “Unit of Time” below), so the frequency variable F is ignored.
  • The initial velocity v0 is assumed to be zero, meaning you can’t construct an instance of this struct to take over an ongoing movement.

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

Acceleration Ramp

This struct will generate a trapezoidal acceleration ramp with the following attributes:

  • The velocity will always be equal to or less than the maximum velocity passed to the constructor.
  • While ramping up or down, the acceleration will be an approximation of the target acceleration passed to the constructor.

Unit of Time

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

This allows you to pass the parameters 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 acceleration, maximum velocity, and delays per step. It is set to a 64-bit fixed-point number type by default.

You can override the default with f32, f64, or any other type from the fixed crate. Please note that this code uses a very naive approach regarding its use of numeric types, which does not play well lower-accuracy fixed-point types. Please be very careful when using any other other type than the default or a floating-point type. The code might not even generate a proper trapezoidal ramp, if accuracy is too low!

Please note that you need to enable support for f32/f64 explicitly. Check out the section on Cargo features from the documentation in the root module for more information.

Implementations

Create a new instance of Trapezoidal

Accepts the target acceleration in steps per (unit of time)^2 as an argument. It must not be zero. See the struct documentation for information about units of time.

Panics

Panics, if target_accel is zero.

Trait Implementations

The type used for representing velocities

The type used for representing delay values

Enter position mode Read more

Return the next step delay Read more

Return an iterator over delay values of each step Read more

Return an iterator over velocity values of each step Read more

Return an iterator over the acceleration values between steps Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Casts the value.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Casts the value.

Casts the value.

Casts the value.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Performs the conversion.

Performs the conversion.

Casts the value.

Casts the value.

Should always be Self

Casts the value.

Casts the value.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Casts the value.

Casts the value.

Casts the value.

Casts the value.