Package frc.spectrumLib.util
Class Curve
java.lang.Object
frc.spectrumLib.util.Curve
- Direct Known Subclasses:
ExpCurve
Maps controller stick inputs through a curve. Subclass this rather than instantiating Curve
directly, for example
ExpCurve.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract doublecalculate(double input) Maps a stick input, expected in [-1, 1], to the curve's output.protected doublecalculateDeadzone(double input) Blanks the middle of the curve, then rescales what is left to fill [-1, 1] again.protected doublecalculateOffset(double input) protected doublecalculateScalar(double input) double[][]getCurvePoints(int pointCount) Samples the curve at pointCount evenly spaced inputs across [-1, 1].doubledoubledoublevoidprintPoints(double[][] points) Prints [x, y] pairs for pasting into Desmos.voidprintPoints(int pointCount) PrintsgetCurvePoints(int)for pasting into Desmos.voidsetDeadzone(double deadzone) Sets the deadband width centred on zero.voidsetOffset(double offset) voidsetScalar(double scalar)
-
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) PrintsgetCurvePoints(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()
-