Class DriverStationSim
java.lang.Object
org.wpilib.simulation.DriverStationSim
Class to control a simulated driver station.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AllianceStationIDGet the alliance station ID (color + number).static booleanCheck if the DS is attached.static booleanCheck if the DS is enabled.static booleangetEStop()Check if eStop has been activated.static booleanCheck if the FMS is connected.static intgetJoystickLeds(int stick) Gets the joystick outputs.static intgetJoystickRumble(int stick, int rumbleNum) Gets the joystick rumble.static doubleGet the current value of the match timer.static longGets the opmode.static OpModeOption[]Gets the list of opmode options.static RobotModeGets the robot mode set by the DS.static voidUpdates DriverStation data so that new values are visible to the user program.static CallbackStoreregisterAllianceStationIdCallback(NotifyCallback callback, boolean initialNotify) Register a callback on the alliance station ID.static CallbackStoreregisterDsAttachedCallback(NotifyCallback callback, boolean initialNotify) Register a callback on whether the DS is connected.static CallbackStoreregisterEnabledCallback(NotifyCallback callback, boolean initialNotify) Register a callback on whether the DS is enabled.static CallbackStoreregisterEStopCallback(NotifyCallback callback, boolean initialNotify) Register a callback on the eStop state.static CallbackStoreregisterFmsAttachedCallback(NotifyCallback callback, boolean initialNotify) Register a callback on whether the FMS is connected.static CallbackStoreregisterMatchTimeCallback(NotifyCallback callback, boolean initialNotify) Register a callback on match time.static CallbackStoreregisterOpModeCallback(NotifyCallback callback, boolean initialNotify) Register a callback on opmode changes.static CallbackStoreregisterOpModeOptionsCallback(BiConsumer<String, OpModeOption[]> callback, boolean initialNotify) Register a callback on opmode options changes.static CallbackStoreregisterRobotModeCallback(NotifyCallback callback, boolean initialNotify) Register a callback on DS robot mode changes.static voidReset all simulation data for the Driver Station.static voidsetAllianceStationId(AllianceStationID allianceStationId) Change the alliance station.static voidsetDsAttached(boolean dsAttached) Change whether the DS is attached.static voidsetEnabled(boolean enabled) Change whether the DS is enabled.static voidsetEStop(boolean eStop) Set whether eStop is active.static voidsetEventName(String name) Sets the event name.static voidsetFmsAttached(boolean fmsAttached) Change whether the FMS is connected.static voidsetGameData(String message) Sets the game specific message.static voidsetJoystickAxesAvailable(int stick, int count) Sets the number of axes for a joystick.static voidsetJoystickAxesMaximumIndex(int stick, int maximumIndex) Sets the maximum index that an axis is available at.static voidsetJoystickAxis(int stick, int axis, double value) Gets the value of the axis on a joystick.static voidsetJoystickButton(int stick, int button, boolean state) Sets the state of one joystick button.static voidsetJoystickButtonsAvailable(int stick, long count) Sets the number of buttons for a joystick.static voidsetJoystickButtonsMaximumIndex(int stick, int maximumIndex) Sets the maximum index that a button is available at.static voidsetJoystickGamepadType(int stick, int type) Sets the value of type for a joystick.static voidsetJoystickIsGamepad(int stick, boolean isGamepad) Sets the value of isGamepad for a joystick.static voidsetJoystickName(int stick, String name) Sets the name of a joystick.static voidsetJoystickPOV(int stick, int pov, POVDirection value) Gets the state of a POV on a joystick.static voidsetJoystickPOVsAvailable(int stick, int count) Sets the number of POVs for a joystick.static voidsetJoystickPOVsMaximumIndex(int stick, int maximumIndex) Sets the maximum index that a pov is available at.static voidsetJoystickSupportedOutputs(int stick, int supportedOutputs) Sets the value of supported outputs for a joystick.static voidsetMatchNumber(int matchNumber) Sets the match number.static voidsetMatchTime(double matchTime) Sets the match timer.static voidsetMatchType(MatchType type) Sets the match type.static voidsetOpMode(long opmode) Change the opmode.static voidsetReplayNumber(int replayNumber) Sets the replay number.static voidsetRobotMode(RobotMode mode) Change the robot mode set by the DS.static voidsetSendConsoleLine(boolean shouldSend) Sets suppression of DriverStation.sendConsoleLine messages.static voidsetSendError(boolean shouldSend) Sets suppression of DriverStation.reportError and reportWarning messages.
-
Method Details
-
registerEnabledCallback
Register a callback on whether the DS is enabled.- Parameters:
callback- the callback that will be called whenever the enabled state is changedinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getEnabled
public static boolean getEnabled()Check if the DS is enabled.- Returns:
- true if enabled
-
setEnabled
public static void setEnabled(boolean enabled) Change whether the DS is enabled.- Parameters:
enabled- the new value
-
registerRobotModeCallback
public static CallbackStore registerRobotModeCallback(NotifyCallback callback, boolean initialNotify) Register a callback on DS robot mode changes.- Parameters:
callback- the callback that will be called when the robot mode changesinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getRobotMode
-
setRobotMode
Change the robot mode set by the DS.- Parameters:
mode- the new value
-
registerEStopCallback
Register a callback on the eStop state.- Parameters:
callback- the callback that will be called whenever the eStop state changesinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getEStop
public static boolean getEStop()Check if eStop has been activated.- Returns:
- true if eStopped
-
setEStop
public static void setEStop(boolean eStop) Set whether eStop is active.- Parameters:
eStop- true to activate
-
registerFmsAttachedCallback
public static CallbackStore registerFmsAttachedCallback(NotifyCallback callback, boolean initialNotify) Register a callback on whether the FMS is connected.- Parameters:
callback- the callback that will be called whenever the FMS connection changesinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getFmsAttached
public static boolean getFmsAttached()Check if the FMS is connected.- Returns:
- true if FMS is connected
-
setFmsAttached
public static void setFmsAttached(boolean fmsAttached) Change whether the FMS is connected.- Parameters:
fmsAttached- the new value
-
registerDsAttachedCallback
public static CallbackStore registerDsAttachedCallback(NotifyCallback callback, boolean initialNotify) Register a callback on whether the DS is connected.- Parameters:
callback- the callback that will be called whenever the DS connection changesinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getDsAttached
public static boolean getDsAttached()Check if the DS is attached.- Returns:
- true if attached
-
setDsAttached
public static void setDsAttached(boolean dsAttached) Change whether the DS is attached.- Parameters:
dsAttached- the new value
-
registerAllianceStationIdCallback
public static CallbackStore registerAllianceStationIdCallback(NotifyCallback callback, boolean initialNotify) Register a callback on the alliance station ID.- Parameters:
callback- the callback that will be called whenever the alliance station changesinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getAllianceStationId
Get the alliance station ID (color + number).- Returns:
- the alliance station color and number
-
setAllianceStationId
Change the alliance station.- Parameters:
allianceStationId- the new alliance station
-
registerMatchTimeCallback
public static CallbackStore registerMatchTimeCallback(NotifyCallback callback, boolean initialNotify) Register a callback on match time.- Parameters:
callback- the callback that will be called whenever match time changesinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getMatchTime
public static double getMatchTime()Get the current value of the match timer.- Returns:
- the current match time
-
setMatchTime
public static void setMatchTime(double matchTime) Sets the match timer.- Parameters:
matchTime- the new match time
-
registerOpModeCallback
Register a callback on opmode changes.- Parameters:
callback- the callback that will be called when the opmode changesinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getOpMode
public static long getOpMode()Gets the opmode.- Returns:
- opmode
-
setOpMode
public static void setOpMode(long opmode) Change the opmode.- Parameters:
opmode- the new value
-
registerOpModeOptionsCallback
public static CallbackStore registerOpModeOptionsCallback(BiConsumer<String, OpModeOption[]> callback, boolean initialNotify) Register a callback on opmode options changes.- Parameters:
callback- the callback that will be called when the list of opmodes changesinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getOpModeOptions
Gets the list of opmode options.- Returns:
- opmodes list
-
notifyNewData
public static void notifyNewData()Updates DriverStation data so that new values are visible to the user program. -
setSendError
public static void setSendError(boolean shouldSend) Sets suppression of DriverStation.reportError and reportWarning messages.- Parameters:
shouldSend- If false then messages will be suppressed.
-
setSendConsoleLine
public static void setSendConsoleLine(boolean shouldSend) Sets suppression of DriverStation.sendConsoleLine messages.- Parameters:
shouldSend- If false then messages will be suppressed.
-
getJoystickLeds
public static int getJoystickLeds(int stick) Gets the joystick outputs.- Parameters:
stick- The joystick number- Returns:
- The joystick outputs
-
getJoystickRumble
public static int getJoystickRumble(int stick, int rumbleNum) Gets the joystick rumble.- Parameters:
stick- The joystick numberrumbleNum- Rumble to get (0=left, 1=right, 2=left trigger, 3=right trigger)- Returns:
- The joystick rumble value
-
setJoystickButton
public static void setJoystickButton(int stick, int button, boolean state) Sets the state of one joystick button. Button indexes begin at 0.- Parameters:
stick- The joystick numberbutton- The button index, beginning at 0state- The state of the joystick button
-
setJoystickAxis
public static void setJoystickAxis(int stick, int axis, double value) Gets the value of the axis on a joystick.- Parameters:
stick- The joystick numberaxis- The analog axis numbervalue- The value of the axis on the joystick
-
setJoystickPOV
Gets the state of a POV on a joystick.- Parameters:
stick- The joystick numberpov- The POV numbervalue- the angle of the POV
-
setJoystickAxesMaximumIndex
public static void setJoystickAxesMaximumIndex(int stick, int maximumIndex) Sets the maximum index that an axis is available at.- Parameters:
stick- The joystick numbermaximumIndex- The maximum index an axis is available at.
-
setJoystickAxesAvailable
public static void setJoystickAxesAvailable(int stick, int count) Sets the number of axes for a joystick.- Parameters:
stick- The joystick numbercount- The number of axes on the indicated joystick
-
setJoystickPOVsMaximumIndex
public static void setJoystickPOVsMaximumIndex(int stick, int maximumIndex) Sets the maximum index that a pov is available at.- Parameters:
stick- The joystick numbermaximumIndex- The maximum index a pov is available at.
-
setJoystickPOVsAvailable
public static void setJoystickPOVsAvailable(int stick, int count) Sets the number of POVs for a joystick.- Parameters:
stick- The joystick numbercount- The number of POVs on the indicated joystick
-
setJoystickButtonsMaximumIndex
public static void setJoystickButtonsMaximumIndex(int stick, int maximumIndex) Sets the maximum index that a button is available at.- Parameters:
stick- The joystick numbermaximumIndex- The maximum index a button is available at.
-
setJoystickButtonsAvailable
public static void setJoystickButtonsAvailable(int stick, long count) Sets the number of buttons for a joystick.- Parameters:
stick- The joystick numbercount- The number of buttons on the indicated joystick
-
setJoystickIsGamepad
public static void setJoystickIsGamepad(int stick, boolean isGamepad) Sets the value of isGamepad for a joystick.- Parameters:
stick- The joystick numberisGamepad- The value of isGamepad
-
setJoystickGamepadType
public static void setJoystickGamepadType(int stick, int type) Sets the value of type for a joystick.- Parameters:
stick- The joystick numbertype- The value of type
-
setJoystickSupportedOutputs
public static void setJoystickSupportedOutputs(int stick, int supportedOutputs) Sets the value of supported outputs for a joystick.- Parameters:
stick- The joystick numbersupportedOutputs- The value of supported outputs
-
setJoystickName
Sets the name of a joystick.- Parameters:
stick- The joystick numbername- The value of name
-
setGameData
Sets the game specific message.- Parameters:
message- the game specific message
-
setEventName
-
setMatchType
Sets the match type.- Parameters:
type- the match type
-
setMatchNumber
public static void setMatchNumber(int matchNumber) Sets the match number.- Parameters:
matchNumber- the match number
-
setReplayNumber
public static void setReplayNumber(int replayNumber) Sets the replay number.- Parameters:
replayNumber- the replay number
-
resetData
public static void resetData()Reset all simulation data for the Driver Station.
-