Package choreo
Class Choreo.TrajectoryCache
java.lang.Object
choreo.Choreo.TrajectoryCache
- Enclosing class:
- Choreo
A utility for caching loaded trajectories. This allows for loading trajectories only once, and
then reusing them.
-
Constructor Summary
ConstructorDescriptionCreates a new TrajectoryCache with a normalHashMap
as the cache.TrajectoryCache
(Map<String, Trajectory<?>> cache) Creates a new TrajectoryCache with a custom cache. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the cache.Optional<? extends Trajectory<?>>
loadTrajectory
(String trajectoryName) Load a trajectory from the deploy directory.Optional<? extends Trajectory<?>>
loadTrajectory
(String trajectoryName, int splitIndex) Load a section of a split trajectory from the deploy directory.
-
Constructor Details
-
TrajectoryCache
public TrajectoryCache()Creates a new TrajectoryCache with a normalHashMap
as the cache. -
TrajectoryCache
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
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
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
Clear the cache.
-