Class HolonomicTrajectory
java.lang.Object
org.wpilib.math.trajectory.Trajectory<HolonomicSample>
org.wpilib.math.trajectory.HolonomicTrajectory
A base trajectory class for general-purpose trajectory following.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HolonomicTrajectoryProtoBase proto for serialization.Fields inherited from class Trajectory
duration, samples -
Constructor Summary
ConstructorsConstructorDescriptionHolonomicTrajectory(List<HolonomicSample> samples) Constructs a HolonomicTrajectory.HolonomicTrajectory(HolonomicSample[] samples) Constructs a HolonomicTrajectory. -
Method Summary
Modifier and TypeMethodDescriptionconcatenate(Trajectory<HolonomicSample> other) Concatenates this trajectory with another trajectory.interpolate(HolonomicSample start, HolonomicSample end, double t) Interpolates between two samples using constant-acceleration kinematic equations.static HolonomicTrajectoryloadFromFile(File file) Loads a trajectory from a JSON file.static HolonomicTrajectoryloadFromFile(String filename) Loads a trajectory from a JSON file.static HolonomicTrajectoryloadFromStream(InputStream stream) Loads a trajectory from a JSON stream.relativeTo(Pose2d other) Returns a new trajectory that is relative to the given pose.transformBy(Transform2d transform) Transforms all poses in the trajectory by the given transform.Methods inherited from class Trajectory
end, getSamples, sampleAt, sampleAt, start
-
Field Details
-
proto
Base proto for serialization.
-
-
Constructor Details
-
HolonomicTrajectory
Constructs a HolonomicTrajectory.- Parameters:
samples- the samples of the trajectory. Order does not matter as they will be ordered internally.
-
HolonomicTrajectory
Constructs a HolonomicTrajectory.- Parameters:
samples- the samples of the trajectory. Order does not matter as they will be ordered internally.
-
-
Method Details
-
interpolate
Interpolates between two samples using constant-acceleration kinematic equations.- Specified by:
interpolatein classTrajectory<HolonomicSample>- Parameters:
start- The starting sample.end- The ending sample.t- The interpolation parameter between 0 and 1.- Returns:
- The interpolated sample.
-
transformBy
Transforms all poses in the trajectory by the given transform.- Specified by:
transformByin classTrajectory<HolonomicSample>- Parameters:
transform- The transform to apply to the trajectory.- Returns:
- The transformed trajectory.
-
concatenate
Concatenates this trajectory with another trajectory.- Specified by:
concatenatein classTrajectory<HolonomicSample>- Parameters:
other- the other trajectory to concatenate with this one.- Returns:
- a new trajectory that is the concatenation of this trajectory and the other trajectory.
-
relativeTo
Returns a new trajectory that is relative to the given pose.- Specified by:
relativeToin classTrajectory<HolonomicSample>- Parameters:
other- the pose to which the trajectory should be relative.- Returns:
- a new trajectory relative to the given pose.
-
loadFromStream
Loads a trajectory from a JSON stream.- Parameters:
stream- the stream to read from- Returns:
- the deserialized trajectory
- Throws:
IOException- if there's an error reading the file or parsing the JSON
-
loadFromFile
Loads a trajectory from a JSON file.- Parameters:
file- the file to read from- Returns:
- the deserialized trajectory
- Throws:
IOException- if there's an error reading the file or parsing the JSON
-
loadFromFile
Loads a trajectory from a JSON file.- Parameters:
filename- the path to the file to read from- Returns:
- the deserialized trajectory
- Throws:
IOException- if there's an error reading the file or parsing the JSON
-