Package choreo

Class Choreo.TrajectoryCache

java.lang.Object
choreo.Choreo.TrajectoryCache
Enclosing class:
Choreo

public static class Choreo.TrajectoryCache extends Object
A utility for caching loaded trajectories. This allows for loading trajectories only once, and then reusing them.
  • Constructor Details

    • TrajectoryCache

      public TrajectoryCache()
      Creates a new TrajectoryCache with a normal HashMap as the cache.
    • TrajectoryCache

      public TrajectoryCache(Map<String,Trajectory<?>> cache)
      Creates a new TrajectoryCache with a custom cache.

      this could be useful if you want to use a concurrent map or a map with a maximum size.

      Parameters:
      cache - The cache to use.
  • Method Details

    • loadTrajectory

      public Optional<? extends Trajectory<?>> loadTrajectory(String trajectoryName)
      Load a trajectory from the deploy directory. Choreolib expects .traj files to be placed in src/main/deploy/choreo/[trajectoryName].traj.

      This method will cache the loaded trajectory and reused it if it is requested again.

      Parameters:
      trajectoryName - the path name in Choreo, which matches the file name in the deploy directory, file extension is optional.
      Returns:
      the loaded trajectory, or `Optional.empty()` if the trajectory could not be loaded.
      See Also:
    • loadTrajectory

      public Optional<? extends Trajectory<?>> loadTrajectory(String trajectoryName, int splitIndex)
      Load a section of a split trajectory from the deploy directory. Choreolib expects .traj files to be placed in src/main/deploy/choreo/[trajectoryName].traj.

      This method will cache the loaded trajectory and reused it if it is requested again. The trajectory that is split off of will also be cached.

      Parameters:
      trajectoryName - the path name in Choreo, which matches the file name in the deploy directory, file extension is optional.
      splitIndex - the index of the split trajectory to load
      Returns:
      the loaded trajectory, or `Optional.empty()` if the trajectory could not be loaded.
      See Also:
    • clear

      public void clear()
      Clear the cache.