Class DifferentialMixer

java.lang.Object
com.crossbotics.ftchelper.drive.DifferentialMixer

public final class DifferentialMixer extends Object
The math that turns stick values into left and right powers for a standard (tank) drive. No hardware here, so it is easy to test. TankDrive uses it.

Signs: forward + = forward, turnClockwise + = turn right. Same as MecanumMixer. All the sign rules: docs/conventions.md. Docs: docs/modules/drive.md. Tutorial 05 drives a standard robot with it.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Index of each side in the arrays this class returns.
    static final int
    Index of each side in the arrays this class returns.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    arcade(double forward, double turnClockwise, double limit)
    "Arcade" drive: one stick for forward, one for turning.
    static double[]
    tank(double left, double right, double limit)
    "Tank" style: one stick for each side.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LEFT

      public static final int LEFT
      Index of each side in the arrays this class returns.
      See Also:
  • Method Details

    • arcade

      public static double[] arcade(double forward, double turnClockwise, double limit)
      "Arcade" drive: one stick for forward, one for turning.

      If a side would get more than limit, both sides are scaled down together, so the robot still follows the same curve.

      Parameters:
      forward - -1 to 1
      turnClockwise - -1 to 1
      limit - the largest power a side may get, 0 to 1
      Returns:
      {left, right}. Both zero if an input is NaN or infinite.
    • tank

      public static double[] tank(double left, double right, double limit)
      "Tank" style: one stick for each side.
      Parameters:
      left - -1 to 1
      right - -1 to 1
      limit - the largest power a side may get, 0 to 1
      Returns:
      {left, right}, each multiplied by the limit (values past 1 are cut to 1 first)