Class Curve

java.lang.Object
frc.spectrumLib.util.Curve
Direct Known Subclasses:
ExpCurve

public abstract class Curve extends Object
Maps controller stick inputs through a curve. Subclass this rather than instantiating Curve directly, for example ExpCurve.
  • Constructor Details

    • Curve

      public Curve()
  • Method Details

    • calculate

      public abstract double calculate(double input)
      Maps a stick input, expected in [-1, 1], to the curve's output.
    • calculateDeadzone

      protected double calculateDeadzone(double input)
      Blanks the middle of the curve, then rescales what is left to fill [-1, 1] again.
    • calculateScalar

      protected double calculateScalar(double input)
    • calculateOffset

      protected double calculateOffset(double input)
    • getCurvePoints

      public double[][] getCurvePoints(int pointCount)
      Samples the curve at pointCount evenly spaced inputs across [-1, 1]. With pointCount of 1, the single point is the center of the input range.
      Returns:
      [x, y] pairs, one per sample
    • printPoints

      public void printPoints(double[][] points)
      Prints [x, y] pairs for pasting into Desmos.
    • printPoints

      public void printPoints(int pointCount)
      Prints getCurvePoints(int) for pasting into Desmos.
    • setOffset

      public void setOffset(double offset)
    • setScalar

      public void setScalar(double scalar)
    • setDeadzone

      public void setDeadzone(double deadzone)
      Sets the deadband width centred on zero. A negative width is stored as its absolute value.
    • getOffset

      public double getOffset()
    • getScalar

      public double getScalar()
    • getDeadzone

      public double getDeadzone()