Class FrcXboxController

java.lang.Object
trclib.driverio.TrcGameController
frclib.driverio.FrcXboxController

public class FrcXboxController extends TrcGameController
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    This interface, if provided, will allow this class to do a notification callback when there are button activities.
    static enum 
     

    Nested classes/interfaces inherited from class trclib.driverio.TrcGameController

    TrcGameController.DriveMode
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final edu.wpi.first.wpilibj.XboxController
     

    Fields inherited from class trclib.driverio.TrcGameController

    instanceName, tracer
  • Constructor Summary

    Constructors
    Constructor
    Description
    FrcXboxController(String instanceName, int port)
    Constructor: Create an instance of the object.
    FrcXboxController(String instanceName, int port, double deadbandThreshold)
    Constructor: Create an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    This method returns the button states in an integer by combining all the button states.
    double[]
    getDriveInputs(TrcGameController.DriveMode driveMode, boolean doExp)
    This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.
    double[]
    getDriveInputs(TrcGameController.DriveMode driveMode, boolean doExp, double drivePowerScale, double turnPowerScale)
    This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.
    double
    This method returns the x-axis value of the left stick.
    double
    getLeftStickX(boolean doExp)
    This method returns the x-axis value of the left stick.
    double
    getLeftStickX(double cubicCoefficient)
    This method returns the x-axis value of the left stick using the cubic polynomial curve.
    double
    This method returns the y-axis value of the left stick.
    double
    getLeftStickY(boolean doExp)
    This method returns the y-axis value of the left stick.
    double
    getLeftStickY(double cubicCoefficient)
    This method returns the y-axis value of the left stick using the cubic polynomial curve.
    double
    This method returns the left trigger value.
    double
    getLeftTrigger(boolean doExp)
    This method returns the left trigger value.
    double
    getLeftTrigger(double cubicCoefficient)
    This method returns the left trigger value using the cubic polynomial curve.
    double
    This method returns the x-axis value of the right stick.
    double
    getRightStickX(boolean doExp)
    This method returns the x-axis value of the right stick.
    double
    getRightStickX(double cubicCoefficient)
    This method returns the x-axis value of the right stick using the cubic polynomial curve.
    double
    This method returns the y-axis value of the right stick.
    double
    getRightStickY(boolean doExp)
    This method returns the y-axis value of the right stick.
    double
    getRightStickY(double cubicCoefficient)
    This method returns the y-axis value of the right stick using the cubic polynomial curve.
    double
    This method returns the right trigger value.
    double
    getRightTrigger(boolean doExp)
    This method returns the right trigger value.
    double
    getRightTrigger(double cubicCoefficient)
    This method returns the right trigger value using the cubic polynomial curve.
    double
    This method combines the left trigger and right trigger values to a value with a range of -1.0 to 1.0.
    double
    getTrigger(boolean doExp)
    This method combines the left trigger and right trigger values to a value with a range of -1.0 to 1.0.
    double
    getTrigger(double cubicCoefficient)
    This method combines the left trigger and right trigger values to a value with a range of -1.0 to 1.0 using the cubic polynomial curve.
    protected void
    notifyButtonEvent(int buttonValue, boolean pressed)
    This method is called when a button event is detected.
    void
    This method sets the button event handler.
    void
    setLeftStickInverted(boolean xInverted, boolean yInverted)
    This method inverts the left analog stick axes.
    void
    setRightStickInverted(boolean xInverted, boolean yInverted)
    This method inverts the right analog stick axes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • gamepad

      public final edu.wpi.first.wpilibj.XboxController gamepad
  • Constructor Details

    • FrcXboxController

      public FrcXboxController(String instanceName, int port, double deadbandThreshold)
      Constructor: Create an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      port - specifies the USB port the gamepad is plugged into.
      deadbandThreshold - specifies the deadband of the gamepad analog sticks.
    • FrcXboxController

      public FrcXboxController(String instanceName, int port)
      Constructor: Create an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      port - specifies the USB port the gamepad is plugged into.
  • Method Details

    • setButtonEventHandler

      public void setButtonEventHandler(FrcXboxController.ButtonEventHandler buttonEventHandler)
      This method sets the button event handler.
      Parameters:
      buttonEventHandler - specifies button event notification handler, null to disable event notification.
    • setLeftStickInverted

      public void setLeftStickInverted(boolean xInverted, boolean yInverted)
      This method inverts the left analog stick axes.
      Parameters:
      xInverted - specifies true if inverting the x-axis, false otherwise.
      yInverted - specifies true if inverting the y-axis, false otherwise.
    • setRightStickInverted

      public void setRightStickInverted(boolean xInverted, boolean yInverted)
      This method inverts the right analog stick axes.
      Parameters:
      xInverted - specifies true if inverting the x-axis, false otherwise.
      yInverted - specifies true if inverting the y-axis, false otherwise.
    • getLeftStickX

      public double getLeftStickX(double cubicCoefficient)
      This method returns the x-axis value of the left stick using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      x-axis value of the left stick.
    • getLeftStickX

      public double getLeftStickX(boolean doExp)
      This method returns the x-axis value of the left stick.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      x-axis value of the left stick.
    • getLeftStickX

      public double getLeftStickX()
      This method returns the x-axis value of the left stick.
      Returns:
      x-axis value of the left stick.
    • getLeftStickY

      public double getLeftStickY(double cubicCoefficient)
      This method returns the y-axis value of the left stick using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      y-axis value of the left stick.
    • getLeftStickY

      public double getLeftStickY(boolean doExp)
      This method returns the y-axis value of the left stick.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      y-axis value of the left stick.
    • getLeftStickY

      public double getLeftStickY()
      This method returns the y-axis value of the left stick.
      Returns:
      y-axis value of the left stick.
    • getRightStickX

      public double getRightStickX(double cubicCoefficient)
      This method returns the x-axis value of the right stick using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      x-axis value of the right stick.
    • getRightStickX

      public double getRightStickX(boolean doExp)
      This method returns the x-axis value of the right stick.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      x-axis value of the right stick.
    • getRightStickX

      public double getRightStickX()
      This method returns the x-axis value of the right stick.
      Returns:
      x-axis value of the right stick.
    • getRightStickY

      public double getRightStickY(double cubicCoefficient)
      This method returns the y-axis value of the right stick using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      y-axis value of the right stick.
    • getRightStickY

      public double getRightStickY(boolean doExp)
      This method returns the y-axis value of the right stick.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      y-axis value of the right stick.
    • getRightStickY

      public double getRightStickY()
      This method returns the y-axis value of the right stick.
      Returns:
      y-axis value of the right stick.
    • getLeftTrigger

      public double getLeftTrigger(double cubicCoefficient)
      This method returns the left trigger value using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      left trigger value.
    • getLeftTrigger

      public double getLeftTrigger(boolean doExp)
      This method returns the left trigger value.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      left trigger value.
    • getLeftTrigger

      public double getLeftTrigger()
      This method returns the left trigger value.
      Returns:
      left trigger value.
    • getRightTrigger

      public double getRightTrigger(double cubicCoefficient)
      This method returns the right trigger value using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      right trigger value.
    • getRightTrigger

      public double getRightTrigger(boolean doExp)
      This method returns the right trigger value.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      right trigger value.
    • getRightTrigger

      public double getRightTrigger()
      This method returns the right trigger value.
      Returns:
      right trigger value.
    • getTrigger

      public double getTrigger(double cubicCoefficient)
      This method combines the left trigger and right trigger values to a value with a range of -1.0 to 1.0 using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      combined left and right trigger value.
    • getTrigger

      public double getTrigger(boolean doExp)
      This method combines the left trigger and right trigger values to a value with a range of -1.0 to 1.0.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      combined left and right trigger value.
    • getTrigger

      public double getTrigger()
      This method combines the left trigger and right trigger values to a value with a range of -1.0 to 1.0.
      Returns:
      combined left and right trigger value.
    • getDriveInputs

      public double[] getDriveInputs(TrcGameController.DriveMode driveMode, boolean doExp, double drivePowerScale, double turnPowerScale)
      This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.
      Parameters:
      driveMode - specifies the drive mode which determines the control mappings.
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      drivePowerScale - specifies the scaling factor for drive power.
      turnPowerScale - specifies the scaling factor for turn power.
      Returns:
      an array of 3 values for x, y and rotation power.
    • getDriveInputs

      public double[] getDriveInputs(TrcGameController.DriveMode driveMode, boolean doExp)
      This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.
      Parameters:
      driveMode - specifies the drive mode which determines the control mappings.
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      an array of 3 values for x, y and rotation power.
    • getButtons

      public int getButtons()
      This method returns the button states in an integer by combining all the button states.
      Specified by:
      getButtons in class TrcGameController
      Returns:
      button states.
    • notifyButtonEvent

      protected void notifyButtonEvent(int buttonValue, boolean pressed)
      This method is called when a button event is detected. It translates the button value into button type and calls the button event handler.
      Specified by:
      notifyButtonEvent in class TrcGameController
      Parameters:
      buttonValue - specifies the button value that generated the event.
      pressed - specifies true if the button is pressed, false if it is released.