![]() |
WPILibC++ 2025.3.2
|
A trapezoid-shaped velocity profile. More...
#include <frc/trajectory/TrapezoidProfile.h>
Classes | |
| class | Constraints |
| Profile constraints. More... | |
| class | State |
| Profile state. More... | |
Public Types | |
| using | Distance_t = units::unit_t<Distance> |
| using | Velocity |
| using | Velocity_t = units::unit_t<Velocity> |
| using | Acceleration |
| using | Acceleration_t = units::unit_t<Acceleration> |
Public Member Functions | |
| constexpr | TrapezoidProfile (Constraints constraints) |
| Constructs a TrapezoidProfile. | |
| constexpr | TrapezoidProfile (const TrapezoidProfile &)=default |
| constexpr TrapezoidProfile & | operator= (const TrapezoidProfile &)=default |
| constexpr | TrapezoidProfile (TrapezoidProfile &&)=default |
| constexpr TrapezoidProfile & | operator= (TrapezoidProfile &&)=default |
| constexpr State | Calculate (units::second_t 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. | |
| constexpr units::second_t | TimeLeftUntil (Distance_t target) const |
| Returns the time left until a target distance in the profile is reached. | |
| constexpr units::second_t | TotalTime () const |
| Returns the total time the profile takes to reach the goal. | |
| constexpr bool | IsFinished (units::second_t t) const |
| Returns true if the profile has reached the goal. | |
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().
| using frc::TrapezoidProfile< Distance >::Acceleration |
| using frc::TrapezoidProfile< Distance >::Acceleration_t = units::unit_t<Acceleration> |
| using frc::TrapezoidProfile< Distance >::Distance_t = units::unit_t<Distance> |
| using frc::TrapezoidProfile< Distance >::Velocity |
| using frc::TrapezoidProfile< Distance >::Velocity_t = units::unit_t<Velocity> |
|
inlineconstexpr |
Constructs a TrapezoidProfile.
| constraints | The constraints on the profile, like maximum velocity. |
|
constexprdefault |
|
constexprdefault |
|
inlineconstexpr |
Calculates the position and velocity for the profile at a time t where the current state is at time t = 0.
| t | How long to advance from the current state toward the desired state. |
| current | The current state. |
| goal | The desired state when the profile is complete. |
|
inlineconstexpr |
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. |
|
constexprdefault |
|
constexprdefault |
|
inlineconstexpr |
Returns the time left until a target distance in the profile is reached.
| target | The target distance. |
|
inlineconstexpr |
Returns the total time the profile takes to reach the goal.