Trapezoid Profile
A trapezoid-shaped velocity profile.
While this class can be used for a profiled movement from start to finish, the intended usage is to filter a reference's dynamics based on trapezoidal velocity constraints. To compute the reference obeying this constraint, do the following.
Initialization:
TrapezoidProfile.Constraints constraints =
new TrapezoidProfile.Constraints(kMaxV, kMaxA);
TrapezoidProfile.State previousProfiledReference =
new TrapezoidProfile.State(initialReference, 0.0);
Content copied to clipboard
Run on update:
TrapezoidProfile profile =
new TrapezoidProfile(constraints, unprofiledReference, previousProfiledReference);
previousProfiledReference = profile.calculate(timeSincePreviousUpdate);
Content copied to clipboard
where `unprofiledReference` is free to change between calls. Note that when the unprofiled reference is within the constraints, `calculate()` returns the unprofiled reference unchanged.
Otherwise, a timer can be started to provide monotonic values for `calculate()` and to determine when the profile has completed via `isFinished()`. Source
Since
3.5.0
Constructors
Link copied to clipboard
constructor(@NonNull constraints: TrapezoidProfile.Constraints, @NonNull goal: TrapezoidProfile.State, @NonNull initial: TrapezoidProfile.State)
Construct a TrapezoidProfile.
constructor(@NonNull constraints: TrapezoidProfile.Constraints, @NonNull goal: TrapezoidProfile.State)
Construct a TrapezoidProfile.
Functions
Link copied to clipboard
Calculate the correct position and velocity for the profile at a time t where the beginning of the profile was at time t = 0.
Link copied to clipboard
Returns true if the profile has reached the goal.
Link copied to clipboard
Returns the time left until a target distance in the profile is reached.