WPILibC++ 2024.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 = units::compound_unit< Distance, units::inverse< units::seconds > > |
using | Velocity_t = units::unit_t< Velocity > |
using | Acceleration = units::compound_unit< Velocity, units::inverse< units::seconds > > |
using | Acceleration_t = units::unit_t< Acceleration > |
Public Member Functions | |
TrapezoidProfile (Constraints constraints) | |
Constructs a TrapezoidProfile. More... | |
TrapezoidProfile (Constraints constraints, State goal, State initial=State{Distance_t{0}, Velocity_t{0}}) | |
Constructs 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 |
Calculates the position and velocity for the profile at a time t where the current state is at time t = 0. More... | |
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. 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. More... | |
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()
.
using frc::TrapezoidProfile< Distance >::Acceleration = units::compound_unit<Velocity, units::inverse<units::seconds> > |
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 = units::compound_unit<Distance, units::inverse<units::seconds> > |
using frc::TrapezoidProfile< Distance >::Velocity_t = units::unit_t<Velocity> |
frc::TrapezoidProfile< Distance >::TrapezoidProfile | ( | Constraints | constraints | ) |
Constructs a TrapezoidProfile.
constraints | The constraints on the profile, like maximum velocity. |
frc::TrapezoidProfile< Distance >::TrapezoidProfile | ( | Constraints | constraints, |
State | goal, | ||
State | initial = State{Distance_t{0}, Velocity_t{0}} |
||
) |
Constructs 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). |
|
default |
|
default |
TrapezoidProfile< Distance >::State frc::TrapezoidProfile< Distance >::Calculate | ( | units::second_t | t | ) | const |
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. |
TrapezoidProfile< Distance >::State frc::TrapezoidProfile< Distance >::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.
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. |
|
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. |
|
default |
|
default |
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. |
|
inline |
Returns the total time the profile takes to reach the goal.