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: object

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 MatchInfoData[source]

Bases: object

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.

Returns:The current alliance
Return type:DriverStation.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

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

Get the game specific message

Returns:Game specific message
Return type:str
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

: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

: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

:returns The joystick name.

getJoystickType(stick)[source]

Gets the value of type on a joystick

Parameters:stick (int) – The joystick port number

:returns An integer that returns the value of type.

getLocation()[source]

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

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

Get the match number

Returns:Match number
Return type:int
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.

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

Gets the match type

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

Get the replay number

Returns:Replay number
Return type:int
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.
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
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.
Returns:

The state of the button.

getStickButtonCount(stick)[source]

Gets the number of buttons on a joystick

Parameters:stick (int) – The joystick port number
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 – Joystick to read
  • button – Button index, beginning at 1
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 – Joystick to read
  • button – Button index, beginning at 1
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
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
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
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.

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?

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.

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.

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

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

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

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

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 – The maximum time in seconds to wait.
Returns:True if there is new data, otherwise False