Class DriverStationJNI

java.lang.Object
org.wpilib.hardware.hal.JNIWrapper
org.wpilib.hardware.hal.DriverStationJNI

public class DriverStationJNI extends JNIWrapper
Driver Station JNI Functions.
See Also:
  • "wpi/hal/DriverStation.h"
  • Field Details

  • 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:
      • "HAL_ObserveUserProgramStarting"
    • 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

      public static void getControlWord(ControlWord controlWord)
      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"
    • 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

      public static void getUncachedControlWord(ControlWord controlWord)
      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:
      • "HAL_GetControlWord"
    • setOpModeOptions

      public static void setOpModeOptions(OpModeOption[] options)
      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:
      • "HAL_GetAllianceStation"
    • 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 grab
      axesArray - all joystick axes
      rawAxesArray - all joystick axes as int
      povsArray - all povs
      touchpadFingersArray - all touchpad fingers
      buttonsAndMetadata - 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:
      • "HAL_GetAllJoystickData"
    • setJoystickRumble

      public static int setJoystickRumble(byte joystickNum, int leftRumble, int rightRumble, int leftTriggerRumble, int rightTriggerRumble)
      Set joystick rumbles.
      Parameters:
      joystickNum - the joystick number
      leftRumble - 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:
      • "HAL_SetJoystickRumble"
    • setJoystickLeds

      public static int setJoystickLeds(byte joystickNum, int leds)
      Sets the LEDs on a specific joystick.
      Parameters:
      joystickNum - the joystick number
      leds - the rgb led color value (0xRRGGBB)
      Returns:
      the error code, or 0 for success
      See Also:
      • "HAL_SetJoystickLeds"
    • 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:
      • "HAL_GetJoystickIsGamepad"
    • 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:
      • "HAL_GetJoystickGamepadType"
    • 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:
      • "HAL_GetJoystickSupportedOutputs"
    • getJoystickName

      public static String getJoystickName(byte joystickNum)
      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"
    • 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:
      • "HAL_GetMatchTime"
    • getMatchInfo

      public static int getMatchInfo(MatchInfoData info)
      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"
    • getGameData

      public static String getGameData(String gameData)
      Gets the game-specific data for the current match.
      Parameters:
      gameData - The existing game data string.
      Returns:
      the game-specific data
      See Also:
      • "HAL_GetGameData"
    • 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 warning
      errorCode - the error code
      isLVCode - true for a LV error code, false for a standard error code
      details - the details of the error
      location - the file location of the error
      callStack - the callstack of the error
      printMsg - 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

      public static int sendConsoleLine(String line)
      Sends a line to the driver station console.
      Parameters:
      line - the line to send
      Returns:
      the error code, or 0 for success
    • refreshDSData

      public static boolean refreshDSData()
      Refresh the DS control word.
      Returns:
      true if updated
      See Also:
      • "HAL_RefreshDSData"
    • 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