DriverStationSim

class wpilib.simulation.DriverStationSim

Bases: pybind11_object

Class to control a simulated driver station.

static getAllianceStationId() hal._wpiHal.AllianceStationID

Get the alliance station ID (color + number).

Returns:

the alliance station color and number

static getDsAttached() bool

Check if the DS is attached.

Returns:

true if attached

static getEStop() bool

Check if eStop has been activated.

Returns:

true if eStopped

static getEnabled() bool

Check if the DS is enabled.

Returns:

true if enabled

static getFmsAttached() bool

Check if the FMS is connected.

Returns:

true if FMS is connected

static getJoystickLeds(stick: SupportsInt | SupportsIndex) int

Gets the joystick outputs.

Parameters:

stick – The joystick number

Returns:

The joystick outputs

static getJoystickRumble(stick: SupportsInt | SupportsIndex, rumbleNum: SupportsInt | SupportsIndex) int

Gets the joystick rumble.

Parameters:
  • stick – The joystick number

  • rumbleNum – Rumble to get (0=left, 1=right, 2=left trigger, 3=right trigger)

Returns:

The joystick rumble value

static getMatchTime() float

Get the current value of the match timer.

Returns:

the current match time

static getOpMode() int

Get the opmode set by the DS.

Returns:

opmode

static getOpModeOptions() wpilib.simulation._simulation.OpModeOptions

Gets the list of opmode options.

Returns:

opmodes list

static getRobotMode() hal._wpiHal._RobotMode

Get the robot mode set by the DS.

Returns:

robot mode

static notifyNewData() None

Updates DriverStation data so that new values are visible to the user program.

static registerAllianceStationIdCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on the alliance station ID.

Parameters:
  • callback – the callback that will be called whenever the alliance station changes

  • initialNotify – if true, the callback will be run on the initial value

Returns:

the CallbackStore object associated with this callback

static registerDsAttachedCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on whether the DS is connected.

Parameters:
  • callback – the callback that will be called whenever the DS connection changes

  • initialNotify – if true, the callback will be run on the initial value

Returns:

the CallbackStore object associated with this callback

static registerEStopCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on the eStop state.

Parameters:
  • callback – the callback that will be called whenever the eStop state changes

  • initialNotify – if true, the callback will be run on the initial value

Returns:

the CallbackStore object associated with this callback

static registerEnabledCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on whether the DS is enabled.

Parameters:
  • callback – the callback that will be called whenever the enabled state is changed

  • initialNotify – if true, the callback will be run on the initial value

Returns:

the CallbackStore object associated with this callback

static registerFmsAttachedCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on whether the FMS is connected.

Parameters:
  • callback – the callback that will be called whenever the FMS connection changes

  • initialNotify – if true, the callback will be run on the initial value

Returns:

the CallbackStore object associated with this callback

static registerMatchTimeCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on match time.

Parameters:
  • callback – the callback that will be called whenever match time changes

  • initialNotify – if true, the callback will be run on the initial value

Returns:

the CallbackStore object associated with this callback

static registerOpModeCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on DS opmode changes.

Parameters:
  • callback – the callback that will be called when opmode changes

  • initialNotify – if true, the callback will be run on the initial value

Returns:

the CallbackStore object associated with this callback

