Class TeleopDriveMath

java.lang.Object
com.marslib.swerve.TeleopDriveMath

public final class TeleopDriveMath extends Object
Pure-function joystick-to-ChassisSpeeds math for the teleop drive pipeline.

This class exists so the exact same math is used in RobotContainer and in tests. If this is ever changed, the TeleopDrivePipelineTest will immediately catch regressions.

Pipeline stages:

  1. Deadband (10%) — filters stick drift
  2. Cubic scaling — provides fine control at small deflections
  3. Physical scaling — converts [-1,1] to m/s and rad/s
  4. WPILib sign convention — negates to convert stick-forward to +X
  5. Alliance flip — negates X and Y for Red alliance

Note: slew rate limiting and gyro-lock are stateful operations that remain in RobotContainer since they depend on previous tick state.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Default joystick deadband threshold.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    computeFieldRelativeSpeeds(double rawLeftY, double rawLeftX, double rawOmega, double maxLinearSpeedMps, double maxAngularSpeedRadPerSec, boolean isRedAlliance, edu.wpi.first.math.kinematics.ChassisSpeeds outSpeeds)
    Computes field-relative ChassisSpeeds from raw joystick axes BEFORE slew rate limiting.

    Methods inherited from class java.lang.Object

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

    • DEADBAND

      public static final double DEADBAND
      Default joystick deadband threshold.
      See Also:
  • Method Details

    • computeFieldRelativeSpeeds

      public static void computeFieldRelativeSpeeds(double rawLeftY, double rawLeftX, double rawOmega, double maxLinearSpeedMps, double maxAngularSpeedRadPerSec, boolean isRedAlliance, edu.wpi.first.math.kinematics.ChassisSpeeds outSpeeds)
      Computes field-relative ChassisSpeeds from raw joystick axes BEFORE slew rate limiting. This is the pure-math portion of the teleop pipeline: deadband → cube → scale → negate → alliance-flip.
      Parameters:
      rawLeftY - Raw left stick Y axis (negative = forward per HID convention)
      rawLeftX - Raw left stick X axis (negative = left per HID convention)
      rawOmega - Raw right stick X axis (negative = CCW per HID convention)
      maxLinearSpeedMps - The maximum translation speed of the robot.
      maxAngularSpeedRadPerSec - The maximum rotation speed of the robot.
      isRedAlliance - Whether the robot is on the Red alliance (flips translation axes)
      outSpeeds - The pre-allocated ChassisSpeeds to populate with field-relative velocities. Omega is negated so that rightward stick (positive HID) produces negative (clockwise) rotation per WPILib ChassisSpeeds convention.