Class DriveBaseSubsystemCommandFactory
java.lang.Object
frc.robot.shared.commands.AbstractSubsystemCommandFactory<DriveBaseSubsystem>
frc.robot.subsystems.drivebase.commands.DriveBaseSubsystemCommandFactory
public class DriveBaseSubsystemCommandFactory
extends AbstractSubsystemCommandFactory<DriveBaseSubsystem>
Factory that creates drive base commands and wires default behaviors.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intModule index for the back-left swerve module in the YAGSL modules array.static final intModule index for the back-right swerve module in the YAGSL modules array.static final intModule index for the front-left swerve module in the YAGSL modules array.static final intModule index for the front-right swerve module in the YAGSL modules array.Fields inherited from class frc.robot.shared.commands.AbstractSubsystemCommandFactory
subsystem -
Constructor Summary
ConstructorsConstructorDescriptionCreates a factory that produces commands operating on the provided drive base subsystem. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.wpilibj2.command.CommandCreates a SysId command that exercises all four steer (angle) motors simultaneously using the configured YAGSL characterization routine.edu.wpi.first.wpilibj2.command.CommandcreateAngleSysIdCommandForModule(int moduleIndex) Creates a SysId command that exercises a single angle (steer) motor identified by module index.edu.wpi.first.wpilibj2.command.CommandcreateDpadPathfindCommand(DpadTargetConfig targetConfig, DriverControllerConfig driverConfig) Builds a command that pathfinds to a d-pad target with trench zone awareness.edu.wpi.first.wpilibj2.command.CommandCreates a SysId command that exercises all four drive motors simultaneously using the configured YAGSL characterization routine.edu.wpi.first.wpilibj2.command.CommandcreateDriveSysIdCommandForModule(int moduleIndex) Creates a SysId command that exercises a single drive motor identified by module index.edu.wpi.first.wpilibj2.command.CommandcreateSnapToFieldFacingCommand(Supplier<Double> forwardAxis, Supplier<Double> leftAxis) Creates a command that snaps the robot to the nearest field-facing orientation (0 degrees or 180 degrees field-relative).edu.wpi.first.wpilibj2.command.CommandcreateSpin180Command(Supplier<Double> forwardAxis, Supplier<Double> leftAxis) Creates a command that spins the robot 180 degrees from its heading at the moment the button is pressed.edu.wpi.first.wpilibj2.command.CommandsetDefaultManualDriveCommand(Supplier<Double> forwardAxis, Supplier<Double> leftAxis, Supplier<Double> omegaAxis) Builds and sets the default manual drive command using a driver controller.Methods inherited from class frc.robot.shared.commands.AbstractSubsystemCommandFactory
getSubsystem
-
Field Details
-
MODULE_FRONT_LEFT
public static final int MODULE_FRONT_LEFTModule index for the front-left swerve module in the YAGSL modules array.- See Also:
-
MODULE_FRONT_RIGHT
public static final int MODULE_FRONT_RIGHTModule index for the front-right swerve module in the YAGSL modules array.- See Also:
-
MODULE_BACK_LEFT
public static final int MODULE_BACK_LEFTModule index for the back-left swerve module in the YAGSL modules array.- See Also:
-
MODULE_BACK_RIGHT
public static final int MODULE_BACK_RIGHTModule index for the back-right swerve module in the YAGSL modules array.- See Also:
-
-
Constructor Details
-
DriveBaseSubsystemCommandFactory
Creates a factory that produces commands operating on the provided drive base subsystem.- Parameters:
subsystem- drive base subsystem instance to be shared by generated commands
-
-
Method Details
-
setDefaultManualDriveCommand
public edu.wpi.first.wpilibj2.command.Command setDefaultManualDriveCommand(Supplier<Double> forwardAxis, Supplier<Double> leftAxis, Supplier<Double> omegaAxis) Builds and sets the default manual drive command using a driver controller.- Parameters:
forwardAxis- supplier providing forward stick valueleftAxis- supplier providing left stick valueomegaAxis- supplier providing rotation stick value- Returns:
- command that is also set as the subsystem's default
-
createDriveSysIdCommand
public edu.wpi.first.wpilibj2.command.Command createDriveSysIdCommand()Creates a SysId command that exercises all four drive motors simultaneously using the configured YAGSL characterization routine. Timing is read from the drivebase SysId config.- Returns:
- command suitable for binding to a dashboard/button for on-robot testing
-
createAngleSysIdCommand
public edu.wpi.first.wpilibj2.command.Command createAngleSysIdCommand()Creates a SysId command that exercises all four steer (angle) motors simultaneously using the configured YAGSL characterization routine. Timing is read from the drivebase SysId config.- Returns:
- command suitable for binding to a dashboard/button for on-robot testing
-
createDriveSysIdCommandForModule
public edu.wpi.first.wpilibj2.command.Command createDriveSysIdCommandForModule(int moduleIndex) Creates a SysId command that exercises a single drive motor identified by module index. All other drive motors are held at zero voltage. The module is centered (angle set to 0 degrees) before the test begins.Use the
MODULE_FRONT_LEFT,MODULE_FRONT_RIGHT,MODULE_BACK_LEFT, andMODULE_BACK_RIGHTconstants for the module index.- Parameters:
moduleIndex- index of the swerve module (0 = front-left, 1 = front-right, 2 = back-left, 3 = back-right)- Returns:
- command that runs a full SysId sweep on the specified drive motor
-
createAngleSysIdCommandForModule
public edu.wpi.first.wpilibj2.command.Command createAngleSysIdCommandForModule(int moduleIndex) Creates a SysId command that exercises a single angle (steer) motor identified by module index. All other angle motors are held at zero voltage and all drive motors are held at zero. This isolates the angular response of a single module for characterization.Use the
MODULE_FRONT_LEFT,MODULE_FRONT_RIGHT,MODULE_BACK_LEFT, andMODULE_BACK_RIGHTconstants for the module index.- Parameters:
moduleIndex- index of the swerve module (0 = front-left, 1 = front-right, 2 = back-left, 3 = back-right)- Returns:
- command that runs a full SysId sweep on the specified angle motor
-
createSpin180Command
public edu.wpi.first.wpilibj2.command.Command createSpin180Command(Supplier<Double> forwardAxis, Supplier<Double> leftAxis) Creates a command that spins the robot 180 degrees from its heading at the moment the button is pressed. The target heading is captured once via deferred proxy and held constant while the button is held. The driver retains full translation control during the spin.- Parameters:
forwardAxis- supplier providing the shaped forward stick value ([-1, 1])leftAxis- supplier providing the shaped left stick value ([-1, 1])- Returns:
- deferred command that captures the current heading, adds 180 degrees, and locks onto it
-
createSnapToFieldFacingCommand
public edu.wpi.first.wpilibj2.command.Command createSnapToFieldFacingCommand(Supplier<Double> forwardAxis, Supplier<Double> leftAxis) Creates a command that snaps the robot to the nearest field-facing orientation (0 degrees or 180 degrees field-relative). If the robot is already within the configured rotation tolerance of the nearest orientation, the command picks the opposite one instead. The target is captured once when the button is pressed and held constant while held.Field-facing means aligned with the field's X axis: 0 degrees faces the red alliance wall, 180 degrees faces the blue alliance wall.
- Parameters:
forwardAxis- supplier providing the shaped forward stick value ([-1, 1])leftAxis- supplier providing the shaped left stick value ([-1, 1])- Returns:
- deferred command that snaps to the nearest (or opposite) field-facing heading
-