Class DifferentialTrajectory
java.lang.Object
org.wpilib.math.trajectory.Trajectory<DifferentialSample>
org.wpilib.math.trajectory.DifferentialTrajectory
A trajectory for differential drive robots with drivetrain-specific interpolation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DifferentialTrajectoryProtoBase proto for serialization.Fields inherited from class Trajectory
duration, samples -
Constructor Summary
ConstructorsConstructorDescriptionDifferentialTrajectory(List<DifferentialSample> samples) Constructs a DifferentialTrajectory.DifferentialTrajectory(DifferentialDriveKinematics kinematics, List<? extends HolonomicSample> samples) Constructs a DifferentialTrajectory.DifferentialTrajectory(DifferentialSample[] samples) Constructs a DifferentialTrajectory. -
Method Summary
Modifier and TypeMethodDescriptionconcatenate(Trajectory<DifferentialSample> other) Concatenates this trajectory with another trajectory.interpolate(DifferentialSample start, DifferentialSample end, double t) Interpolates between two samples using numerical integration of the differential drive differential equation.static DifferentialTrajectoryloadFromFile(File file) Loads a trajectory from a JSON file.static DifferentialTrajectoryloadFromFile(String filename) Loads a trajectory from a JSON file.static DifferentialTrajectoryloadFromStream(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
-
DifferentialTrajectory
Constructs a DifferentialTrajectory.- Parameters:
samples- the samples of the trajectory. Order does not matter as they will be ordered internally.
-
DifferentialTrajectory
Constructs a DifferentialTrajectory.- Parameters:
samples- the samples of the trajectory. Order does not matter as they will be ordered internally.
-
DifferentialTrajectory
public DifferentialTrajectory(DifferentialDriveKinematics kinematics, List<? extends HolonomicSample> samples) Constructs a DifferentialTrajectory.- Parameters:
kinematics- the kinematics of the drivetrain.samples- the samples of the trajectory. Order does not matter as they will be ordered internally.
-
-
Method Details
-
interpolate
Interpolates between two samples using numerical integration of the differential drive differential equation.- Specified by:
interpolatein classTrajectory<DifferentialSample>- 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<DifferentialSample>- Parameters:
transform- The transform to apply to the trajectory.- Returns:
- The transformed trajectory.
-
concatenate
Concatenates this trajectory with another trajectory.- Specified by:
concatenatein classTrajectory<DifferentialSample>- 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<DifferentialSample>- 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
-