WPILibC++ 2024.1.1-beta-4
frc::TrapezoidProfile< Distance > Class Template Reference

A trapezoid-shaped velocity profile. More...

#include <frc/trajectory/TrapezoidProfile.h>

## Classes

class  Constraints

class  State

## 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)
Construct a TrapezoidProfile. More...

TrapezoidProfile (Constraints constraints, State goal, State initial=State{Distance_t{0}, Velocity_t{0}})
Construct a TrapezoidProfile. More...

TrapezoidProfile (const TrapezoidProfile &)=default

TrapezoidProfileoperator= (const TrapezoidProfile &)=default

TrapezoidProfile (TrapezoidProfile &&)=default

TrapezoidProfileoperator= (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...

State Calculate (units::second_t t, State current, 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. 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...

## Detailed Description

template<class Distance>
class frc::TrapezoidProfile< Distance >

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{kMaxV, kMaxA};
double previousProfiledReference = initialReference;
TrapezoidProfile profile{constraints};
Definition: TrapezoidProfile.h:55
A trapezoid-shaped velocity profile.
Definition: TrapezoidProfile.h:45

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

## ◆ Acceleration

template<class Distance >
 using frc::TrapezoidProfile< Distance >::Acceleration = units::compound_unit >

## ◆ Acceleration_t

template<class Distance >
 using frc::TrapezoidProfile< Distance >::Acceleration_t = units::unit_t

## ◆ Distance_t

template<class Distance >
 using frc::TrapezoidProfile< Distance >::Distance_t = units::unit_t

## ◆ Velocity

template<class Distance >
 using frc::TrapezoidProfile< Distance >::Velocity = units::compound_unit >

## ◆ Velocity_t

template<class Distance >
 using frc::TrapezoidProfile< Distance >::Velocity_t = units::unit_t

## ◆ TrapezoidProfile() [1/4]

template<class Distance >
 frc::TrapezoidProfile< Distance >::TrapezoidProfile ( Constraints constraints )

Construct a TrapezoidProfile.

Parameters
 constraints The constraints on the profile, like maximum velocity.

## ◆ TrapezoidProfile() [2/4]

template<class Distance >
 frc::TrapezoidProfile< Distance >::TrapezoidProfile ( Constraints constraints, State goal, State initial = State{Distance_t{0}, Velocity_t{0}} )

Construct 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).
Deprecated:
Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current state

## ◆ TrapezoidProfile() [3/4]

template<class Distance >
 frc::TrapezoidProfile< Distance >::TrapezoidProfile ( const TrapezoidProfile< Distance > & )
default

## ◆ TrapezoidProfile() [4/4]

template<class Distance >
 frc::TrapezoidProfile< Distance >::TrapezoidProfile ( TrapezoidProfile< Distance > && )
default

## ◆ Calculate() [1/2]

template<class Distance >
 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.

Parameters
 t The time since the beginning of the profile.
Deprecated:
Pass the desired and current state into calculate instead of constructing a new TrapezoidProfile with the desired and current state

## ◆ Calculate() [2/2]

template<class Distance >
 TrapezoidProfile< Distance >::State frc::TrapezoidProfile< Distance >::Calculate ( units::second_t t, State current, 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 initial state (usually the current state). goal The desired state when the profile is complete.

## ◆ IsFinished()

template<class Distance >
 bool frc::TrapezoidProfile< Distance >::IsFinished ( units::second_t t ) const
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.

Parameters
 t The time since the beginning of the profile.

## ◆ operator=() [1/2]

template<class Distance >
 TrapezoidProfile & frc::TrapezoidProfile< Distance >::operator= ( const TrapezoidProfile< Distance > & )
default

## ◆ operator=() [2/2]

template<class Distance >
 TrapezoidProfile & frc::TrapezoidProfile< Distance >::operator= ( TrapezoidProfile< Distance > && )
default

## ◆ TimeLeftUntil()

template<class Distance >
 units::second_t frc::TrapezoidProfile< Distance >::TimeLeftUntil ( Distance_t target ) const

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

Parameters
 target The target distance.

## ◆ TotalTime()

template<class Distance >
 units::second_t frc::TrapezoidProfile< Distance >::TotalTime ( ) const
inline

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

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