Package com.marswars.auto
Class Auto
java.lang.Object
edu.wpi.first.wpilibj2.command.Command
edu.wpi.first.wpilibj2.command.SequentialCommandGroup
com.marswars.auto.Auto
- All Implemented Interfaces:
Sendable
Base class for autonomous routines that load Choreo trajectories and expose
common path utilities.
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj2.command.Command
Command.InterruptionBehavior -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcacheTrajetories(boolean is_red_alliance) Loads all registered trajectories from Choreo and processes them for use in the auto.Pose2d[]getPath()Get the full path as an array of Pose2dGets the starting pose for the first loaded trajectory.protected Supplier<ChoreoTrajectory>getTrajectory(String name) Get a loaded trajectory by name.protected voidloadTrajectory(String name) Registers a trajectory to be part of the auto.Methods inherited from class edu.wpi.first.wpilibj2.command.SequentialCommandGroup
addCommands, end, execute, getInterruptionBehavior, initialize, initSendable, isFinished, runsWhenDisabledMethods inherited from class edu.wpi.first.wpilibj2.command.Command
addRequirements, addRequirements, alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineFor, deadlineWith, finallyDo, finallyDo, getName, getRequirements, getSubsystem, handleInterrupt, hasRequirement, ignoringDisable, isScheduled, onlyIf, onlyWhile, raceWith, repeatedly, schedule, setName, setSubsystem, unless, until, withDeadline, withInterruptBehavior, withName, withTimeout, withTimeout
-
Field Details
-
trajectories_
-
-
Constructor Details
-
Auto
public Auto()Creates a new autonomous routine container with a default name.
-
-
Method Details
-
loadTrajectory
Registers a trajectory to be part of the auto. The actual trajectory will be loaded once the auto is selected, allowing for pre-caching of trajectories without loading them all at once during initialization.- Parameters:
name- The name of the trajectory to load
-
cacheTrajetories
public void cacheTrajetories(boolean is_red_alliance) Loads all registered trajectories from Choreo and processes them for use in the auto. This should be called once after the auto is selected to ensure all paths are ready before execution- Parameters:
is_red_alliance- true if the robot is on the red alliance, false for blue (used for flipping trajectories)
-
getTrajectory
Get a loaded trajectory by name.- Parameters:
name- The name of the trajectory- Returns:
- The typed Choreo trajectory
- Throws:
IllegalStateException- if the trajectory has not been loaded yet (i.e. cacheTrajectories() has not been called)
-
getStartPose
Gets the starting pose for the first loaded trajectory.- Returns:
- The first pose in the first trajectory, or
Pose2d.kZeroif none
-
getPath
Get the full path as an array of Pose2d- Returns:
- Array of Pose2d representing the path
-