2010 FRC Java API


edu.wpi.first.wpilibj
Class DriverStation

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

public class DriverStation
extends Object

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 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 contructor.
 
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()
          Get the dashboard packer for sending high user data to a dashboard program
 Dashboard getDashboardPackerLow()
          Get the dashboard packer for sending low priority user data to a dashboard program
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()
          Get the location of the controls
 int getPacketNumber()
          Return the DS packet number.
 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. 12 buttons (4 msb are unused) from the joystick.
 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 isOperatorControl()
          Gets a value indicating whether the Driver Station requires the robot to be running in operator-controlled mode.
 void release()
          Kill the thread
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.
 
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
Constructor Detail

DriverStation

protected DriverStation()
DriverStation contructor. 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


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

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.

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()
Get the location of the controls

Returns:
the location of the controls

getDashboardPackerHigh

public Dashboard getDashboardPackerHigh()
Get the dashboard packer for sending high user data to a dashboard program

Returns:
a Dashboard object

getDashboardPackerLow

public Dashboard getDashboardPackerLow()
Get the dashboard packer for sending low priority user data to a dashboard program

Returns:
a Dashboard object

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.

2010 FRC Java API


Copyright © 2006-2009 Sun Microsystems, Inc. All Rights Reserved.