DriverStationSim

class wpilib.simulation.DriverStationSim

Bases: pybind11_object

Class to control a simulated driver station.

static get_alliance_station_id() hal._wpi_hal.AllianceStationID

Get the alliance station ID (color + number).

Returns:

the alliance station color and number

static get_ds_attached() bool

Check if the DS is attached.

Returns:

true if attached

static get_e_stop() bool

Check if eStop has been activated.

Returns:

true if eStopped

static get_enabled() bool

Check if the DS is enabled.

Returns:

true if enabled

static get_fms_attached() bool

Check if the FMS is connected.

Returns:

true if FMS is connected

static get_joystick_leds(stick: SupportsInt | SupportsIndex) int

Gets the joystick outputs.

Parameters:

stick – The joystick number

Returns:

The joystick outputs

static get_joystick_rumble(stick: SupportsInt | SupportsIndex, rumble_num: SupportsInt | SupportsIndex) int

Gets the joystick rumble.

Parameters:
  • stick – The joystick number

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

Returns:

The joystick rumble value

static get_match_time() float

Get the current value of the match timer.

Returns:

the current match time

static get_opmode() int

Get the opmode set by the DS.

Returns:

opmode

static get_opmode_options() wpilib.simulation._simulation.OpModeOptions

Gets the list of opmode options.

Returns:

opmodes list

static get_robot_mode() hal._wpi_hal.RobotMode

Get the robot mode set by the DS.

Returns:

robot mode

static notify_new_data() None

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

static register_alliance_station_id_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: 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

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

Returns:

the CallbackStore object associated with this callback

static register_ds_attached_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: 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

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

Returns:

the CallbackStore object associated with this callback

static register_e_stop_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: 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

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

Returns:

the CallbackStore object associated with this callback

static register_enabled_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: 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

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

Returns:

the CallbackStore object associated with this callback

static register_fms_attached_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: 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

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

Returns:

the CallbackStore object associated with this callback

static register_match_time_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on match time.

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

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

Returns:

the CallbackStore object associated with this callback

static register_opmode_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback on DS opmode changes.

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

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

Returns:

the CallbackStore object associated with this callback

static register_robot_mode_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: 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

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

Returns:

the CallbackStore object associated with this callback

static reset_data() None

Reset all simulation data for the Driver Station.

static set_alliance_station_id(alliance_station_id: hal._wpi_hal.AllianceStationID) None

Change the alliance station.

Parameters:

alliance_station_id – the new alliance station

static set_ds_attached(ds_attached: bool) None

Change whether the DS is attached.

Parameters:

ds_attached – the new value

static set_e_stop(e_stop: bool) None

Set whether eStop is active.

Parameters:

e_stop – true to activate

static set_enabled(enabled: bool) None

Change whether the DS is enabled.

Parameters:

enabled – the new value

static set_event_name(name: str) None

Sets the event name.

Parameters:

name – the event name

static set_fms_attached(fms_attached: bool) None

Change whether the FMS is connected.

Parameters:

fms_attached – the new value

static set_game_data(message: str) None

Sets the game specific message.

Parameters:

message – the game specific message

static set_joystick_axes_available(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 set_joystick_axes_maximum_index(stick: SupportsInt | SupportsIndex, maximum_index: SupportsInt | SupportsIndex) None

Sets the number of axes for a joystick.

Parameters:
  • stick – The joystick number

  • maximum_index – The number of axes on the indicated joystick

static set_joystick_axis(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 set_joystick_button(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 set_joystick_buttons_available(stick: SupportsInt | SupportsIndex, available: SupportsInt | SupportsIndex) None
static set_joystick_buttons_maximum_index(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 set_joystick_gamepad_type(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 set_joystick_is_gamepad(stick: SupportsInt | SupportsIndex, is_gamepad: bool) None

Sets the value of isGamepad for a joystick.

Parameters:
  • stick – The joystick number

  • is_gamepad – The value of isGamepad

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

Sets the name of a joystick.

Parameters:
  • stick – The joystick number

  • name – The value of name

static set_joystick_pov(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 set_joystick_povs_available(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 set_joystick_povs_maximum_index(stick: SupportsInt | SupportsIndex, maximum_index: SupportsInt | SupportsIndex) None

Sets the number of POVs for a joystick.

Parameters:
  • stick – The joystick number

  • maximum_index – The number of POVs on the indicated joystick

static set_joystick_supported_outputs(stick: SupportsInt | SupportsIndex, supported_outputs: SupportsInt | SupportsIndex) None

Sets the supported outputs for a joystick.

Parameters:
  • stick – The joystick number

  • supported_outputs – The supported outputs for the joystick

static set_match_number(match_number: SupportsInt | SupportsIndex) None

Sets the match number.

Parameters:

match_number – the match number

static set_match_time(match_time: SupportsFloat | SupportsIndex) None

Sets the match timer.

Parameters:

match_time – the new match time

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

Sets the match type.

Parameters:

type – the match type

static set_opmode(opmode: SupportsInt | SupportsIndex) None

Change the opmode set by the DS.

Parameters:

opmode – the new value

static set_replay_number(replay_number: SupportsInt | SupportsIndex) None

Sets the replay number.

Parameters:

replay_number – the replay number

static set_robot_mode(robot_mode: hal._wpi_hal.RobotMode) None

Change the robot mode set by the DS.

Parameters:

robot_mode – the new value

static set_send_console_line(should_send: bool) None

Sets suppression of DriverStationErrors::SendConsoleLine messages.

Parameters:

should_send – If false then messages will be suppressed.

static set_send_error(should_send: bool) None

Sets suppression of DriverStationErrors::ReportError and ReportWarning messages.

Parameters:

should_send – If false then messages will be suppressed.