Class DriverStationJNI
- See Also:
-
- "hal/DriverStation.h"
- "hal/FRCUsageReporting.h"
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.hal.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 intThe maximum number of POVs.static final intThe maximum number of joysticks.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(float[] axesArray, byte[] rawAxesArray, short[] povsArray, long[] buttonsAndMetadata) Get all joystick data.static voidgetControlWord(ControlWord controlWord) Gets the current control word of the driver station.static intgetJoystickAxes(byte joystickNum, float[] axesArray) Gets the axes of a specific joystick.static intgetJoystickAxesRaw(byte joystickNum, int[] rawAxesArray) Gets the axes of a specific joystick.static intgetJoystickAxisType(byte joystickNum, byte axis) Gets the type of a specific joystick axis.static intgetJoystickButtons(byte joystickNum, ByteBuffer count) Gets the buttons of a specific joystick.static intgetJoystickIsXbox(byte joystickNum) Gets whether a specific joystick is considered to be an XBox controller.static StringgetJoystickName(byte joystickNum) Gets the name of a joystick.static intgetJoystickPOVs(byte joystickNum, short[] povsArray) Gets the POVs of a specific joystick.static intgetJoystickType(byte joystickNum) Gets the type of joystick connected.static intgetMatchInfo(MatchInfoData info) Gets info about a specific match.static doubleReturns the approximate match time.static booleanGets if outputs are enabled by the control system.static intGets the current control word of the driver station.static voidSets the autonomous enabled flag in the DS.static voidSets the disabled flag in the DS.static voidSets the program starting flag in the DS.static voidSets the teleoperated enabled flag in the DS.static voidSets the test mode 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 voidreport(int resource, int instanceNumber) Report the usage of a resource of interest.static voidreport(int resource, int instanceNumber, int context) Report the usage of a resource of interest.static intReport the usage of a resource of interest.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 intsetJoystickOutputs(byte joystickNum, int outputs, int leftRumble, int rightRumble) Set joystick outputs.Methods inherited from class edu.wpi.first.hal.JNIWrapper
forceLoad, suppressUnused
-
Field Details
-
kUnknownAllianceStation
Unknown Alliance Station ID.- See Also:
-
kRed1AllianceStation
Red Alliance Station 1 ID.- See Also:
-
kRed2AllianceStation
Red Alliance Station 2 ID.- See Also:
-
kRed3AllianceStation
Red Alliance Station 3 ID.- See Also:
-
kBlue1AllianceStation
Blue Alliance Station 1 ID.- See Also:
-
kBlue2AllianceStation
Blue Alliance Station 2 ID.- See Also:
-
kBlue3AllianceStation
Blue Alliance Station 3 ID.- See Also:
-
kMaxJoystickAxes
The maximum number of axes.- See Also:
-
kMaxJoystickPOVs
The maximum number of POVs.- See Also:
-
kMaxJoysticks
The maximum number of joysticks.- 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:
-
- "HAL_ObserveUserProgramStarting"
-
observeUserProgramDisabled
Sets the disabled flag in 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.
- See Also:
-
- "HAL_ObserveUserProgramDisabled"
-
observeUserProgramAutonomous
Sets the autonomous enabled flag in 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.
- See Also:
-
- "HAL_ObserveUserProgramAutonomous"
-
observeUserProgramTeleop
Sets the teleoperated enabled flag in 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.
- See Also:
-
- "HAL_ObserveUserProgramTeleop"
-
observeUserProgramTest
Sets the test mode flag in 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.
- See Also:
-
- "HAL_ObserveUserProgramTest"
-
report
Report the usage of a resource of interest.Original signature:
uint32_t report(tResourceType, uint8_t, uint8_t, const char*)- Parameters:
resource- one of the values in the tResourceType above.instanceNumber- an index that identifies the resource instance.- See Also:
-
- "HAL_Report"
-
report
Report the usage of a resource of interest.Original signature:
uint32_t report(tResourceType, uint8_t, uint8_t, const char*)- Parameters:
resource- one of the values in the tResourceType above.instanceNumber- an index that identifies the resource instance.context- an optional additional context number for some cases (such as module number). Set to 0 to omit.- See Also:
-
- "HAL_Report"
-
report
Report the usage of a resource of interest.Original signature:
uint32_t report(tResourceType, uint8_t, uint8_t, const char*)- Parameters:
resource- one of the values in the tResourceType above.instanceNumber- an index that identifies the resource instance.context- an optional additional context number for some cases (such as module number). Set to 0 to omit.feature- a string to be included describing features in use on a specific resource. Setting the same resource more than once allows you to change the feature string.- Returns:
- the index of the added value in NetComm
- See Also:
-
- "HAL_Report"
-
nativeGetControlWord
Gets the current control word of the driver station.The control word contains the robot state.
- Returns:
- the control word
- See Also:
-
- "HAL_GetControlWord"
for a version easier to parse
-
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:
-
- "HAL_GetControlWord"
-
getAllianceStation
Gets the current alliance station ID.- Returns:
- the alliance station ID as AllianceStationID
- See Also:
-
- "HAL_GetAllianceStation"
-
getJoystickAxes
Gets the axes of a specific joystick.- Parameters:
joystickNum- the joystick numberaxesArray- the axes values- Returns:
- number of joystick axes, or 0 for error
- See Also:
-
- "HAL_GetJoystickAxes"
-
getJoystickAxesRaw
Gets the axes of a specific joystick.- Parameters:
joystickNum- the joystick numberrawAxesArray- the raw int axes values (0-255)- Returns:
- number of joystick axes, or 0 for error
- See Also:
-
- "HAL_GetJoystickAxes"
-
getJoystickPOVs
Gets the POVs of a specific joystick.- Parameters:
joystickNum- the joystick numberpovsArray- the POV values- Returns:
- number of POVs, or 0 for error
- See Also:
-
- "HAL_GetJoystickPOVs"
-
getJoystickButtons
Gets the buttons of a specific joystick.- Parameters:
joystickNum- the joystick numbercount- the count of buttons- Returns:
- The joystick button values
- See Also:
-
- "HAL_GetJoystickButtons"
-
getAllJoystickData
public static void getAllJoystickData(float[] axesArray, byte[] rawAxesArray, short[] povsArray, long[] buttonsAndMetadata) Get all joystick data.- Parameters:
axesArray- all joystick axesrawAxesArray- all joystick axes as intpovsArray- all povsbuttonsAndMetadata- array of long joystick axes count, long joystick povs count, long joystick buttons count, long joystick buttons values- See Also:
-
- "HAL_GetAllJoystickData"
-
setJoystickOutputs
public static int setJoystickOutputs(byte joystickNum, int outputs, int leftRumble, int rightRumble) Set joystick outputs.- Parameters:
joystickNum- the joystick numberoutputs- bitmask of outputs, 1 for on 0 for offleftRumble- the left rumble value (0-FFFF)rightRumble- the right rumble value (0-FFFF)- Returns:
- the error code, or 0 for success
- See Also:
-
- "HAL_SetJoystickOutputs"
-
getJoystickIsXbox
Gets whether a specific joystick is considered to be an XBox controller.- Parameters:
joystickNum- the joystick number- Returns:
- 1 if xbox, 0 otherwise
- See Also:
-
- "HAL_GetJoystickIsXbox"
-
getJoystickType
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:
-
- "HAL_GetJoystickType"
-
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:
-
- "HAL_GetJoystickName"
-
getJoystickAxisType
Gets the type of a specific joystick axis.This is device specific, and different depending on what system input type the joystick uses.
- Parameters:
joystickNum- the joystick numberaxis- the axis number- Returns:
- the enumerated axis type
- See Also:
-
- "HAL_GetJoystickAxisType"
-
getMatchTime
Returns 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).
The Practice Match function of the DS approximates the behavior seen on the field.
- Returns:
- time remaining in current match period (auto or teleop)
- See Also:
-
- "HAL_GetMatchTime"
-
getMatchInfo
Gets info about a specific match.- Parameters:
info- the match info to populate- Returns:
- the error code, or 0 for success
- See Also:
-
- "HAL_GetMatchInfo"
-
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:
-
- "HAL_SendError"
-
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:
-
- "HAL_RefreshDSData"
-
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
-