static registerRobotModeCallback(callback: collections.abc.Callable[[str, hal._wpiHal.Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on DS robot mode changes.

Parameters:
  • callback – the callback that will be called when robot mode changes

  • initialNotify – if true, the callback will be run on the initial value

Returns:

the CallbackStore object associated with this callback

static resetData() None

Reset all simulation data for the Driver Station.

static setAllianceStationId(allianceStationId: hal._wpiHal.AllianceStationID) None

Change the alliance station.

Parameters:

allianceStationId – the new alliance station

static setDsAttached(dsAttached: bool) None

Change whether the DS is attached.

Parameters:

dsAttached – the new value

static setEStop(eStop: bool) None

Set whether eStop is active.

Parameters:

eStop – true to activate

static setEnabled(enabled: bool) None

Change whether the DS is enabled.

Parameters:

enabled – the new value

static setEventName(name: str) None

Sets the event name.

Parameters:

name – the event name

static setFmsAttached(fmsAttached: bool) None

Change whether the FMS is connected.

Parameters:

fmsAttached – the new value

static setGameData(message: str) None

Sets the game specific message.

Parameters:

message – the game specific message

static setJoystickAxesAvailable(stick: SupportsInt | SupportsIndex, available: SupportsInt | SupportsIndex) None

Sets the number of axes for a joystick.

Parameters:
  • stick – The joystick number

  • available – The number of axes on the indicated joystick

static setJoystickAxesMaximumIndex(stick: SupportsInt | SupportsIndex, maximumIndex: SupportsInt | SupportsIndex) None

Sets the number of axes for a joystick.

Parameters:
  • stick – The joystick number

  • maximumIndex – The number of axes on the indicated joystick

static setJoystickAxis(stick: SupportsInt | SupportsIndex, axis: SupportsInt | SupportsIndex, value: SupportsFloat | SupportsIndex) None

Gets the value of the axis on a joystick.

Parameters:
  • stick – The joystick number

  • axis – The analog axis number

  • value – The value of the axis on the joystick

static setJoystickButton(stick: SupportsInt | SupportsIndex, button: SupportsInt | SupportsIndex, state: bool) None

Sets the state of one joystick button. %Button indexes begin at 0.

Parameters:
  • stick – The joystick number

  • button – The button index, beginning at 0

  • state – The state of the joystick button

static setJoystickButtonsAvailable(stick: SupportsInt | SupportsIndex, available: SupportsInt | SupportsIndex) None
static setJoystickButtonsMaximumIndex(stick: SupportsInt | SupportsIndex, count: SupportsInt | SupportsIndex) None

Sets the number of buttons for a joystick.

Parameters:
  • stick – The joystick number

  • count – The number of buttons on the indicated joystick

static setJoystickGamepadType(stick: SupportsInt | SupportsIndex, type: SupportsInt | SupportsIndex) None

Sets the value of type for a joystick.

Parameters:
  • stick – The joystick number

  • type – The value of type

static setJoystickIsGamepad(stick: SupportsInt | SupportsIndex, isGamepad: bool) None

Sets the value of isGamepad for a joystick.

Parameters:
  • stick – The joystick number

  • isGamepad – The value of isGamepad

static setJoystickName(stick: SupportsInt | SupportsIndex, name: str) None

Sets the name of a joystick.

Parameters:
  • stick – The joystick number

  • name – The value of name

static setJoystickPOV(stick: SupportsInt | SupportsIndex, pov: SupportsInt | SupportsIndex, value: wpilib._wpilib.POVDirection) None

Gets the state of a POV on a joystick.

Parameters:
  • stick – The joystick number

  • pov – The POV number

  • value – the angle of the POV

static setJoystickPOVsAvailable(stick: SupportsInt | SupportsIndex, available: SupportsInt | SupportsIndex) None

Sets the number of POVs for a joystick.

Parameters:
  • stick – The joystick number

  • available – The number of POVs on the indicated joystick

static setJoystickPOVsMaximumIndex(stick: SupportsInt | SupportsIndex, maximumIndex: SupportsInt | SupportsIndex) None

Sets the number of POVs for a joystick.

Parameters:
  • stick – The joystick number

  • maximumIndex – The number of POVs on the indicated joystick

static setJoystickSupportedOutputs(stick: SupportsInt | SupportsIndex, supportedOutputs: SupportsInt | SupportsIndex) None

Sets the supported outputs for a joystick.

Parameters:
  • stick – The joystick number

  • supportedOutputs – The supported outputs for the joystick

static setMatchNumber(matchNumber: SupportsInt | SupportsIndex) None

Sets the match number.

Parameters:

matchNumber – the match number

static setMatchTime(matchTime: SupportsFloat | SupportsIndex) None

Sets the match timer.

Parameters:

matchTime – the new match time

static setMatchType(type: wpilib._wpilib.MatchType) None

Sets the match type.

Parameters:

type – the match type

static setOpMode(opmode: SupportsInt | SupportsIndex) None

Change the opmode set by the DS.

Parameters:

opmode – the new value

static setReplayNumber(replayNumber: SupportsInt | SupportsIndex) None

Sets the replay number.

Parameters:

replayNumber – the replay number

static setRobotMode(robotMode: hal._wpiHal._RobotMode) None

Change the robot mode set by the DS.

Parameters:

robotMode – the new value

static setSendConsoleLine(shouldSend: bool) None

Sets suppression of DriverStationErrors::SendConsoleLine messages.

Parameters:

shouldSend – If false then messages will be suppressed.

static setSendError(shouldSend: bool) None

Sets suppression of DriverStationErrors::ReportError and ReportWarning messages.

Parameters:

shouldSend – If false then messages will be suppressed.