Package org.team1540.rooster.util
Class ControlUtils
- java.lang.Object
-
- org.team1540.rooster.util.ControlUtils
-
public class ControlUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description ControlUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
constrainAbsValue(double velocity, double maxVelocity, double minVelocity)
static double
constrainAndDeadzone(double output, double max, double min, double deadzone)
static double
deadzone(double input, boolean allowNegativeValues, double fast, double slow, double fastX, double slowX)
https://www.desmos.com/calculator/ybuyhcfzgmstatic double
deadzone(double axis, double deadzone)
Processes an axis with a deadzone.static double
simpleDeadzone(double axis, double deadzone)
Processes an axis and returns the value only if it is outside the provided deadzone.
-
-
-
Method Detail
-
constrainAbsValue
public static double constrainAbsValue(double velocity, double maxVelocity, double minVelocity)
-
simpleDeadzone
public static double simpleDeadzone(double axis, double deadzone)
Processes an axis and returns the value only if it is outside the provided deadzone.- Parameters:
axis
- The axis to return.deadzone
- The deadzone to use.- Returns:
- If |
axis
| is greater than |deadzone
|, returnsaxis
; otherwise, returns 0.
-
constrainAndDeadzone
public static double constrainAndDeadzone(double output, double max, double min, double deadzone)
-
deadzone
public static double deadzone(double input, boolean allowNegativeValues, double fast, double slow, double fastX, double slowX)
https://www.desmos.com/calculator/ybuyhcfzgm- Parameters:
input
- xfast
- fslow
- sfastX
- b, fastX < slowXslowX
- a- Returns:
- y
-
deadzone
@Contract(pure=true) public static double deadzone(double axis, double deadzone)
Processes an axis with a deadzone. This implementation scales the output such that the area between the deadzone and 1 is mapped to the full range of motion.Full implementation details: The function processes the deadzone according to the function \(\DeclareMathOperator{\sgn}{sgn}\frac{d(x)-Z\sgn(d(x))}{1-Z}\), where \(x\) is the
axis
parameter, \(Z\) is thedeadzone
parameter, and \(d(x)\) is the deadzone function \(d(x)=\begin{cases}x & |x| \geq D \\ 0 & |x| < D\end{cases}\). (Note: Equations may require viewing the Javadoc using a browser.)- Parameters:
axis
- The axis to return.deadzone
- The deadzone to use.- Returns:
- The axis value processed with respect to the specified deadzone.
-
-