Class ShotCalculator

java.lang.Object
frc.robot.util.ShotCalculator

public class ShotCalculator extends Object
Calculates shooter parameters (RPM and hood angle) based on distance and required velocity. Uses an interpolating map of empirically derived shooter parameters at various distances, then applies a correction based on the required velocity. The correction is split between RPM and hood angle to allow for more nuanced adjustments.
  • Constructor Details

    • ShotCalculator

      public ShotCalculator()
  • Method Details

    • calculateBoth

      public static void calculateBoth(double distance, double requiredVelocity, Consumer<Angle> hoodAngle, Consumer<Double> rpsOutput)
      Calculates shooter parameters based on distance and required velocity.
      Parameters:
      distance - The distance to the target in meters.
      requiredVelocity - The required velocity of the projectile at the target in m/s.
      hoodAngle - A consumer to accept the calculated hood angle.
      rpsOutput - A consumer to accept the calculated shooter RPS.
    • velocityComp

      public static void velocityComp(Translation2d robotPosition, ChassisSpeeds chassisSpeeds, Translation2d goalPosition, Consumer<Double> rpsOutput, Consumer<Angle> hoodAngle, Consumer<Angle> turretAngle)
      Calculates shooter parameters based on current robot position, velocity, and goal position. This method projects the robot's future position based on its current velocity, then calculates the required shot velocity to hit the target from that future position. It then uses the required shot velocity to adjust the shooter parameters accordingly
      Parameters:
      robotPosition - The current position of the robot on the field as a Translation2d (x, y).
      chassisSpeeds - The current velocity of the robot as a ChassisSpeeds object (vx, vy, omega).
      goalPosition - The position of the target on the field as a Translation2d (x, y).
      rpsOutput - A consumer to accept the calculated shooter RPS.
      hoodAngle - A consumer to accept the calculated hood angle.
      turretAngle - A consumer to accept the calculated turret angle (the angle the turret needs to turn to face the calculated target).