ChoreoLib
Choreo support library.
Loading...
Searching...
No Matches
choreo::Trajectory< SampleType > Class Template Reference

#include <choreo/trajectory/Trajectory.h>

Public Member Functions

 Trajectory ()=default
 
 Trajectory (std::string_view name, std::vector< SampleType > samples, std::vector< int > splits, std::vector< EventMarker > events)
 
std::optional< SampleType > GetInitialSample (bool mirrorForRedAlliance=false) const
 
std::optional< SampleType > GetFinalSample (bool mirrorForRedAlliance=false) const
 
template<int Year = util::kDefaultYear>
std::optional< SampleType > SampleAt (units::second_t timestamp, bool mirrorForRedAlliance=false) const
 
template<int Year = util::kDefaultYear>
std::optional< frc::Pose2d > GetInitialPose (bool mirrorForRedAlliance=false) const
 
template<int Year = util::kDefaultYear>
std::optional< frc::Pose2d > GetFinalPose (bool mirrorForRedAlliance=false) const
 
units::second_t GetTotalTime () const
 
std::vector< frc::Pose2d > GetPoses () const
 
template<int Year = util::kDefaultYear>
Trajectory< SampleType > Flipped () const
 
std::vector< EventMarkerGetEvents (std::string_view eventName) const
 
std::optional< Trajectory< SampleType > > GetSplit (int splitIndex) const
 
bool operator== (const Trajectory< SampleType > &other) const
 

Public Attributes

std::string name
 The name of the trajectory.
 
std::vector< SampleType > samples
 The vector of samples in the trajectory.
 
std::vector< int > splits
 The waypoints indexes where the trajectory is split.
 
std::vector< EventMarkerevents
 A vector of all of the events in the trajectory.
 

Detailed Description

template<TrajectorySample SampleType>
class choreo::Trajectory< SampleType >

A trajectory loaded from Choreo.

Parameters
<SampleType>DifferentialSample or SwerveSample.

Constructor & Destructor Documentation

◆ Trajectory() [1/2]

template<TrajectorySample SampleType>
choreo::Trajectory< SampleType >::Trajectory ( )
default

Constructs a Trajectory with defaults

◆ Trajectory() [2/2]

template<TrajectorySample SampleType>
choreo::Trajectory< SampleType >::Trajectory ( std::string_view  name,
std::vector< SampleType >  samples,
std::vector< int >  splits,
std::vector< EventMarker events 
)
inline

Constructs a Trajectory with the specified parameters.

Parameters
nameThe name of the trajectory.
samplesThe samples of the trajectory.
splitsThe indices of the splits in the trajectory.
eventsThe events in the trajectory.

Member Function Documentation

◆ Flipped()

template<TrajectorySample SampleType>
template<int Year = util::kDefaultYear>
Trajectory< SampleType > choreo::Trajectory< SampleType >::Flipped ( ) const
inline

Returns this trajectory, mirrored across the field midline.

Template Parameters
YearThe field year. Defaults to the current year.
Returns
this trajectory, mirrored across the field midline.

◆ GetEvents()

template<TrajectorySample SampleType>
std::vector< EventMarker > choreo::Trajectory< SampleType >::GetEvents ( std::string_view  eventName) const
inline

Returns a vector of all events with the given name in the trajectory.

Parameters
eventNameThe name of the event.
Returns
A vector of all events with the given name in the trajectory, if no events are found, an empty vector is returned.

◆ GetFinalPose()

template<TrajectorySample SampleType>
template<int Year = util::kDefaultYear>
std::optional< frc::Pose2d > choreo::Trajectory< SampleType >::GetFinalPose ( bool  mirrorForRedAlliance = false) const
inline

Returns the last Pose in the trajectory.

Will return an empty optional if the trajectory is empty

Template Parameters
YearThe field year. Defaults to the current year.
Parameters
mirrorForRedAlliancewhether or not to return the Pose mirrored.
Returns
The last Pose in the trajectory.

◆ GetFinalSample()

template<TrajectorySample SampleType>
std::optional< SampleType > choreo::Trajectory< SampleType >::GetFinalSample ( bool  mirrorForRedAlliance = false) const
inline

Returns the last SampleType in the trajectory.

Will return an empty optional if the trajectory is empty

Parameters
mirrorForRedAlliancewhether or not to return the sample as mirrored across the field
Returns
The last sample in the trajectory.

◆ GetInitialPose()

template<TrajectorySample SampleType>
template<int Year = util::kDefaultYear>
std::optional< frc::Pose2d > choreo::Trajectory< SampleType >::GetInitialPose ( bool  mirrorForRedAlliance = false) const
inline

Returns the first Pose in the trajectory.

Will return an empty optional if the trajectory is empty

Template Parameters
YearThe field year. Defaults to the current year.
Parameters
mirrorForRedAlliancewhether or not to return the Pose mirrored.
Returns
The first Pose in the trajectory.

◆ GetInitialSample()

template<TrajectorySample SampleType>
std::optional< SampleType > choreo::Trajectory< SampleType >::GetInitialSample ( bool  mirrorForRedAlliance = false) const
inline

Returns the first SampleType in the trajectory.

Will return an empty optional if the trajectory is empty

Parameters
mirrorForRedAlliancewhether or not to return the sample as mirrored across the field
Returns
The first sample in the trajectory.

◆ GetPoses()

template<TrajectorySample SampleType>
std::vector< frc::Pose2d > choreo::Trajectory< SampleType >::GetPoses ( ) const
inline

Returns the vector of poses corresponding to the trajectory.

Returns
the vector of poses corresponding to the trajectory.

◆ GetSplit()

template<TrajectorySample SampleType>
std::optional< Trajectory< SampleType > > choreo::Trajectory< SampleType >::GetSplit ( int  splitIndex) const
inline

Returns a choreo trajectory that represents the split of the trajectory at the given index.

Parameters
splitIndexthe index of the split trajectory to return.
Returns
a choreo trajectory that represents the split of the trajectory at the given index.

◆ GetTotalTime()

template<TrajectorySample SampleType>
units::second_t choreo::Trajectory< SampleType >::GetTotalTime ( ) const
inline

The total time the trajectory will take to follow

Returns
The total time the trajectory will take to follow, if empty will return 0 seconds.

◆ operator==()

template<TrajectorySample SampleType>
bool choreo::Trajectory< SampleType >::operator== ( const Trajectory< SampleType > &  other) const
inline

Trajectory equality operator.

Parameters
otherThe other trajectory.
Returns
True for equality.

◆ SampleAt()

template<TrajectorySample SampleType>
template<int Year = util::kDefaultYear>
std::optional< SampleType > choreo::Trajectory< SampleType >::SampleAt ( units::second_t  timestamp,
bool  mirrorForRedAlliance = false 
) const
inline

Return an interpolated sample of the trajectory at the given timestamp.

This function will return an empty optional if the trajectory is empty.

Template Parameters
YearThe field year. Defaults to the current year.
Parameters
timestampThe timestamp of this sample relative to the beginning of the trajectory.
mirrorForRedAlliancewhether or not to return the sample mirrored.
Returns
The SampleType at the given time.

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