Class TractionControlLimiter

java.lang.Object
com.marslib.swerve.TractionControlLimiter

public class TractionControlLimiter extends Object
Advanced 2D Slew Rate Limiter to prevent carpet slippage and Odometry drift.

Standard WPILib SlewRateLimiters operate independently on X and Y axes. If both max out, the robot accelerates diagonally at 1.41x the limit, instantly breaking carpet friction. This class ensures the total 2D acceleration vector never exceeds the maximum static friction coefficient of the FRC carpet (usually ~1.1g or 10.78 m/s^2).

  • Constructor Summary

    Constructors
    Constructor
    Description
    TractionControlLimiter(double maxAccelMetersPerSecSq)
    Initializes the 2D Traction Control limit.
  • Method Summary

    Modifier and Type
    Method
    Description
    edu.wpi.first.math.geometry.Translation2d
    calculate(edu.wpi.first.math.geometry.Translation2d targetVelocity)
    Calculates the max achievable velocity vector without slipping tires.

    Methods inherited from class java.lang.Object

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

    • TractionControlLimiter

      public TractionControlLimiter(double maxAccelMetersPerSecSq)
      Initializes the 2D Traction Control limit.
      Parameters:
      maxAccelMetersPerSecSq - Maximum physical acceleration before tire slip occurs.
  • Method Details

    • calculate

      public edu.wpi.first.math.geometry.Translation2d calculate(edu.wpi.first.math.geometry.Translation2d targetVelocity)
      Calculates the max achievable velocity vector without slipping tires.
      Parameters:
      targetVelocity - Target requested X/Y velocity vector.
      Returns:
      Safe velocity vector to apply to the ChassisSpeeds.