Package edu.wpi.first.math.trajectory
Class TrapezoidProfile
java.lang.Object
edu.wpi.first.math.trajectory.TrapezoidProfile
public class TrapezoidProfile extends Object
A trapezoidshaped 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);
TrapezoidProfile profile = new TrapezoidProfile(constraints);
Run on update:
previousProfiledReference =
profile.calculate(timeSincePreviousUpdate, previousProfiledReference, unprofiledReference);
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()`.

Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TrapezoidProfile.Constraints
static class
TrapezoidProfile.State

Constructor Summary
Constructors Constructor Description TrapezoidProfile(TrapezoidProfile.Constraints constraints)
Construct a TrapezoidProfile.TrapezoidProfile(TrapezoidProfile.Constraints constraints, TrapezoidProfile.State goal)
Deprecated, for removal: This API element is subject to removal in a future version.Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current stateTrapezoidProfile(TrapezoidProfile.Constraints constraints, TrapezoidProfile.State goal, TrapezoidProfile.State initial)
Deprecated, for removal: This API element is subject to removal in a future version.Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current state 
Method Summary
Modifier and Type Method Description TrapezoidProfile.State
calculate(double t)
Deprecated, for removal: This API element is subject to removal in a future version.Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current stateTrapezoidProfile.State
calculate(double t, TrapezoidProfile.State current, TrapezoidProfile.State goal)
Calculate the correct position and velocity for the profile at a time t where the beginning of the profile was at time t = 0.boolean
isFinished(double t)
Returns true if the profile has reached the goal.double
timeLeftUntil(double target)
Returns the time left until a target distance in the profile is reached.double
totalTime()
Returns the total time the profile takes to reach the goal.

Constructor Details

TrapezoidProfile
Construct a TrapezoidProfile. Parameters:
constraints
 The constraints on the profile, like maximum velocity.

TrapezoidProfile
@Deprecated(since="2024", forRemoval=true) public TrapezoidProfile(TrapezoidProfile.Constraints constraints, TrapezoidProfile.State goal, TrapezoidProfile.State initial)Deprecated, for removal: This API element is subject to removal in a future version.Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current stateConstruct a TrapezoidProfile. Parameters:
constraints
 The constraints on the profile, like maximum velocity.goal
 The desired state when the profile is complete.initial
 The initial state (usually the current state).

TrapezoidProfile
@Deprecated(since="2024", forRemoval=true) public TrapezoidProfile(TrapezoidProfile.Constraints constraints, TrapezoidProfile.State goal)Deprecated, for removal: This API element is subject to removal in a future version.Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current stateConstruct a TrapezoidProfile. Parameters:
constraints
 The constraints on the profile, like maximum velocity.goal
 The desired state when the profile is complete.


Method Details

calculate
Deprecated, for removal: This API element is subject to removal in a future version.Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current stateCalculate the correct position and velocity for the profile at a time t where the beginning of the profile was at time t = 0. Parameters:
t
 The time since the beginning of the profile. Returns:
 The position and velocity of the profile at time t.

calculate
public TrapezoidProfile.State calculate(double t, TrapezoidProfile.State current, TrapezoidProfile.State goal)Calculate the correct position and velocity for the profile at a time t where the beginning of the profile was at time t = 0. Parameters:
t
 The time since the beginning of the profile.current
 The current state.goal
 The desired state when the profile is complete. Returns:
 The position and velocity of the profile at time t.

timeLeftUntil
Returns the time left until a target distance in the profile is reached. Parameters:
target
 The target distance. Returns:
 The time left until a target distance in the profile is reached.

totalTime
Returns the total time the profile takes to reach the goal. Returns:
 The total time the profile takes to reach the goal.

isFinished
Returns true if the profile has reached the goal.The profile has reached the goal if the time since the profile started has exceeded the profile's total time.
 Parameters:
t
 The time since the beginning of the profile. Returns:
 True if the profile has reached the goal.
