edu.wpi.first.wpilibj

## Class DriverStation

- java.lang.Object
- - edu.wpi.first.wpilibj.DriverStation

-     public class DriverStation
      extends java.lang.Object

  Provide access to the network communication data to / from the Driver Station.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DriverStation.Alliance` The robot alliance that the robot is a part of.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `kJoystickPorts` Number of Joystick Ports.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DriverStation.Alliance` | `getAlliance()` Get the current alliance from the FMS.
    `double` | `getBatteryVoltage()` Read the battery voltage.
    `protected void` | `getData()` Copy data from the DS task for the user.
    `static DriverStation` | `getInstance()` Gets an instance of the DriverStation.
    `int` | `getJoystickAxisType(int stick, int axis)` Returns the types of Axes on a given joystick port.
    `boolean` | `getJoystickIsXbox(int stick)` Gets the value of isXbox on a joystick.
    `java.lang.String` | `getJoystickName(int stick)` Gets the name of the joystick at a port.
    `int` | `getJoystickType(int stick)` Gets the value of type on a joystick.
    `int` | `getLocation()` Gets the location of the team's driver station controls.
    `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.
    `double` | `getStickAxis(int stick, int axis)` Get the value of the axis on a joystick.
    `int` | `getStickAxisCount(int stick)` Returns the number of axes on a given joystick port.
    `boolean` | `getStickButton(int stick, int button)` The state of one joystick button.
    `int` | `getStickButtonCount(int stick)` Gets the number of buttons on a joystick.
    `int` | `getStickButtons(int stick)` The state of the buttons on the joystick.
    `int` | `getStickPOV(int stick, int pov)` Get the state of a POV on the joystick.
    `int` | `getStickPOVCount(int stick)` Returns the number of POVs on a given joystick port.
    `void` | `InAutonomous(boolean entering)` Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
    `void` | `InDisabled(boolean entering)` Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
    `void` | `InOperatorControl(boolean entering)` Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
    `void` | `InTest(boolean entering)` Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
    `boolean` | `isAutonomous()` Gets a value indicating whether the Driver Station requires the robot to be running in autonomous mode.
    `boolean` | `isBrownedOut()` Check if the system is browned out.
    `boolean` | `isDisabled()` Gets a value indicating whether the Driver Station requires the robot to be disabled.
    `boolean` | `isDSAttached()` Gets a value indicating whether the Driver Station is attached.
    `boolean` | `isEnabled()` Gets a value indicating whether the Driver Station requires the robot to be enabled.
    `boolean` | `isFMSAttached()` Gets if the driver station attached to a Field Management System.
    `boolean` | `isNewControlData()` Gets if a new control packet from the driver station arrived since the last time this function was called.
    `boolean` | `isOperatorControl()` Gets a value indicating whether the Driver Station requires the robot to be running in operator-controlled mode.
    `boolean` | `isSysActive()` Gets a value indicating whether the FPGA outputs are enabled.
    `boolean` | `isTest()` Gets a value indicating whether the Driver Station requires the robot to be running in test mode.
    `void` | `release()` Kill the thread.
    `static void` | `reportError(java.lang.String error, boolean printTrace)` Report error to Driver Station.
    `static void` | `reportWarning(java.lang.String error, boolean printTrace)` Report warning to Driver Station.
    `void` | `waitForData()` Wait for new data from the driver station.
    `boolean` | `waitForData(double timeout)` Wait for new data or for timeout, which ever comes first.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### kJoystickPorts

          public static final int kJoystickPorts

      Number of Joystick Ports.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getInstance

          public static DriverStation getInstance()

      Gets an instance of the DriverStation.
      Returns:
        The DriverStation.

    - #### release

          public void release()

      Kill the thread.

    - #### reportError

          public static void reportError(java.lang.String error,
                                         boolean printTrace)

      Report error to Driver Station. Also prints error to System.err Optionally appends Stack trace to error message.
      Parameters:
        `printTrace` - If true, append stack trace to error string

    - #### reportWarning

          public static void reportWarning(java.lang.String error,
                                           boolean printTrace)

      Report warning to Driver Station. Also prints error to System.err Optionally appends Stack trace to warning message.
      Parameters:
        `printTrace` - If true, append stack trace to warning string

    - #### getStickButton

          public boolean getStickButton(int stick,
                                        int button)

      The state of one joystick button. Button indexes begin at 1.
      Parameters:
        `stick` - The joystick to read.
        `button` - The button index, beginning at 1.
      Returns:
        The state of the joystick button.

    - #### getStickAxis

          public double getStickAxis(int stick,
                                     int axis)

      Get the value of the axis on a joystick. This depends on the mapping of the joystick connected to the specified port.
      Parameters:
        `stick` - The joystick to read.
        `axis` - The analog axis value to read from the joystick.
      Returns:
        The value of the axis on the joystick.

    - #### getStickPOV

          public int getStickPOV(int stick,
                                 int pov)

      Get the state of a POV on the joystick.
      Returns:
        the angle of the POV in degrees, or -1 if the POV is not pressed.

    - #### getStickButtons

          public int getStickButtons(int stick)

      The state of the buttons on the joystick.
      Parameters:
        `stick` - The joystick to read.
      Returns:
        The state of the buttons on the joystick.

    - #### getStickAxisCount

          public int getStickAxisCount(int stick)

      Returns the number of axes on a given joystick port.
      Parameters:
        `stick` - The joystick port number
      Returns:
        The number of axes on the indicated joystick

    - #### getStickPOVCount

          public int getStickPOVCount(int stick)

      Returns the number of POVs on a given joystick port.
      Parameters:
        `stick` - The joystick port number
      Returns:
        The number of POVs on the indicated joystick

    - #### getStickButtonCount

          public int getStickButtonCount(int stick)

      Gets the number of buttons on a joystick.
      Parameters:
        `stick` - The joystick port number
      Returns:
        The number of buttons on the indicated joystick

    - #### getJoystickIsXbox

          public boolean getJoystickIsXbox(int stick)

      Gets the value of isXbox on a joystick.
      Parameters:
        `stick` - The joystick port number
      Returns:
        A boolean that returns the value of isXbox

    - #### getJoystickType

          public int getJoystickType(int stick)

      Gets the value of type on a joystick.
      Parameters:
        `stick` - The joystick port number
      Returns:
        The value of type

    - #### getJoystickName

          public java.lang.String getJoystickName(int stick)

      Gets the name of the joystick at a port.
      Parameters:
        `stick` - The joystick port number
      Returns:
        The value of name

    - #### getJoystickAxisType

          public int getJoystickAxisType(int stick,
                                         int axis)

      Returns the types of Axes on a given joystick port.
      Parameters:
        `stick` - The joystick port number
        `axis` - The target axis
      Returns:
        What type of axis the axis is reporting to be

    - #### isEnabled

          public boolean isEnabled()

      Gets a value indicating whether the Driver Station requires the robot to be enabled.
      Returns:
        True if the robot is enabled, false otherwise.

    - #### isDisabled

          public boolean isDisabled()

      Gets a value indicating whether the Driver Station requires the robot to be disabled.
      Returns:
        True if the robot should be disabled, false otherwise.

    - #### isAutonomous

          public boolean isAutonomous()

      Gets a value indicating whether the Driver Station requires the robot to be running in autonomous mode.
      Returns:
        True if autonomous mode should be enabled, false otherwise.

    - #### isOperatorControl

          public boolean isOperatorControl()

      Gets a value indicating whether the Driver Station requires the robot to be running in operator-controlled mode.
      Returns:
        True if operator-controlled mode should be enabled, false otherwise.

    - #### isTest

          public boolean isTest()

      Gets a value indicating whether the Driver Station requires the robot to be running in test mode.
      Returns:
        True if test mode should be enabled, false otherwise.

    - #### isDSAttached

          public boolean isDSAttached()

      Gets a value indicating whether the Driver Station is attached.
      Returns:
        True if Driver Station is attached, false otherwise.

    - #### isNewControlData

          public boolean isNewControlData()

      Gets if a new control packet from the driver station arrived since the last time this function was called.
      Returns:
        True if the control data has been updated since the last call.

    - #### isFMSAttached

          public boolean isFMSAttached()

      Gets if the driver station attached to a Field Management System.
      Returns:
        true if the robot is competing on a field being controlled by a Field Management System

    - #### isSysActive

          public boolean isSysActive()

      Gets a value indicating whether the FPGA outputs are enabled. The outputs may be disabled if the robot is disabled or e-stopped, the watchdog has expired, or if the roboRIO browns out.
      Returns:
        True if the FPGA outputs are enabled.

    - #### isBrownedOut

          public boolean isBrownedOut()

      Check if the system is browned out.
      Returns:
        True if the system is browned out

    - #### getAlliance

          public DriverStation.Alliance getAlliance()

      Get the current alliance from the FMS.
      Returns:
        the current alliance

    - #### getLocation

          public int getLocation()

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

    - #### waitForData

          public void waitForData()

      Wait for new data from the driver station.

    - #### waitForData

          public boolean waitForData(double timeout)

      Wait for new data or for timeout, which ever comes first. If timeout is 0, wait for new data only.
      Parameters:
        `timeout` - The maximum time in seconds to wait.
      Returns:
        true if there is new data, otherwise false

    - #### getMatchTime

          public 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) The Practice Match function of the DS approximates the behaviour seen on the field.
      Returns:
        Time remaining in current match period (auto or teleop) in seconds

    - #### getBatteryVoltage

          public double getBatteryVoltage()

      Read the battery voltage.
      Returns:
        The battery voltage in Volts.

    - #### InDisabled

          public void InDisabled(boolean entering)

      Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
      Parameters:
        `entering` - If true, starting disabled code; if false, leaving disabled code

    - #### InAutonomous

          public void InAutonomous(boolean entering)

      Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
      Parameters:
        `entering` - If true, starting autonomous code; if false, leaving autonomous code

    - #### InOperatorControl

          public void InOperatorControl(boolean entering)

      Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
      Parameters:
        `entering` - If true, starting teleop code; if false, leaving teleop code

    - #### InTest

          public void InTest(boolean entering)

      Only to be used to tell the Driver Station what code you claim to be executing for diagnostic purposes only.
      Parameters:
        `entering` - If true, starting test code; if false, leaving test code

    - #### getData

          protected void getData()

      Copy data from the DS task for the user. If no new data exists, it will just be returned, otherwise the data will be copied from the DS polling loop.