Class PathPlannerCommandFactory
Before autonomous starts the robot may not be sitting where the pre-planned PathPlanner auto expects. This factory creates a short alignment path on the fly that drives the robot from its current pose to the auto's expected start, then sequences the planned auto after it. All autos are pre-loaded at construction time so there is no file-parsing delay when the match starts.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new factory and pre-loads all known autos. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.wpilibj2.command.CommandcreateAutoCommand(edu.wpi.first.wpilibj.DriverStation.Alliance alliance, String autoName) Builds the full autonomous command for the given alliance using the auto name selected on the dashboard.Returns the auto name currently selected on the dashboard chooser.
-
Constructor Details
-
PathPlannerCommandFactory
public PathPlannerCommandFactory()Creates a new factory and pre-loads all known autos.Call this once during robot initialization in
RobotContainerand reuse the instance every time an autonomous command is needed.
-
-
Method Details
-
createAutoCommand
public edu.wpi.first.wpilibj2.command.Command createAutoCommand(edu.wpi.first.wpilibj.DriverStation.Alliance alliance, String autoName) Builds the full autonomous command for the given alliance using the auto name selected on the dashboard.The returned command sequences an alignment path (current pose to expected start) followed by the pre-loaded PathPlanner auto. If the auto has no recorded starting pose the alignment step is skipped.
- Parameters:
alliance- alliance color used to mirror the starting pose to the correct side of the fieldautoName- name of the auto to run, matching a key in the cache- Returns:
- composite command that first aligns then runs the auto
-
getSelectedAutoName
Returns the auto name currently selected on the dashboard chooser.Falls back to
"b1"if the chooser has not been initialized or returns null.- Returns:
- selected auto name
-