|
WPILibC++
2020.3.2
|
A trapezoid-shaped velocity profile. More...
#include <TrapezoidProfile.h>
Classes | |
| class | Constraints |
| class | State |
Public Member Functions | |
| TrapezoidProfile (Constraints constraints, State goal, State initial=State{Distance_t(0), Velocity_t(0)}) | |
| Construct a TrapezoidProfile. More... | |
| TrapezoidProfile (const TrapezoidProfile &)=default | |
| TrapezoidProfile & | operator= (const TrapezoidProfile &)=default |
| TrapezoidProfile (TrapezoidProfile &&)=default | |
| TrapezoidProfile & | operator= (TrapezoidProfile &&)=default |
| State | Calculate (units::second_t t) const |
| Calculate the correct position and velocity for the profile at a time t where the beginning of the profile was at time t = 0. More... | |
| units::second_t | TimeLeftUntil (Distance_t target) const |
| Returns the time left until a target distance in the profile is reached. More... | |
| units::second_t | TotalTime () const |
| Returns the total time the profile takes to reach the goal. | |
| bool | IsFinished (units::second_t t) const |
| Returns true if the profile has reached the goal. More... | |
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:
Run on update:
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().
| frc::TrapezoidProfile< Distance >::TrapezoidProfile | ( | Constraints | constraints, |
| State | goal, | ||
| State | initial = State{Distance_t(0), Velocity_t(0)} |
||
| ) |
Construct a TrapezoidProfile.
| 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< Distance >::State frc::TrapezoidProfile< Distance >::Calculate | ( | units::second_t | t | ) | const |
Calculate the correct position and velocity for the profile at a time t where the beginning of the profile was at time t = 0.
| t | The time since the beginning of the profile. |
|
inline |
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.
| t | The time since the beginning of the profile. |
| units::second_t frc::TrapezoidProfile< Distance >::TimeLeftUntil | ( | Distance_t | target | ) | const |
Returns the time left until a target distance in the profile is reached.
| target | The target distance. |