DriverStation¶
- class wpilib.DriverStation[source]¶
Bases: builtins.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: builtins.object
The robot alliance that the robot is a part of
- Blue = 1¶
- Invalid = 2¶
- Red = 0¶
- DriverStation.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
- DriverStation.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
- DriverStation.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
- DriverStation.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
- DriverStation.getAlliance()[source]¶
Get the current alliance from the FMS.
Returns: The current alliance Return type: DriverStation.Alliance
- DriverStation.getBatteryVoltage()[source]¶
Read the battery voltage.
Returns: The battery voltage in Volts.
- DriverStation.getData()[source]¶
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.
- static DriverStation.getInstance()[source]¶
Gets the global instance of the DriverStation
Returns: DriverStation
- DriverStation.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
- DriverStation.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
- DriverStation.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 – The joystick port number
- axis – The analog axis value to read from the joystick.
Returns: The value of the axis on the joystick.
- DriverStation.getStickAxisCount(stick)[source]¶
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
- DriverStation.getStickButton(stick, button)[source]¶
The state of a button on the joystick.
Parameters: - stick – The joystick port number
- button – The button number to be read.
Returns: The state of the button.
- DriverStation.getStickButtonCount(stick)[source]¶
Gets the number of buttons on a joystick
Parameters: stick – The joystick port number Returns: The number of buttons on the indicated joystick.
- DriverStation.getStickButtons(stick)[source]¶
The state of all the buttons on the joystick.
Parameters: stick – The joystick port number Returns: The state of all buttons, as a bit array.
- DriverStation.getStickPOV(stick, pov)[source]¶
Get the state of a POV on the joystick.
Parameters: - stick – The joystick port number
- pov – which POV
Returns: The angle of the POV in degrees, or -1 if the POV is not pressed.
- DriverStation.getStickPOVCount(stick)[source]¶
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
- DriverStation.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.
- DriverStation.isBrownedOut()[source]¶
Check if the system is browned out.
Returns: True if the system is browned out.
- DriverStation.isDSAttached()[source]¶
Is the driver station attached to the robot?
Returns: True if the robot is being controlled by a driver station.
- DriverStation.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.
- DriverStation.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.
- DriverStation.isFMSAttached()[source]¶
Is 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
- DriverStation.isNewControlData()[source]¶
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.
- DriverStation.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.
- DriverStation.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 watdhog has expired, or if the roboRIO browns out.
Returns: True if the FPGA outputs are enabled.
- DriverStation.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.
- DriverStation.kJoystickPorts = 6¶
The number of joystick ports