Class DriverStationJNI

java.lang.Object
edu.wpi.first.hal.JNIWrapper
edu.wpi.first.hal.DriverStationJNI

public class DriverStationJNI
extends JNIWrapper
Driver Station JNI Functions.
See Also:
"hal/DriverStation.h", "hal/FRCUsageReporting.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"
    • observeUserProgramDisabled

      public static void 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

      public static void 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

      public static void 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

      public static void 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

      public static void report​(int resource, int instanceNumber)
      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

      public static void report​(int resource, int instanceNumber, int context)
      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

      public static int report​(int resource, int instanceNumber, int context, String feature)
      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

      public static int 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

      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"
    • getAllianceStation

      Gets the current alliance station ID.
      Returns:
      the alliance station ID as AllianceStationID
      See Also:
      "HAL_GetAllianceStation"
    • getJoystickAxes

      public static int getJoystickAxes​(byte joystickNum, float[] axesArray)
      Gets the axes of a specific joystick.
      Parameters:
      joystickNum - the joystick number
      axesArray - the axes values
      Returns:
      number of joystick axes, or 0 for error
      See Also:
      "HAL_GetJoystickAxes"
    • getJoystickAxesRaw

      public static int getJoystickAxesRaw​(byte joystickNum, int[] rawAxesArray)
      Gets the axes of a specific joystick.
      Parameters:
      joystickNum - the joystick number
      rawAxesArray - the raw int axes values (0-255)
      Returns:
      number of joystick axes, or 0 for error
      See Also:
      "HAL_GetJoystickAxes"
    • getJoystickPOVs

      public static int getJoystickPOVs​(byte joystickNum, short[] povsArray)
      Gets the POVs of a specific joystick.
      Parameters:
      joystickNum - the joystick number
      povsArray - the POV values
      Returns:
      number of POVs, or 0 for error
      See Also:
      "HAL_GetJoystickPOVs"
    • getJoystickButtons

      public static int getJoystickButtons​(byte joystickNum, ByteBuffer count)
      Gets the buttons of a specific joystick.
      Parameters:
      joystickNum - the joystick number
      count - 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 axes
      rawAxesArray - all joystick axes as int
      povsArray - all povs
      buttonsAndMetadata - 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 number
      outputs - bitmask of outputs, 1 for on 0 for off
      leftRumble - 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

      public static int getJoystickIsXbox​(byte joystickNum)
      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

      public static int getJoystickType​(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_GetJoystickType"
    • 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"
    • getJoystickAxisType

      public static int getJoystickAxisType​(byte joystickNum, byte axis)
      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 number
      axis - the axis number
      Returns:
      the enumerated axis type
      See Also:
      "HAL_GetJoystickAxisType"
    • getMatchTime

      public static double 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

      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"
    • 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)
    • removeNewDataEventHandle

      public static void removeNewDataEventHandle​(int handle)
    • getOutputsActive

      public static boolean getOutputsActive()
      Gets if outputs are enabled by the control system.
      Returns:
      true if outputs are enabled