Class HolonomicTrajectory

java.lang.Object
org.wpilib.math.trajectory.Trajectory<HolonomicSample>
org.wpilib.math.trajectory.HolonomicTrajectory

public class HolonomicTrajectory extends Trajectory<HolonomicSample>
A base trajectory class for general-purpose trajectory following.
  • Field Details

  • Constructor Details

    • HolonomicTrajectory

      public HolonomicTrajectory(List<HolonomicSample> samples)
      Constructs a HolonomicTrajectory.
      Parameters:
      samples - the samples of the trajectory. Order does not matter as they will be ordered internally.
    • HolonomicTrajectory

      public HolonomicTrajectory(HolonomicSample[] samples)
      Constructs a HolonomicTrajectory.
      Parameters:
      samples - the samples of the trajectory. Order does not matter as they will be ordered internally.
  • Method Details

    • interpolate

      public HolonomicSample interpolate(HolonomicSample start, HolonomicSample end, double t)
      Interpolates between two samples using constant-acceleration kinematic equations.
      Specified by:
      interpolate in class Trajectory<HolonomicSample>
      Parameters:
      start - The starting sample.
      end - The ending sample.
      t - The interpolation parameter between 0 and 1.
      Returns:
      The interpolated sample.
    • transformBy

      public HolonomicTrajectory transformBy(Transform2d transform)
      Transforms all poses in the trajectory by the given transform.
      Specified by:
      transformBy in class Trajectory<HolonomicSample>
      Parameters:
      transform - The transform to apply to the trajectory.
      Returns:
      The transformed trajectory.
    • concatenate

      public HolonomicTrajectory concatenate(Trajectory<HolonomicSample> other)
      Concatenates this trajectory with another trajectory.
      Specified by:
      concatenate in class Trajectory<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

      public HolonomicTrajectory relativeTo(Pose2d other)
      Returns a new trajectory that is relative to the given pose.
      Specified by:
      relativeTo in class Trajectory<HolonomicSample>
      Parameters:
      other - the pose to which the trajectory should be relative.
      Returns:
      a new trajectory relative to the given pose.
    • loadFromStream

      public static HolonomicTrajectory loadFromStream(InputStream stream) throws IOException
      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

      public static HolonomicTrajectory loadFromFile(File file) throws IOException
      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

      public static HolonomicTrajectory loadFromFile(String filename) throws IOException
      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