Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.wpi.first.wpilibj
Class DriverStation

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

All Implemented Interfaces:
  IDevice, IInputOutput

    public class DriverStation

extends Object
implements IInputOutput

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

Nested Class Summary
`static class` | `DriverStation.Alliance` The robot alliance that the robot is a part of

Field Summary
`static int` | `kBatteryChannel` Analog channel to read the battery
`static int` | `kBatterySlot` Slot for the analog module to read the battery
`static double` | `kDSAnalogInScaling` Convert from raw values to volts
`static int` | `kJoystickAxes` Number of Joystick Axes
`static int` | `kJoystickPorts` Number of Joystick Ports
`static int` | `USER_CONTROL_DATA_SIZE` The size of the user control data
`static int` | `USER_STATUS_DATA_SIZE` The size of the user status data

Constructor Summary
`protected` | `DriverStation()` DriverStation constructor.

Method Summary
`DriverStation.Alliance` | `getAlliance()` Get the current alliance from the FMS
`double` | `getAnalogIn(int channel)` Get an analog voltage from the Driver Station.
`double` | `getBatteryVoltage()` Read the battery voltage from the specified AnalogChannel.
`Dashboard` | `getDashboardPackerHigh()` Gets the default dashboard packer for sending high priority user data to a dashboard receiver.
`IDashboard` | `getDashboardPackerInUseHigh()` Gets the dashboard packer that's currently in use for sending high priority user data to a dashboard receiver.
`IDashboard` | `getDashboardPackerInUseLow()` Gets the dashboard packer that's currently in use for sending low priority user data to a dashboard receiver.
`Dashboard` | `getDashboardPackerLow()` Gets the default dashboard packer for sending low priority user data to a dashboard receiver.
`protected void` | `getData()` Copy data from the DS task for the user.
`boolean` | `getDigitalIn(int channel)` Get values from the digital inputs on the Driver Station.
`boolean` | `getDigitalOut(int channel)` Get a value that was set for the digital outputs on the Driver Station.
`DriverStationEnhancedIO` | `getEnhancedIO()` Get the interface to the enhanced IO of the new driver station.
`static DriverStation` | `getInstance()` Gets an instance of the DriverStation
`int` | `getLocation()` Gets the location of the team's driver station controls.
`double` | `getMatchTime()` Return the approximate match time The FMS does not currently send the official match time to the robots This returns the time since the enable signal sent from the Driver Station At the beginning of autonomous, the time is reset to 0.0 seconds At the beginning of teleop, the time is reset to +15.0 seconds If the robot is disabled, this returns 0.0 seconds Warning: This is not an official time (so it cannot be used to argue with referees)
`int` | `getPacketNumber()` Return the DS packet number.
`Object` | `getStatusDataMonitor()` Gets the status data monitor
`double` | `getStickAxis(int stick, int axis)` Get the value of the axis on a joystick.
`int` | `getStickButtons(int stick)` The state of the buttons on the joystick.
`int` | `getTeamNumber()` Return the team number that the Driver Station is configured for
`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` | `isDisabled()` Gets a value indicating whether the Driver Station requires the robot to be disabled.
`boolean` | `isEnabled()` Gets a value indicating whether the Driver Station requires the robot to be enabled.
`boolean` | `isFMSAttached()` Is the driver station attached to a Field Management System? Note: This does not work with the Blue DS.
`boolean` | `isNewControlData()` Has 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` | `isTest()` Gets a value indicating whether the Driver Station requires the robot to be running in test mode.
`void` | `release()` Kill the thread
`void` | `setDashboardPackerToUseHigh(IDashboard dashboard)` Sets the dashboard packer to use for sending high priority user data to a dashboard receiver.
`void` | `setDashboardPackerToUseLow(IDashboard dashboard)` Sets the dashboard packer to use for sending low priority user data to a dashboard receiver.
`protected void` | `setData()` Copy status data from the DS task for the user.
`void` | `setDigitalOut(int channel, boolean value)` Set a value for the digital outputs on the Driver Station.
`void` | `waitForData()` Wait for new data from the driver station.
`void` | `waitForData(long timeout)` Wait for new data or for timeout, which ever comes first.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### USER_CONTROL_DATA_SIZE

    public static final int USER_CONTROL_DATA_SIZE

  The size of the user control data

  See Also:
    Constant Field Values

### USER_STATUS_DATA_SIZE

    public static final int USER_STATUS_DATA_SIZE

  The size of the user status data

  See Also:
    Constant Field Values

### kBatterySlot

    public static final int kBatterySlot

  Slot for the analog module to read the battery

  See Also:
    Constant Field Values

### kBatteryChannel

    public static final int kBatteryChannel

  Analog channel to read the battery

  See Also:
    Constant Field Values

### kJoystickPorts

    public static final int kJoystickPorts

  Number of Joystick Ports

  See Also:
    Constant Field Values

### kJoystickAxes

    public static final int kJoystickAxes

  Number of Joystick Axes

  See Also:
    Constant Field Values

### kDSAnalogInScaling

    public static final double kDSAnalogInScaling

  Convert from raw values to volts

  See Also:
    Constant Field Values

Constructor Detail

### DriverStation

    protected DriverStation()

  DriverStation constructor. The single DriverStation instance is created statically with the instance static member variable.

Method Detail

### getInstance

    public static DriverStation getInstance()

  Gets an instance of the DriverStation

  Returns:
    The DriverStation.

### release

    public void release()

  Kill the thread

### waitForData

    public void waitForData()

  Wait for new data from the driver station.

### waitForData

    public void waitForData(long 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 milliseconds to wait.

### 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.

### setData

    protected void setData()

  Copy status data from the DS task for the user. This is used primarily to set digital outputs on the DS.

### getBatteryVoltage

    public double getBatteryVoltage()

  Read the battery voltage from the specified AnalogChannel. This accessor assumes that the battery voltage is being measured through the voltage divider on an analog breakout.

  Returns:
    The battery voltage.

### 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.

### getStickButtons

    public int getStickButtons(int stick)

  The state of the buttons on the joystick. 12 buttons (4 msb are unused) from the joystick.

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

### getAnalogIn

    public double getAnalogIn(int channel)

  Get an analog voltage from the Driver Station. The analog values are returned as voltage values for the Driver Station analog inputs. These inputs are typically used for advanced operator interfaces consisting of potentiometers or resistor networks representing values on a rotary switch.

  Parameters:
    `channel` - The analog input channel on the driver station to read from. Valid range is 1 - 4.
  Returns:
    The analog voltage on the input.

### getDigitalIn

    public boolean getDigitalIn(int channel)

  Get values from the digital inputs on the Driver Station. Return digital values from the Drivers Station. These values are typically used for buttons and switches on advanced operator interfaces.

  Parameters:
    `channel` - The digital input to get. Valid range is 1 - 8.
  Returns:
    The value of the digital input

### setDigitalOut

    public void setDigitalOut(int channel,
                              boolean value)

  Set a value for the digital outputs on the Driver Station. Control digital outputs on the Drivers Station. These values are typically used for giving feedback on a custom operator station such as LEDs.

  Parameters:
    `channel` - The digital output to set. Valid range is 1 - 8.
    `value` - The state to set the digital output.

### getDigitalOut

    public boolean getDigitalOut(int channel)

  Get a value that was set for the digital outputs on the Driver Station.

  Parameters:
    `channel` - The digital ouput to monitor. Valid range is 1 through 8.
  Returns:
    A digital value being output on the Drivers Station.

### 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.

### 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.

### 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.

### isNewControlData

    public boolean isNewControlData()

  Has 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.

### getPacketNumber

    public int getPacketNumber()

  Return the DS packet number. The packet number is the index of this set of data returned by the driver station. Each time new data is received, the packet number (included with the sent data) is returned.

  Returns:
    The DS packet number.

### 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

### getTeamNumber

    public int getTeamNumber()

  Return the team number that the Driver Station is configured for

  Returns:
    The team number

### setDashboardPackerToUseHigh

    public void setDashboardPackerToUseHigh(IDashboard dashboard)

  Sets the dashboard packer to use for sending high priority user data to a dashboard receiver. This can idle or restore the default packer. (Initializing SmartDashboard sets the high priority packer in use, so beware that the default packer will then be idle. You can restore the default high priority packer by calling `setDashboardPackerToUseHigh(getDashboardPackerHigh())`.)

  Parameters:
    `dashboard` - any kind of IDashboard object

### getDashboardPackerHigh

    public Dashboard getDashboardPackerHigh()

  Gets the default dashboard packer for sending high priority user data to a dashboard receiver. This instance stays around even after a call to `setDashboardPackerToUseHigh(edu.wpi.first.wpilibj.IDashboard)` changes which packer is in use.

  Returns:
    the default Dashboard object; it may be idle

### getDashboardPackerInUseHigh

    public IDashboard getDashboardPackerInUseHigh()

  Gets the dashboard packer that's currently in use for sending high priority user data to a dashboard receiver. This can be any kind of IDashboard.

  Returns:
    the current IDashboard object

### setDashboardPackerToUseLow

    public void setDashboardPackerToUseLow(IDashboard dashboard)

  Sets the dashboard packer to use for sending low priority user data to a dashboard receiver. This can idle or restore the default packer.

  Parameters:
    `dashboard` - any kind of IDashboard object

### getDashboardPackerLow

    public Dashboard getDashboardPackerLow()

  Gets the default dashboard packer for sending low priority user data to a dashboard receiver. This instance stays around even after a call to `setDashboardPackerToUseLow(edu.wpi.first.wpilibj.IDashboard)` changes which packer is in use.

  Returns:
    the default Dashboard object; it may be idle

### getDashboardPackerInUseLow

    public IDashboard getDashboardPackerInUseLow()

  Gets the dashboard packer that's currently in use for sending low priority user data to a dashboard receiver. This can be any kind of IDashboard.

  Returns:
    the current IDashboard object

### getStatusDataMonitor

    public Object getStatusDataMonitor()

  Gets the status data monitor

  Returns:
    The status data monitor for use with IDashboard objects which must send data across the network.

### isFMSAttached

    public boolean isFMSAttached()

  Is the driver station attached to a Field Management System? Note: This does not work with the Blue DS.

  Returns:
    True if the robot is competing on a field being controlled by a Field Management System

### getEnhancedIO

    public DriverStationEnhancedIO getEnhancedIO()

  Get the interface to the enhanced IO of the new driver station.

  Returns:
    An enhanced IO object for the advanced features of the driver station.

### getMatchTime

    public double getMatchTime()

  Return the approximate match time The FMS does not currently send the official match time to the robots This returns the time since the enable signal sent from the Driver Station At the beginning of autonomous, the time is reset to 0.0 seconds At the beginning of teleop, the time is reset to +15.0 seconds If the robot is disabled, this returns 0.0 seconds Warning: This is not an official time (so it cannot be used to argue with referees)

  Returns:
    Match time in seconds since the beginning of autonomous

### 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"