Class DriverStationJNI
public class DriverStationJNI extends JNIWrapper
- See Also:
- "hal/DriverStation.h", "hal/FRCUsageReporting.h"
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description static int
kBlue1AllianceStation
static int
kBlue2AllianceStation
static int
kBlue3AllianceStation
static int
kMaxJoystickAxes
static int
kMaxJoystickPOVs
static int
kMaxJoysticks
static int
kRed1AllianceStation
static int
kRed2AllianceStation
static int
kRed3AllianceStation
-
Method Summary
Modifier and Type Method Description static AllianceStationID
getAllianceStation()
Gets the current alliance station ID.static void
getAllJoystickData(float[] axesArray, byte[] rawAxesArray, short[] povsArray, long[] buttonsAndMetadata)
Get all joystick data.static void
getControlWord(ControlWord controlWord)
Gets the current control word of the driver station.static int
getJoystickAxes(byte joystickNum, float[] axesArray)
Gets the axes of a specific joystick.static int
getJoystickAxesRaw(byte joystickNum, int[] rawAxesArray)
Gets the axes of a specific joystick.static int
getJoystickAxisType(byte joystickNum, byte axis)
Gets the type of a specific joystick axis.static int
getJoystickButtons(byte joystickNum, ByteBuffer count)
Gets the buttons of a specific joystick.static int
getJoystickIsXbox(byte joystickNum)
Gets whether a specific joystick is considered to be an XBox controller.static String
getJoystickName(byte joystickNum)
Gets the name of a joystick.static int
getJoystickPOVs(byte joystickNum, short[] povsArray)
Gets the POVs of a specific joystick.static int
getJoystickType(byte joystickNum)
Gets the type of joystick connected.static int
getMatchInfo(MatchInfoData info)
Gets info about a specific match.static double
getMatchTime()
Returns the approximate match time.static boolean
getOutputsActive()
Gets if outputs are enabled by the control system.static int
nativeGetControlWord()
Gets the current control word of the driver station.static void
observeUserProgramAutonomous()
Sets the autonomous enabled flag in the DS.static void
observeUserProgramDisabled()
Sets the disabled flag in the DS.static void
observeUserProgramStarting()
Sets the program starting flag in the DS.static void
observeUserProgramTeleop()
Sets the teleoperated enabled flag in the DS.static void
observeUserProgramTest()
Sets the test mode flag in the DS.static void
provideNewDataEventHandle(int handle)
static boolean
refreshDSData()
Refresh the DS control word.static void
removeNewDataEventHandle(int handle)
static void
report(int resource, int instanceNumber)
Report the usage of a resource of interest.static void
report(int resource, int instanceNumber, int context)
Report the usage of a resource of interest.static int
report(int resource, int instanceNumber, int context, String feature)
Report the usage of a resource of interest.static int
sendConsoleLine(String line)
Sends a line to the driver station console.static int
sendError(boolean isError, int errorCode, boolean isLVCode, String details, String location, String callStack, boolean printMsg)
Sends an error to the driver station.static int
setJoystickOutputs(byte joystickNum, int outputs, short leftRumble, short rightRumble)
Set joystick outputs.
-
Field Details
-
kRed1AllianceStation
- See Also:
- Constant Field Values
-
kRed2AllianceStation
- See Also:
- Constant Field Values
-
kRed3AllianceStation
- See Also:
- Constant Field Values
-
kBlue1AllianceStation
- See Also:
- Constant Field Values
-
kBlue2AllianceStation
- See Also:
- Constant Field Values
-
kBlue3AllianceStation
- See Also:
- Constant Field Values
-
kMaxJoystickAxes
- See Also:
- Constant Field Values
-
kMaxJoystickPOVs
- See Also:
- Constant Field Values
-
kMaxJoysticks
- See Also:
- Constant Field Values
-
-
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 jostick buttons count, long joystick buttons values- See Also:
- "HAL_GetAllJoystickData"
-
setJoystickOutputs
public static int setJoystickOutputs(byte joystickNum, int outputs, short leftRumble, short 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
-
removeNewDataEventHandle
-
getOutputsActive
Gets if outputs are enabled by the control system.- Returns:
- true if outputs are enabled
-