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 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.static final intThe maximum number of axes.static final intstatic final intThe maximum number of POVs.static final intThe maximum number of fingers per touchpad.static final intThe maximum number of touchpads.static final intThe maximum number of joysticks. -
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, String details, String location, String callStack, boolean printMsg) Sends an error to the driver station.static intsendProgramCrash(String details, String location, String callStack) Sends a program crash 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.static voidwriteDisplayAnsi(String data) Writes ANSI text to the display.Methods inherited from class JNIWrapper
forceLoad, suppressUnused
-
Field Details
-
ALLIANCE_STATION_UNKNOWN
public static final int ALLIANCE_STATION_UNKNOWNUnknown Alliance Station ID.- See Also:
-
ALLIANCE_STATION_RED_1
public static final int ALLIANCE_STATION_RED_1Red Alliance Station 1 ID.- See Also:
-
ALLIANCE_STATION_RED_2
public static final int ALLIANCE_STATION_RED_2Red Alliance Station 2 ID.- See Also:
-
ALLIANCE_STATION_RED_3
public static final int ALLIANCE_STATION_RED_3Red Alliance Station 3 ID.- See Also:
-
ALLIANCE_STATION_BLUE_1
public static final int ALLIANCE_STATION_BLUE_1Blue Alliance Station 1 ID.- See Also:
-
ALLIANCE_STATION_BLUE_2
public static final int ALLIANCE_STATION_BLUE_2Blue Alliance Station 2 ID.- See Also:
-
ALLIANCE_STATION_BLUE_3
public static final int ALLIANCE_STATION_BLUE_3Blue Alliance Station 3 ID.- See Also:
-
MAX_JOYSTICK_AXES
public static final int MAX_JOYSTICK_AXESThe maximum number of axes.- See Also:
-
MAX_JOYSTICK_BUTTONS
public static final int MAX_JOYSTICK_BUTTONS- See Also:
-
MAX_JOYSTICK_POVS
public static final int MAX_JOYSTICK_POVSThe maximum number of POVs.- See Also:
-
MAX_JOYSTICKS
public static final int MAX_JOYSTICKSThe maximum number of joysticks.- See Also:
-
MAX_JOYSTICK_TOUCHPADS
public static final int MAX_JOYSTICK_TOUCHPADSThe maximum number of touchpads.- See Also:
-
MAX_JOYSTICK_TOUCHPAD_FINGERS
public static final int MAX_JOYSTICK_TOUCHPAD_FINGERSThe maximum number of fingers per touchpad.- See Also:
-
-
Method Details
-
observeUserProgramStarting
public static void observeUserProgramStarting()Sets the program starting flag in the DS.This is what changes the DS to showing robot code ready.
- See Also:
-
observeUserProgram
public static void observeUserProgram(long word) 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
public static long 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
public static long 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
public static int setJoystickLeds(byte joystickNum, int leds) 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
public static int getJoystickIsGamepad(byte joystickNum) 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
public static int getJoystickGamepadType(byte joystickNum) 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
public static int getJoystickSupportedOutputs(byte joystickNum) 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
public static double 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
-
sendError
public static int sendError(boolean isError, int errorCode, 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 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
-
sendProgramCrash
Sends a program crash to the driver station.- Parameters:
details- the details of the crashlocation- the file location of the crashcallStack- the callstack of the crash- Returns:
- the error code, or 0 for success
- See Also:
-
refreshDSData
public static boolean refreshDSData()Refresh the DS control word.- Returns:
- true if updated
- See Also:
-
provideNewDataEventHandle
public static void provideNewDataEventHandle(int handle) Adds an event handle to be signalled when new data arrives.- Parameters:
handle- the event handle to be signalled
-
removeNewDataEventHandle
public static void removeNewDataEventHandle(int handle) Removes the event handle from being signalled when new data arrives.- Parameters:
handle- the event handle to remove
-
getOutputsActive
public static boolean getOutputsActive()Gets if outputs are enabled by the control system.- Returns:
- true if outputs are enabled
-
writeDisplayAnsi
Writes ANSI text to the display.- Parameters:
data- the ANSI text to write- See Also:
-