Package edu.wpi.first.wpilibj.simulation
Class DriverStationSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.DriverStationSim
public final class DriverStationSim extends Object
Class to control a simulated driver station.
-
Method Summary
Modifier and Type Method Description static AllianceStationIDgetAllianceStationId()Get the alliance station ID (color + number).static booleangetAutonomous()Check if the DS is in autonomous.static booleangetDsAttached()Check if the DS is attached.static booleangetEnabled()Check if the DS is enabled.static booleangetEStop()Check if eStop has been activated.static booleangetFmsAttached()Check if the FMS is connected.static longgetJoystickOutputs(int stick)Gets the joystick outputs.static intgetJoystickRumble(int stick, int rumbleNum)Gets the joystick rumble.static doublegetMatchTime()Get the current value of the match timer.static booleangetTest()Check if the DS is in test.static voidnotifyNewData()Updates 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 CallbackStoreregisterAutonomousCallback(NotifyCallback callback, boolean initialNotify)Register a callback on whether the DS is in autonomous mode.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 CallbackStoreregisterTestCallback(NotifyCallback callback, boolean initialNotify)Register a callback on whether the DS is in test mode.static voidresetData()Reset all simulation data for the Driver Station.static voidsetAllianceStationId(AllianceStationID allianceStationId)Change the alliance station.static voidsetAutonomous(boolean autonomous)Change whether the DS is in autonomous.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 voidsetGameSpecificMessage(String message)Sets the game specific message.static voidsetJoystickAxis(int stick, int axis, double value)Gets the value of the axis on a joystick.static voidsetJoystickAxisCount(int stick, int count)Sets the number of axes for a joystick.static voidsetJoystickAxisType(int stick, int axis, int type)Sets the types of Axes for a joystick.static voidsetJoystickButton(int stick, int button, boolean state)Sets the state of one joystick button.static voidsetJoystickButtonCount(int stick, int count)Sets the number of buttons for a joystick.static voidsetJoystickButtons(int stick, int buttons)Sets the state of all the buttons on a joystick.static voidsetJoystickIsXbox(int stick, boolean isXbox)Sets the value of isXbox for a joystick.static voidsetJoystickName(int stick, String name)Sets the name of a joystick.static voidsetJoystickPOV(int stick, int pov, int value)Gets the state of a POV on a joystick.static voidsetJoystickPOVCount(int stick, int count)Sets the number of POVs for a joystick.static voidsetJoystickType(int stick, int type)Sets the value of type for a joystick.static voidsetMatchNumber(int matchNumber)Sets the match number.static voidsetMatchTime(double matchTime)Sets the match timer.static voidsetMatchType(DriverStation.MatchType type)Sets the match type.static voidsetReplayNumber(int replayNumber)Sets the replay number.static voidsetSendConsoleLine(boolean shouldSend)Sets suppression of DriverStation.sendConsoleLine messages.static voidsetSendError(boolean shouldSend)Sets suppression of DriverStation.reportError and reportWarning messages.static voidsetTest(boolean test)Change whether the DS is in test.
-
Method Details
-
registerEnabledCallback
public static CallbackStore registerEnabledCallback(NotifyCallback callback, boolean initialNotify)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. Save a reference to this object so GC doesn't cancel the callback.
-
getEnabled
Check if the DS is enabled.- Returns:
- true if enabled
-
setEnabled
Change whether the DS is enabled.- Parameters:
enabled- the new value
-
registerAutonomousCallback
public static CallbackStore registerAutonomousCallback(NotifyCallback callback, boolean initialNotify)Register a callback on whether the DS is in autonomous mode.- Parameters:
callback- the callback that will be called on autonomous mode entrance/exitinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getAutonomous
Check if the DS is in autonomous.- Returns:
- true if autonomous
-
setAutonomous
Change whether the DS is in autonomous.- Parameters:
autonomous- the new value
-
registerTestCallback
Register a callback on whether the DS is in test mode.- Parameters:
callback- the callback that will be called whenever the test mode is entered or leftinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getTest
Check if the DS is in test.- Returns:
- true if test
-
setTest
Change whether the DS is in test.- Parameters:
test- 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. Save a reference to this object so GC doesn't cancel the callback.
-
getEStop
Check if eStop has been activated.- Returns:
- true if eStopped
-
setEStop
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. Save a reference to this object so GC doesn't cancel the callback.
-
getFmsAttached
Check if the FMS is connected.- Returns:
- true if FMS is connected
-
setFmsAttached
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. Save a reference to this object so GC doesn't cancel the callback.
-
getDsAttached
Check if the DS is attached.- Returns:
- true if attached
-
setDsAttached
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. Save a reference to this object so GC doesn't cancel the 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. Save a reference to this object so GC doesn't cancel the callback.
-
getMatchTime
Get the current value of the match timer.- Returns:
- the current match time
-
setMatchTime
Sets the match timer.- Parameters:
matchTime- the new match time
-
notifyNewData
Updates DriverStation data so that new values are visible to the user program. -
setSendError
Sets suppression of DriverStation.reportError and reportWarning messages.- Parameters:
shouldSend- If false then messages will be suppressed.
-
setSendConsoleLine
Sets suppression of DriverStation.sendConsoleLine messages.- Parameters:
shouldSend- If false then messages will be suppressed.
-
getJoystickOutputs
Gets the joystick outputs.- Parameters:
stick- The joystick number- Returns:
- The joystick outputs
-
getJoystickRumble
Gets the joystick rumble.- Parameters:
stick- The joystick numberrumbleNum- Rumble to get (0=left, 1=right)- Returns:
- The joystick rumble value
-
setJoystickButton
Sets the state of one joystick button. Button indexes begin at 1.- Parameters:
stick- The joystick numberbutton- The button index, beginning at 1state- The state of the joystick button
-
setJoystickAxis
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 in degrees, or -1 for not pressed
-
setJoystickButtons
Sets the state of all the buttons on a joystick.- Parameters:
stick- The joystick numberbuttons- The bitmap state of the buttons on the joystick
-
setJoystickAxisCount
Sets the number of axes for a joystick.- Parameters:
stick- The joystick numbercount- The number of axes on the indicated joystick
-
setJoystickPOVCount
Sets the number of POVs for a joystick.- Parameters:
stick- The joystick numbercount- The number of POVs on the indicated joystick
-
setJoystickButtonCount
Sets the number of buttons for a joystick.- Parameters:
stick- The joystick numbercount- The number of buttons on the indicated joystick
-
setJoystickIsXbox
Sets the value of isXbox for a joystick.- Parameters:
stick- The joystick numberisXbox- The value of isXbox
-
setJoystickType
Sets the value of type for a joystick.- Parameters:
stick- The joystick numbertype- The value of type
-
setJoystickName
Sets the name of a joystick.- Parameters:
stick- The joystick numbername- The value of name
-
setJoystickAxisType
Sets the types of Axes for a joystick.- Parameters:
stick- The joystick numberaxis- The target axistype- The type of axis
-
setGameSpecificMessage
Sets the game specific message.- Parameters:
message- the game specific message
-
setEventName
Sets the event name.- Parameters:
name- the event name
-
setMatchType
Sets the match type.- Parameters:
type- the match type
-
setMatchNumber
Sets the match number.- Parameters:
matchNumber- the match number
-
setReplayNumber
Sets the replay number.- Parameters:
replayNumber- the replay number
-
resetData
Reset all simulation data for the Driver Station.
-