Class GameplayStateSubsystem
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.shared.subsystems.AbstractSubsystem<GameplayStateSubsystemConfig>
frc.robot.subsystems.gameplaystate.GameplayStateSubsystem
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable,edu.wpi.first.wpilibj2.command.Subsystem
Tracks the robot's high-level operating mode and publishes the current gameplay state for command factories and telemetry.
This subsystem does not own hardware or directly schedule commands on other subsystems. It maintains the current GameplayState and exposes
it so the companion GameplayStateCommandFactory can compose the appropriate parallel command groups. Automatic transitions based on FMS
match phase and endgame timer are evaluated each cycle when enabled in configuration.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionGameplayStateSubsystem(GameplayStateSubsystemConfig config, Supplier<Double> distanceToTargetMetersSupplier, Supplier<String> activeTargetNameSupplier) Creates the Gameplay State subsystem with targeting telemetry suppliers. -
Method Summary
Modifier and TypeMethodDescriptionReturns the current gameplay state.booleanReturns true when the endgame threshold has been reached.voidperiodic()Evaluates automatic state transitions and logs telemetry each robot loop.voidrequestState(GameplayState state, String source) Requests a transition to the specified gameplay state.Methods inherited from class frc.robot.shared.subsystems.AbstractSubsystem
getConfig, isFMSAttached, isSimulation, isSubsystemDisabled, isVerbose, isVerboseLoggingEnabled, logDisabled, reportWarningMethods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, idle, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
GameplayStateSubsystem
public GameplayStateSubsystem(GameplayStateSubsystemConfig config, Supplier<Double> distanceToTargetMetersSupplier, Supplier<String> activeTargetNameSupplier) Creates the Gameplay State subsystem with targeting telemetry suppliers.- Parameters:
config- configuration values for auto-transition behavior and endgame thresholdsdistanceToTargetMetersSupplier- supplier returning the distance from the robot to the active field target in metersactiveTargetNameSupplier- supplier returning the human-readable name of the active field target
-
-
Method Details
-
periodic
public void periodic()Evaluates automatic state transitions and logs telemetry each robot loop. -
requestState
Requests a transition to the specified gameplay state.The state change takes effect immediately. The transition source is recorded for telemetry so operators can see what triggered each change.
- Parameters:
state- desired gameplay statesource- description of what triggered this transition (e.g., "operator", "fms", "auto", "timer")
-
getCurrentState
Returns the current gameplay state.- Returns:
- active gameplay state
-
isEndgameSuggested
public boolean isEndgameSuggested()Returns true when the endgame threshold has been reached.Use this as a dashboard indicator or driver alert.
- Returns:
- true when match time is below the configured endgame threshold during teleop
-