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 Details

    • MODULE_FRONT_LEFT

      public static final int MODULE_FRONT_LEFT
      Module index for the front-left swerve module in the YAGSL modules array.
      See Also:
    • MODULE_FRONT_RIGHT

      public static final int MODULE_FRONT_RIGHT
      Module index for the front-right swerve module in the YAGSL modules array.
      See Also:
    • MODULE_BACK_LEFT

      public static final int MODULE_BACK_LEFT
      Module index for the back-left swerve module in the YAGSL modules array.
      See Also:
    • MODULE_BACK_RIGHT

      public static final int MODULE_BACK_RIGHT
      Module index for the back-right swerve module in the YAGSL modules array.
      See Also:
  • Constructor Details

    • DriveBaseSubsystemCommandFactory

      public DriveBaseSubsystemCommandFactory(DriveBaseSubsystem subsystem)
      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 value
      leftAxis - supplier providing left stick value
      omegaAxis - 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, and MODULE_BACK_RIGHT constants 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, and MODULE_BACK_RIGHT constants 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
    • createDpadPathfindCommand

      public edu.wpi.first.wpilibj2.command.Command createDpadPathfindCommand(DpadTargetConfig targetConfig, DriverControllerConfig driverConfig)
      Builds a command that pathfinds to a d-pad target with trench zone awareness.

      The target is stored in blue-alliance coordinates and flipped at runtime for the red alliance. When the straight-line path from the robot's current position to the target crosses a configured trench zone, intermediate waypoints are inserted at the zone entry and exit so the robot drives through the trench with the correct heading. When no trench zone is crossed, a single pathfind command drives directly to the target.

      Parameters:
      targetConfig - config holding the target pose for this d-pad direction (blue-alliance coordinates)
      driverConfig - shared driver controller config holding pathfinding constraints and trench zone definitions
      Returns:
      command that pathfinds to the target pose with trench zone handling, or a no-op if the subsystem is disabled