Package choreo
Class Choreo
java.lang.Object
choreo.Choreo
Utilities to load and follow Choreo Trajectories
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A utility for caching loaded trajectories.static interface
This interface exists as a type alias. -
Method Summary
Modifier and TypeMethodDescriptionstatic <SampleType extends TrajectorySample<SampleType>>
AutoFactorycreateAutoFactory
(Supplier<Pose2d> poseSupplier, BiConsumer<Pose2d, SampleType> controller, BooleanSupplier mirrorTrajectory, Subsystem driveSubsystem, AutoFactory.AutoBindings bindings) Create a factory that can be used to createAutoRoutine
andAutoTrajectory
.static <SampleType extends TrajectorySample<SampleType>>
AutoFactorycreateAutoFactory
(Supplier<Pose2d> poseSupplier, BiConsumer<Pose2d, SampleType> controller, BooleanSupplier mirrorTrajectory, Subsystem driveSubsystem, AutoFactory.AutoBindings bindings, Choreo.TrajectoryLogger<SampleType> trajectoryLogger) Create a factory that can be used to createAutoRoutine
andAutoTrajectory
.static ProjectFile
Gets the project file from the deploy directory.static <SampleType extends TrajectorySample<SampleType>>
Optional<Trajectory<SampleType>>loadTrajectory
(String trajectoryName) Load a trajectory from the deploy directory.
-
Method Details
-
getProjectFile
Gets the project file from the deploy directory. Choreolib expects a .chor file to be placed in src/main/deploy/choreo.The result is cached after the first call.
- Returns:
- the project file
-
loadTrajectory
public static <SampleType extends TrajectorySample<SampleType>> Optional<Trajectory<SampleType>> loadTrajectory(String trajectoryName) Load a trajectory from the deploy directory. Choreolib expects .traj files to be placed in src/main/deploy/choreo/[trajectoryName].traj.- Type Parameters:
SampleType
- The type of samples in the trajectory.- 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.
-
createAutoFactory
public static <SampleType extends TrajectorySample<SampleType>> AutoFactory createAutoFactory(Supplier<Pose2d> poseSupplier, BiConsumer<Pose2d, SampleType> controller, BooleanSupplier mirrorTrajectory, Subsystem driveSubsystem, AutoFactory.AutoBindings bindings) Create a factory that can be used to createAutoRoutine
andAutoTrajectory
.- Type Parameters:
SampleType
- The type of samples in the trajectory.- Parameters:
poseSupplier
- A function that returns the current field-relativePose2d
of the robot.controller
- ABiConsumer
to follow the currentTrajectory
<Choreo
>.mirrorTrajectory
- If this returns true, the path will be mirrored to the opposite side, while keeping the same coordinate system origin. This will be called every loop during the command.driveSubsystem
- The driveSubsystem
to require forAutoTrajectory
Command
s.bindings
- Universal trajectory event bindings.- Returns:
- An
AutoFactory
that can be used to createAutoRoutine
andAutoTrajectory
. - See Also:
-
createAutoFactory
public static <SampleType extends TrajectorySample<SampleType>> AutoFactory createAutoFactory(Supplier<Pose2d> poseSupplier, BiConsumer<Pose2d, SampleType> controller, BooleanSupplier mirrorTrajectory, Subsystem driveSubsystem, AutoFactory.AutoBindings bindings, Choreo.TrajectoryLogger<SampleType> trajectoryLogger) Create a factory that can be used to createAutoRoutine
andAutoTrajectory
.- Type Parameters:
SampleType
- The type of samples in the trajectory.- Parameters:
poseSupplier
- A function that returns the current field-relativePose2d
of the robot.controller
- ABiConsumer
to follow the currentTrajectory
<Choreo
>.mirrorTrajectory
- If this returns true, the path will be mirrored to the opposite side, while keeping the same coordinate system origin. This will be called every loop during the command.driveSubsystem
- The driveSubsystem
to require forAutoTrajectory
Command
s.bindings
- Universal trajectory event bindings.trajectoryLogger
- AChoreo.TrajectoryLogger
to logTrajectory
as they start and finish.- Returns:
- An
AutoFactory
that can be used to createAutoRoutine
andAutoTrajectory
. - See Also:
-