Class ControlUtils


  • public class ControlUtils
    extends Object
    • Constructor Detail

      • ControlUtils

        public ControlUtils()
    • 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|, returns axis; 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 - x
        fast - f
        slow - s
        fastX - b, fastX < slowX
        slowX - 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 the deadzone 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.