Class GameplayStateCommandFactory

java.lang.Object
frc.robot.shared.commands.AbstractSubsystemCommandFactory<GameplayStateSubsystem>
frc.robot.subsystems.gameplaystate.commands.GameplayStateCommandFactory

public class GameplayStateCommandFactory extends AbstractSubsystemCommandFactory<GameplayStateSubsystem>
Composes parallel command groups that coordinate multiple subsystems for each GameplayState.

Each factory method produces a command group that sets the appropriate gameplay state on the GameplayStateSubsystem and then schedules mechanism commands in parallel so the robot acts as a unified system. The factory delegates to individual subsystem command factories rather than driving motors directly, keeping subsystem ownership intact.

  • Constructor Details

    • GameplayStateCommandFactory

      public GameplayStateCommandFactory(GameplayStateSubsystem subsystem, ShooterSubsystemCommandFactory shooterCommandFactory, IndexerSubsystemCommandFactory indexerCommandFactory, FeederSubsystemCommandFactory feederCommandFactory, IntakeSubsystemCommandFactory intakeCommandFactory, HarvesterSubsystemCommandFactory harvesterCommandFactory, Supplier<Double> distanceToTargetMetersSupplier, Supplier<Boolean> turretReadySupplier)
      Creates a factory that composes gameplay state commands from individual subsystem command factories.
      Parameters:
      subsystem - gameplay state subsystem that tracks the current operating mode
      shooterCommandFactory - factory for shooter flywheel commands
      indexerCommandFactory - factory for indexer roller commands
      feederCommandFactory - factory for feeder belt commands
      intakeCommandFactory - factory for intake roller commands
      harvesterCommandFactory - factory for harvester arm commands
      distanceToTargetMetersSupplier - supplier returning the distance from the robot to the active scoring target in meters
      turretReadySupplier - supplier returning true when the turret has settled on its target
  • Method Details

    • createIdleCommand

      public edu.wpi.first.wpilibj2.command.Command createIdleCommand()
      Builds the IDLE state command group: all subsystems return to their resting positions.

      The shooter idles at its configured idle RPM, the indexer and feeder stop completely, the intake stops, and the harvester stows.

      Returns:
      parallel command group that idles all mechanisms
    • createHarvestReadyCommand

      public edu.wpi.first.wpilibj2.command.Command createHarvestReadyCommand()
      Builds the HARVEST_READY state command group: deploys the harvester arm and spins the intake and feeder to pull Fuel into the robot while the shooter idles.
      Returns:
      parallel command group that prepares the robot for Fuel collection
    • createFireReadyCommand

      public edu.wpi.first.wpilibj2.command.Command createFireReadyCommand()
      Builds the FIRE_READY state command group: spins up the shooter and stages Fuel in the indexer while the turret continues tracking via its default command.

      Both the indexer and feeder wait until the shooter and turret report ready before activating. The indexer gates on readiness via createFireWhenReadyCommand, and the feeder similarly waits before running its reverse-pulse-then-forward sequence. When the command ends or is interrupted (e.g., operator releases the fire trigger), all mechanisms transition back to IDLE so the indexer and feeder stop cleanly. The turret is not explicitly commanded here because it runs its default tracking command at all times.

      Returns:
      parallel command group that prepares the robot to score
    • createEjectCommand

      public edu.wpi.first.wpilibj2.command.Command createEjectCommand()
      Builds the EJECT state command group: reverses all ball-path mechanisms to expel Fuel.

      The shooter stops, and the indexer, feeder, and intake all run in reverse to push Fuel out of the robot. The harvester deploys so ejected Fuel can exit cleanly.

      Returns:
      parallel command group that ejects all Fuel from the robot
    • createTravelCommand

      public edu.wpi.first.wpilibj2.command.Command createTravelCommand()
      Builds the TRAVEL state command group: stows the harvester and idles all other mechanisms for safe field traversal.

      This state is useful when driving across the field without actively collecting or scoring. The harvester moves to its stowed position so it stays inside the frame perimeter, while the shooter, indexer, feeder, and intake return to their idle behaviors.

      Returns:
      parallel command group that stows the harvester and idles all other mechanisms
    • createTrenchTravelCommand

      public edu.wpi.first.wpilibj2.command.Command createTrenchTravelCommand()
      Builds the TRENCH_TRAVEL state command group: deploys the harvester for low-profile clearance under field obstacles while idling all other mechanisms.

      This state is identical to TRAVEL except the harvester is deployed instead of stowed, allowing the robot to pass under structures such as the trench run.

      Returns:
      parallel command group that deploys the harvester and idles all other mechanisms
    • setDefaultIdleCommand

      public edu.wpi.first.wpilibj2.command.Command setDefaultIdleCommand()
      Sets the idle command as the default behavior for the gameplay state subsystem.
      Returns:
      the idle command that was set as the default