Robot Core Documentation
Loading...
Searching...
No Matches
edu.wpi.first.math.trajectory.TrapezoidProfile Class Reference

Public Member Functions

 TrapezoidProfile (Constraints constraints)
 
 TrapezoidProfile (Constraints constraints, State goal, State initial)
 
 TrapezoidProfile (Constraints constraints, State goal)
 
State calculate (double t)
 
State calculate (double t, State current, State goal)
 
double timeLeftUntil (double target)
 
double totalTime ()
 
boolean isFinished (double t)
 

Detailed Description

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);
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().

Constructor & Destructor Documentation

◆ TrapezoidProfile() [1/3]

edu.wpi.first.math.trajectory.TrapezoidProfile.TrapezoidProfile ( Constraints constraints)

Constructs a TrapezoidProfile.

Parameters
constraintsThe constraints on the profile, like maximum velocity.

◆ TrapezoidProfile() [2/3]

edu.wpi.first.math.trajectory.TrapezoidProfile.TrapezoidProfile ( Constraints constraints,
State goal,
State initial )

Constructs a TrapezoidProfile.

Parameters
constraintsThe constraints on the profile, like maximum velocity.
goalThe desired state when the profile is complete.
initialThe initial state (usually the current state).
Deprecated
Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current state

◆ TrapezoidProfile() [3/3]

edu.wpi.first.math.trajectory.TrapezoidProfile.TrapezoidProfile ( Constraints constraints,
State goal )

Constructs a TrapezoidProfile.

Parameters
constraintsThe constraints on the profile, like maximum velocity.
goalThe desired state when the profile is complete.
Deprecated
Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current state

Member Function Documentation

◆ calculate() [1/2]

State edu.wpi.first.math.trajectory.TrapezoidProfile.calculate ( double t)

Calculates the position and velocity for the profile at a time t where the current state is at time t = 0.

Parameters
tHow long to advance from the current state toward the desired state.
Returns
The position and velocity of the profile at time t.
Deprecated
Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current state

◆ calculate() [2/2]

State edu.wpi.first.math.trajectory.TrapezoidProfile.calculate ( double t,
State current,
State goal )

Calculates the position and velocity for the profile at a time t where the current state is at time t = 0.

Parameters
tHow long to advance from the current state toward the desired state.
currentThe current state.
goalThe desired state when the profile is complete.
Returns
The position and velocity of the profile at time t.

◆ isFinished()

boolean edu.wpi.first.math.trajectory.TrapezoidProfile.isFinished ( double t)

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
tThe time since the beginning of the profile.
Returns
True if the profile has reached the goal.

◆ timeLeftUntil()

double edu.wpi.first.math.trajectory.TrapezoidProfile.timeLeftUntil ( double target)

Returns the time left until a target distance in the profile is reached.

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

◆ totalTime()

double edu.wpi.first.math.trajectory.TrapezoidProfile.totalTime ( )

Returns the total time the profile takes to reach the goal.

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

The documentation for this class was generated from the following file: