Package com.choreo.lib
Class ChoreoTrajectory
- java.lang.Object
-
- com.choreo.lib.ChoreoTrajectory
-
public class ChoreoTrajectory extends Object
A trajectory loaded from Choreo.
-
-
Constructor Summary
Constructors Constructor Description ChoreoTrajectory()Create an empty ChoreoTrajectory.ChoreoTrajectory(List<ChoreoTrajectoryState> samples)Constructs a new trajectory from a list of trajectory states
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChoreoTrajectoryflipped()Returns this trajectory, mirrored across the field midline.Pose2dgetFinalPose()Returns the final, non-mirrored pose of the trajectory.ChoreoTrajectoryStategetFinalState()Returns the last ChoreoTrajectoryState in the trajectory.Pose2dgetFlippedFinalPose()Returns the final, mirrored pose of the trajectory.Pose2dgetFlippedInitialPose()Returns the initial, mirrored pose of the trajectory.Pose2dgetInitialPose()Returns the initial, non-mirrored pose of the trajectory.ChoreoTrajectoryStategetInitialState()Returns the first ChoreoTrajectoryState in the trajectory.Pose2d[]getPoses()Returns the array of poses corresponding to the trajectory.List<ChoreoTrajectoryState>getSamples()Returns the list of states for this trajectory.doublegetTotalTime()Returns the total time of the trajectory (the timestamp of the last sample)ChoreoTrajectoryStatesample(double timestamp)Return an interpolated, non-mirrored sample of the trajectory at the given timestamp.ChoreoTrajectoryStatesample(double timestamp, boolean mirrorForRedAlliance)Return an interpolated sample of the trajectory at the given timestamp.
-
-
-
Constructor Detail
-
ChoreoTrajectory
public ChoreoTrajectory()
Create an empty ChoreoTrajectory.
-
ChoreoTrajectory
public ChoreoTrajectory(List<ChoreoTrajectoryState> samples)
Constructs a new trajectory from a list of trajectory states- Parameters:
samples- a vector containing a list of ChoreoTrajectoryStates
-
-
Method Detail
-
getInitialState
public ChoreoTrajectoryState getInitialState()
Returns the first ChoreoTrajectoryState in the trajectory.- Returns:
- The first ChoreoTrajectoryState in the trajectory.
-
getFinalState
public ChoreoTrajectoryState getFinalState()
Returns the last ChoreoTrajectoryState in the trajectory.- Returns:
- The last ChoreoTrajectoryState in the trajectory.
-
sample
public ChoreoTrajectoryState sample(double timestamp)
Return an interpolated, non-mirrored sample of the trajectory at the given timestamp.- Parameters:
timestamp- The timestamp of this sample relative to the beginning of the trajectory.- Returns:
- The ChoreoTrajectoryState at the given time.
-
sample
public ChoreoTrajectoryState sample(double timestamp, boolean mirrorForRedAlliance)
Return an interpolated sample of the trajectory at the given timestamp.- Parameters:
timestamp- The timestamp of this sample relative to the beginning of the trajectory.mirrorForRedAlliance- whether or not to return the sample as mirrored across the field midline (as in 2023).- Returns:
- The ChoreoTrajectoryState at the given time.
-
getSamples
public List<ChoreoTrajectoryState> getSamples()
Returns the list of states for this trajectory.- Returns:
- this trajectory's states.
-
getInitialPose
public Pose2d getInitialPose()
Returns the initial, non-mirrored pose of the trajectory.- Returns:
- the initial, non-mirrored pose of the trajectory.
-
getFlippedInitialPose
public Pose2d getFlippedInitialPose()
Returns the initial, mirrored pose of the trajectory.- Returns:
- the initial, mirrored pose of the trajectory.
-
getFinalPose
public Pose2d getFinalPose()
Returns the final, non-mirrored pose of the trajectory.- Returns:
- the final, non-mirrored pose of the trajectory.
-
getFlippedFinalPose
public Pose2d getFlippedFinalPose()
Returns the final, mirrored pose of the trajectory.- Returns:
- the final, mirrored pose of the trajectory.
-
getTotalTime
public double getTotalTime()
Returns the total time of the trajectory (the timestamp of the last sample)- Returns:
- the total time of the trajectory (the timestamp of the last sample)
-
getPoses
public Pose2d[] getPoses()
Returns the array of poses corresponding to the trajectory.- Returns:
- the array of poses corresponding to the trajectory.
-
flipped
public ChoreoTrajectory flipped()
Returns this trajectory, mirrored across the field midline.- Returns:
- this trajectory, mirrored across the field midline.
-
-