Class JoystickAxis

java.lang.Object
org.chsrobotics.lib.input.JoystickAxis

public class JoystickAxis extends Object
Represents a hardware axis on an input device which has a value in [-1,1] (inclusive).
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    JoystickAxis(Supplier<Double> valueLambda, String name, boolean isReal)
    Constructs a JoystickAxis.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDeadband(double magnitude)
    Adds a deadband to the axis such that axis absolute values below this will be returned as 0.
    double
    Returns the current value of the axis, with deadband applied.
    boolean
    Returns whether the axis is inverted (polarity switched).
    boolean
    Whether this JoystickAxis is a representation of physical hardware.
    void
    setInverted(boolean trueIfInverted)
    Sets whether the axis should be inverted (polarity switched).
     

    Methods inherited from class java.lang.Object

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

    • JoystickAxis

      protected JoystickAxis(Supplier<Double> valueLambda, String name, boolean isReal)
      Constructs a JoystickAxis.
      Parameters:
      valueLambda - Supplier of the value of the axis, in [-1,1] (inclusive).
      name - String identifier of the index of this axis in the driver station view.
      isReal - If this JoystickAxis is a representation of actual hardware.
  • Method Details

    • getValue

      public double getValue()
      Returns the current value of the axis, with deadband applied.
      Returns:
      Value of the axis, in [-1,1] (inclusive).
    • addDeadband

      public void addDeadband(double magnitude)
      Adds a deadband to the axis such that axis absolute values below this will be returned as 0.
      Parameters:
      magnitude - The minimum absolute value required for the controller to not return 0.
    • setInverted

      public void setInverted(boolean trueIfInverted)
      Sets whether the axis should be inverted (polarity switched).
      Parameters:
      trueIfInverted - If the axis should be inverted.
    • isInverted

      public boolean isInverted()
      Returns whether the axis is inverted (polarity switched).
      Returns:
      True if the axis is inverted.
    • isReal

      public boolean isReal()
      Whether this JoystickAxis is a representation of physical hardware.
      Returns:
      If this exists on an actual controller.
    • toString

      public String toString()
      Overrides:
      toString in class Object