Class MatchState

java.lang.Object
org.wpilib.driverstation.MatchState

public final class MatchState extends Object
Provides access to match state information from the Driver Station.
  • Method Details

    • getMatchTime

      public static double getMatchTime()
      Return the approximate match time. The FMS does not send an official match time to the robots, but does send an approximate match time. The value will count down the time remaining in the current period (auto or teleop). Warning: This is not an official time (so it cannot be used to dispute ref calls or guarantee that a function will trigger before the match ends).

      When connected to the real field, this number only changes in full integer increments, and always counts down.

      When the DS is in practice mode, this number is a floating point number, and counts down.

      When the DS is in teleop or autonomous mode, this number returns -1.0.

      Simulation matches DS behavior without an FMS connected.

      Returns:
      Time remaining in current match period (auto or teleop) in seconds
    • getAlliance

      public static Optional<Alliance> getAlliance()
      Get the current alliance from the FMS.

      If the FMS is not connected, it is set from the team alliance setting on the driver station.

      Returns:
      The alliance (red or blue) or an empty optional if the alliance is invalid
    • getLocation

      public static OptionalInt getLocation()
      Gets the location of the team's driver station controls from the FMS.

      If the FMS is not connected, it is set from the team alliance setting on the driver station.

      Returns:
      the location of the team's driver station controls: 1, 2, or 3
    • getReplayNumber

      public static int getReplayNumber()
      Get the replay number from the FMS.
      Returns:
      the replay number
    • getMatchNumber

      public static int getMatchNumber()
      Get the match number from the FMS.
      Returns:
      the match number
    • getMatchType

      public static MatchType getMatchType()
      Get the match type from the FMS.
      Returns:
      the match type
    • getEventName

      public static String getEventName()
      Get the event name from the FMS.
      Returns:
      the event name
    • getGameData

      public static Optional<String> getGameData()
      Get the game specific message from the FMS.

      If the FMS is not connected, it is set from the game data setting on the driver station.

      Returns:
      the game specific message