Package choreo.trajectory
Class Trajectory<SampleType extends TrajectorySample<SampleType>>
java.lang.Object
choreo.trajectory.Trajectory<SampleType>
- Type Parameters:
SampleType
- DifferentialSample or SwerveSample.
A trajectory loaded from Choreo.
-
Constructor Summary
ConstructorDescriptionTrajectory
(String name, List<SampleType> samples, List<Integer> splits, List<EventMarker> events) Constructs a Trajectory with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionboolean
events()
Returns the events in the trajectory.flipped()
Returns this trajectory, mirrored across the field midline.Returns a list of all events with the given name in the trajectory.getFinalPose
(boolean mirrorForRedAlliance) Returns the final pose of the trajectory.getFinalSample
(boolean mirrorForRedAlliance) Returns the lastTrajectory
in the trajectory.getInitialPose
(boolean mirrorForRedAlliance) Returns the initial pose of the trajectory.getInitialSample
(boolean mirrorForRedAlliance) Returns the firstTrajectory
in the trajectory.Pose2d[]
getPoses()
Returns the array of poses corresponding to the trajectory.getSplit
(int splitIndex) Returns a choreo trajectory that represents the split of the trajectory at the given index.double
Returns the total time of the trajectory (the timestamp of the last sample)name()
Returns the name of the trajectory.Returns an array of samplessampleAt
(double timestamp, boolean mirrorForRedAlliance) Return an interpolated sample of the trajectory at the given timestamp.samples()
Returns the samples of the trajectory.splits()
Returns the indices of the splits in the trajectory.
-
Constructor Details
-
Trajectory
public Trajectory(String name, List<SampleType> samples, List<Integer> splits, List<EventMarker> events) Constructs a Trajectory with the specified parameters.- Parameters:
name
- The name of the trajectory.samples
- The samples of the trajectory.splits
- The indices of the splits in the trajectory.events
- The events in the trajectory.
-
-
Method Details
-
name
Returns the name of the trajectory.- Returns:
- the name of the trajectory.
-
samples
Returns the samples of the trajectory.- Returns:
- the samples of the trajectory.
-
splits
Returns the indices of the splits in the trajectory.- Returns:
- the indices of the splits in the trajectory.
-
events
Returns the events in the trajectory.- Returns:
- the events in the trajectory.
-
getInitialSample
Returns the firstTrajectory
in the trajectory.NULL SAFETY: This function will return null if the trajectory is empty.
- Parameters:
mirrorForRedAlliance
- whether or not to return the sample as mirrored across the field- Returns:
- The first
Trajectory
in the trajectory.
-
getFinalSample
Returns the lastTrajectory
in the trajectory.NULL SAFETY: This function will return null if the trajectory is empty.
- Parameters:
mirrorForRedAlliance
- whether or not to return the sample as mirrored across the field- Returns:
- The last
Trajectory
in the trajectory.
-
sampleAt
Return an interpolated sample of the trajectory at the given timestamp.NULL SAFETY: This function will return null if the trajectory is empty.
- 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 SampleType at the given time.
-
getInitialPose
Returns the initial pose of the trajectory.NULL SAFETY: This function will return null if the trajectory is empty.
- Parameters:
mirrorForRedAlliance
- whether or not to return the pose as mirrored across the field- Returns:
- the initial pose of the trajectory.
-
getFinalPose
Returns the final pose of the trajectory.NULL SAFETY: This function will return null if the trajectory is empty.
- Parameters:
mirrorForRedAlliance
- whether or not to return the pose as mirrored across the field- Returns:
- the final pose of the trajectory.
-
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
Returns the array of poses corresponding to the trajectory.- Returns:
- the array of poses corresponding to the trajectory.
-
sampleArray
Returns an array of samples- Returns:
- an array of samples
-
flipped
Returns this trajectory, mirrored across the field midline.- Returns:
- this trajectory, mirrored across the field midline.
-
getEvents
Returns a list of all events with the given name in the trajectory.- Parameters:
eventName
- The name of the event.- Returns:
- A list of all events with the given name in the trajectory, if no events are found, an empty list is returned.
-
getSplit
Returns a choreo trajectory that represents the split of the trajectory at the given index.- Parameters:
splitIndex
- the index of the split trajectory to return.- Returns:
- a choreo trajectory that represents the split of the trajectory at the given index.
-
equals
-