Class DriverStationJNI
-
Nested Class Summary
Nested classes/interfaces inherited from class JNIWrapper
JNIWrapper.Helper -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBlue Alliance Station 1 ID.static final intBlue Alliance Station 2 ID.static final intBlue Alliance Station 3 ID.static final intThe maximum number of axes.static final intstatic final intThe maximum number of POVs.static final intThe maximum number of joysticks.static final intThe maximum number of fingers per touchpad.static final intThe maximum number of touchpads.static final intRed Alliance Station 1 ID.static final intRed Alliance Station 2 ID.static final intRed Alliance Station 3 ID.static final intUnknown Alliance Station ID. -
Method Summary
Modifier and TypeMethodDescriptionstatic AllianceStationIDGets the current alliance station ID.static voidgetAllJoystickData(int stick, float[] axesArray, short[] rawAxesArray, byte[] povsArray, float[] touchpadFingersArray, long[] buttonsAndMetadata) Get all joystick data.static voidgetControlWord(ControlWord controlWord) Gets the current control word of the driver station.static StringgetGameData(String gameData) Gets the game-specific data for the current match.static intgetJoystickGamepadType(byte joystickNum) Gets the type of joystick connected.static intgetJoystickIsGamepad(byte joystickNum) Gets whether a specific joystick is considered to be an Gamepad.static StringgetJoystickName(byte joystickNum) Gets the name of a joystick.static intgetJoystickSupportedOutputs(byte joystickNum) Gets the supported outputs of a specific joystick.static intgetMatchInfo(MatchInfoData info) Gets info about a specific match.static doubleReturn the approximate match time.static booleanGets if outputs are enabled by the control system.static voidgetUncachedControlWord(ControlWord controlWord) Gets the current control word of the driver station.static longGets the current control word of the driver station.static longGets the current control word of the driver station.static voidobserveUserProgram(long word) Sets the control state returned to the DS.static voidSets the program starting flag in the DS.static voidprovideNewDataEventHandle(int handle) Adds an event handle to be signalled when new data arrives.static booleanRefresh the DS control word.static voidremoveNewDataEventHandle(int handle) Removes the event handle from being signalled when new data arrives.static intsendConsoleLine(String line) Sends a line to the driver station console.static intsendError(boolean isError, int errorCode, boolean isLVCode, String details, String location, String callStack, boolean printMsg) Sends an error to the driver station.static intsetJoystickLeds(byte joystickNum, int leds) Sets the LEDs on a specific joystick.static intsetJoystickRumble(byte joystickNum, int leftRumble, int rightRumble, int leftTriggerRumble, int rightTriggerRumble) Set joystick rumbles.static voidsetOpModeOptions(OpModeOption[] options) Sets operating mode options.Methods inherited from class JNIWrapper
forceLoad, suppressUnused
-
Field Details
-
kUnknownAllianceStation
-
kRed1AllianceStation
-
kRed2AllianceStation
-
kRed3AllianceStation
-
kBlue1AllianceStation
-
kBlue2AllianceStation
-
kBlue3AllianceStation
-
kMaxJoystickAxes
-
kMaxJoystickButtons
- See Also:
-
kMaxJoystickPOVs
-
kMaxJoysticks
-
kMaxJoystickTouchpads
-
kMaxJoystickTouchpadFingers
The maximum number of fingers per touchpad.- See Also:
-
-
Method Details
-
observeUserProgramStarting
Sets the program starting flag in the DS.This is what changes the DS to showing robot code ready.
- See Also:
-
observeUserProgram
Sets the control state returned to the DS.This is used for the DS to ensure the robot is properly responding to its state request. Ensure this gets called about every 50ms, or the robot will be disabled by the DS.
- Parameters:
word- control word returned by nativeGetControlWord()
-
nativeGetControlWord
Gets the current control word of the driver station.The control word contains the robot state.
- Returns:
- the control word
- See Also:
-
getControlWord
Gets the current control word of the driver station.The control work contains the robot state.
- Parameters:
controlWord- the ControlWord to update- See Also:
-
nativeGetUncachedControlWord
Gets the current control word of the driver station. Unlike nativeGetControlWord, this function gets the latest value rather than using the value cached by refreshDSData().The control word contains the robot state.
- Returns:
- the control word
- See Also:
-
getUncachedControlWord
Gets the current control word of the driver station. Unlike getControlWord, this function gets the latest value rather than using the value cached by refreshDSData().The control work contains the robot state.
- Parameters:
controlWord- the ControlWord to update- See Also:
-
setOpModeOptions
Sets operating mode options.- Parameters:
options- operating mode options
-
getAllianceStation
Gets the current alliance station ID.- Returns:
- the alliance station ID as AllianceStationID
- See Also:
-
getAllJoystickData
public static void getAllJoystickData(int stick, float[] axesArray, short[] rawAxesArray, byte[] povsArray, float[] touchpadFingersArray, long[] buttonsAndMetadata) Get all joystick data.- Parameters:
stick- the joystick to grabaxesArray- all joystick axesrawAxesArray- all joystick axes as intpovsArray- all povstouchpadFingersArray- all touchpad fingersbuttonsAndMetadata- array of long joystick axes count, long joystick povs count, long joystick buttons count, long joystick buttons values, long joystick touchpad count, long pad 0 finger0 down 0x1, finger1 down 0x2, fingerCount 0xC, long pad 1 finger0 down 0x1, finger1 down 0x2, fingerCount 0xC- See Also:
-
setJoystickRumble
public static int setJoystickRumble(byte joystickNum, int leftRumble, int rightRumble, int leftTriggerRumble, int rightTriggerRumble) Set joystick rumbles.- Parameters:
joystickNum- the joystick numberleftRumble- the left rumble value (0-FFFF)rightRumble- the right rumble value (0-FFFF)leftTriggerRumble- the left trigger rumble value (0-FFFF)rightTriggerRumble- the right trigger rumble value (0-FFFF)- Returns:
- the error code, or 0 for success
- See Also:
-
setJoystickLeds
Sets the LEDs on a specific joystick.- Parameters:
joystickNum- the joystick numberleds- the rgb led color value (0xRRGGBB)- Returns:
- the error code, or 0 for success
- See Also:
-
getJoystickIsGamepad
Gets whether a specific joystick is considered to be an Gamepad.- Parameters:
joystickNum- the joystick number- Returns:
- 1 if gamepad, 0 otherwise
- See Also:
-
getJoystickGamepadType
Gets the type of joystick connected.This is device specific, and different depending on what system input type the joystick uses.
- Parameters:
joystickNum- the joystick number- Returns:
- the enumerated joystick type
- See Also:
-
getJoystickSupportedOutputs
Gets the supported outputs of a specific joystick.- Parameters:
joystickNum- the joystick number- Returns:
- bitmask of supported outputs
- See Also:
-
getJoystickName
Gets the name of a joystick.The returned array must be freed with HAL_FreeJoystickName.
- Parameters:
joystickNum- the joystick number- Returns:
- the joystick name
- See Also:
-
getMatchTime
Return the approximate match time. The FMS does not send an 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 dispute ref calls or guarantee that a function will trigger before the match ends).When connected to the real field, this number only changes in full integer increments, and always counts down.
When the DS is in practice mode, this number is a floating point number, and counts down.
When the DS is in teleop or autonomous mode, this number returns -1.0.
Simulation matches DS behavior without an FMS connected.
- Returns:
- time remaining in current match period (auto or teleop)
- See Also:
-
getMatchInfo
Gets info about a specific match.- Parameters:
info- the match info to populate- Returns:
- the error code, or 0 for success
- See Also:
-
getGameData
Gets the game-specific data for the current match.- Parameters:
gameData- The existing game data string.- Returns:
- the game-specific data
- See Also:
-
sendError
public static int sendError(boolean isError, int errorCode, boolean isLVCode, String details, String location, String callStack, boolean printMsg) Sends an error to the driver station.- Parameters:
isError- true for error, false for warningerrorCode- the error codeisLVCode- true for a LV error code, false for a standard error codedetails- the details of the errorlocation- the file location of the errorcallStack- the callstack of the errorprintMsg- true to print the error message to stdout as well as to the DS- Returns:
- the error code, or 0 for success
- See Also:
-
sendConsoleLine
Sends a line to the driver station console.- Parameters:
line- the line to send- Returns:
- the error code, or 0 for success
-
refreshDSData
Refresh the DS control word.- Returns:
- true if updated
- See Also:
-
provideNewDataEventHandle
Adds an event handle to be signalled when new data arrives.- Parameters:
handle- the event handle to be signalled
-
removeNewDataEventHandle
Removes the event handle from being signalled when new data arrives.- Parameters:
handle- the event handle to remove
-
getOutputsActive
Gets if outputs are enabled by the control system.- Returns:
- true if outputs are enabled
-