DriverStation

class wpilib.DriverStation[source]

Bases: object

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

DriverStation constructor.

The single DriverStation instance is created statically with the instance static member variable, you should never create a DriverStation instance.

class Alliance[source]

Bases: enum.IntEnum

The robot alliance that the robot is a part of.

Blue = 1
Invalid = 2
Red = 0
InAutonomous(entering)[source]

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
InDisabled(entering)[source]

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
InOperatorControl(entering)[source]

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(entering)[source]

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
class MatchType[source]

Bases: enum.IntEnum

An enumeration.

Elimination = 3
None_ = 0
Practice = 1
Qualification = 2
getAlliance()[source]

Get the current alliance from the FMS.

Return type:Alliance
Returns:The current alliance
getBatteryVoltage()[source]

Read the battery voltage.

Deprecated since version 2018.0.0: Use RobotController.getBatteryVoltage()

Returns:The battery voltage in Volts.
getEventName()[source]

Get the event name

Return type:str
Returns:The event name
getGameSpecificMessage()[source]

Get the game specific message.

Return type:str
Returns:The game specific message
classmethod getInstance()[source]

Gets the global instance of the DriverStation.

Returns:DriverStation
getJoystickAxisType(stick, axis)[source]

Returns the types of Axes on a given joystick port.

Parameters:
  • stick (int) – The joystick port number
  • axis (int) – The target axis
Return type:

int

Returns:

An integer that reports type of axis the axis is reporting to be

getJoystickIsXbox(stick)[source]

Gets the value of isXbox on a joystick.

Parameters:stick (int) – The joystick port number
Return type:bool
Returns:A boolean that returns the value of isXbox
getJoystickName(stick)[source]

Gets the name of a joystick

Parameters:stick (int) – The joystick port number
Return type:str
Returns:The joystick name.
getJoystickType(stick)[source]

Gets the value of type on a joystick

Parameters:stick (int) – The joystick port number
Return type:int
Returns:An integer that returns the value of type.
getLocation()[source]

Gets the location of the team’s driver station controls.

Return type:int
Returns:The location of the team’s driver station controls: 1, 2, or 3
getMatchNumber()[source]

Get the match number.

Return type:int
Returns:The match number
getMatchTime()[source]

Return the approximate match time.

The FMS does not currently send the 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 argue with referees or guarantee that a function will trigger before a match ends).

The Practice Match function of the DS approximates the behaviour seen on the field.

Return type:int
Returns:Time remaining in current match period (auto or teleop) in seconds
getMatchType()[source]

Get the match type.

Return type:MatchType
Returns:The match type
getReplayNumber()[source]

Get the replay number.

Return type:int
Returns:The replay number
getStickAxis(stick, axis)[source]

Get the value of the axis on a joystick.

This depends on the mapping of the joystick connected to the specified port.

Parameters:
  • stick (int) – The joystick port number
  • axis (int) – The analog axis value to read from the joystick.
Return type:

float

Returns:

The value of the axis on the joystick.

getStickAxisCount(stick)[source]

Returns the number of axes on a given joystick port.

Parameters:stick (int) – The joystick port number
Return type:int
Returns:The number of axes on the indicated joystick
getStickButton(stick, button)[source]

The state of a button on the joystick. Button indexes begin at 1.

Parameters:
  • stick (int) – The joystick port number
  • button (int) – The button index, beginning at 1.
Return type:

bool

Returns:

The state of the button.

getStickButtonCount(stick)[source]

Gets the number of buttons on a joystick.

Parameters:stick (int) – The joystick port number
Return type:int
Returns:The number of buttons on the indicated joystick.
getStickButtonPressed(stick, button)[source]

Whether one joystick button was pressed since the last check. Button indices begin at 1.

Parameters:
  • stick (int) – Joystick to read
  • button (int) – Button index, beginning at 1
Return type:

bool

Returns:

Whether the joystick button was pressed since the last check

getStickButtonReleased(stick, button)[source]

Whether one joystick button was released since the last check. Button indices begin at 1.

Parameters:
  • stick (int) – Joystick to read
  • button (int) – Button index, beginning at 1
Return type:

bool

Returns:

Whether the joystick button was released since the last check

getStickButtons(stick)[source]

The state of all the buttons on the joystick.

Parameters:stick (int) – The joystick port number
Return type:int
Returns:The state of all buttons, as a bit array.
getStickPOV(stick, pov)[source]

Get the state of a POV on the joystick.

Parameters:
  • stick (int) – The joystick port number
  • pov (int) – which POV
Return type:

int

Returns:

The angle of the POV in degrees, or -1 if the POV is not pressed.

getStickPOVCount(stick)[source]

Returns the number of POVs on a given joystick port.

Parameters:stick (int) – The joystick port number
Return type:int
Returns:The number of POVs on the indicated joystick
isAutonomous()[source]

Gets a value indicating whether the Driver Station requires the robot to be running in autonomous mode.

Return type:bool
Returns:True if autonomous mode should be enabled, False otherwise.
isBrownedOut()[source]

Check if the system is browned out.

Deprecated since version 2018.0.0: Use RobotController.isBrownedOut()

Returns:True if the system is browned out.
isDSAttached()[source]

Is the driver station attached to the robot?

Return type:bool
Returns:True if the robot is being controlled by a driver station.
isDisabled()[source]

Gets a value indicating whether the Driver Station requires the robot to be disabled.

Return type:bool
Returns:True if the robot should be disabled, False otherwise.
isEnabled()[source]

Gets a value indicating whether the Driver Station requires the robot to be enabled.

Return type:bool
Returns:True if the robot is enabled, False otherwise.
isFMSAttached()[source]

Gets if the driver station attached to a Field Management System.

Return type:bool
Returns:True if the robot is competing on a field being controlled by a Field Management System
isNewControlData()[source]

Gets if a new control packet from the driver station arrived since the last time this function was called.

Return type:bool
Returns:True if the control data has been updated since the last call.
isOperatorControl()[source]

Gets a value indicating whether the Driver Station requires the robot to be running in operator-controlled mode.

Return type:bool
Returns:True if operator-controlled mode should be enabled, False otherwise.
isSysActive()[source]

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.

Deprecated since version 2018.0.0: Use RobotController.isSysActive()

Returns:True if the FPGA outputs are enabled.
isTest()[source]

Gets a value indicating whether the Driver Station requires the robot to be running in test mode.

Return type:bool
Returns:True if test mode should be enabled, False otherwise.
kJoystickPorts = 6

The number of joystick ports

release()[source]

Kill the thread.

static reportError(error, printTrace)[source]

Report error to Driver Station, and also prints error to sys.stderr. Optionally appends stack trace to error message.

Parameters:printTrace – If True, append stack trace to error string
static reportWarning(error, printTrace)[source]

Report warning to Driver Station, and also prints error to sys.stderr. Optionally appends stack trace to error message.

Parameters:printTrace – If True, append stack trace to warning string
waitForData(timeout=None)[source]

Wait for new data or for timeout, which ever comes first.

If timeout is None, wait for new data only.

Parameters:timeout (Optional[int]) – The maximum time in seconds to wait.
Return type:bool
Returns:True if there is new data, otherwise False