Class AimFeedforward

java.lang.Object
frc.robot.subsystems.swerve.AimFeedforward

public final class AimFeedforward extends Object
The heading-rate feedforward Swerve hands its aim request ( FieldCentricFacingAngle.withTargetRateFeedforward) while aiming at the hub.

Units and sign line up with no conversion. ShotCalculator differentiates a field-relative Rotation2d, so its driveAngularVelocity is radians per second, counter-clockwise positive. Phoenix adds TargetRateFeedforward to the heading PID's output, also rad/s counter-clockwise positive, in the request's forward perspective; this code never calls setOperatorPerspectiveForward, so that perspective is the blue-alliance field frame the target direction is already in, on both alliances.

Why it matters: without it the heading PID (kP 5 rad/s per rad) only turns once it has fallen behind, so tracking a target moving at 0.3 rad/s it sits 0.06 rad (3.4 deg) behind. That is about half the aim tolerance at 3 m.

  • Field Details

    • MAX_RAD_PER_SEC

      public static final double MAX_RAD_PER_SEC
      Largest feedforward handed to the request, rad/s. 2910 clamps theirs to the same +/-2 rad/s so a noisy derivative (a vision correction, a pose reset) cannot make the robot turn abruptly. For scale: strafing at 1 m/s past the hub at 1.5 m needs 0.67 rad/s.
      See Also:
  • Method Details

    • of

      public static double of(double rateRadPerSec)
      The feedforward for a shot solution's heading rate.
      Parameters:
      rateRadPerSec - the shot solution's driveAngularVelocity, rad/s CCW positive
      Returns:
      the clamped feedforward, rad/s CCW positive; 0 if the rate is not a finite number