Class ShotCalculator

java.lang.Object
frc.rebuilt.ShotCalculator

public class ShotCalculator extends Object
  • Field Details

    • STARTING_HOOD_ANGLE_OFFSET

      public static final double STARTING_HOOD_ANGLE_OFFSET
      See Also:
    • HOOD_ANGLE_OFFSET

      public static double HOOD_ANGLE_OFFSET
    • STARTING_DRIVE_ANGLE_OFFSET

      public static final double STARTING_DRIVE_ANGLE_OFFSET
      See Also:
    • DRIVE_ANGLE_OFFSET

      public static double DRIVE_ANGLE_OFFSET
    • FM_HALF_LENGTH_METERS

      public static final double FM_HALF_LENGTH_METERS
      FM's centre to its bumper face, metres: half the 0.84 m bumpered frame PathPlanner uses (settings.json). CALIBRATE: measure FM's bumper-to-centre, both ways.
      See Also:
    • TOWER_CENTRE_Y_METERS

      public static final double TOWER_CENTRE_Y_METERS
      The y of the tower's centreline, metres. CALIBRATE on the field. The offseason bot parked on tag 31's y (147.469 in in the 2026 welded layout, 3.746 m) and found "squared up dead flat is 5.3 deg off, because the tower's centreline follows tag 31 and the hub sits on the field centreline". FM's own Field.BlueTower.tag31Y puts the tower on the field centreline instead (4.035 m); the distance differs by under a centimetre, only the heading moves.
      See Also:
  • Method Details

    • getInstance

      public static ShotCalculator getInstance()
    • increaseHoodAngleOffset

      public static Command increaseHoodAngleOffset()
    • decreaseHoodAngleOffset

      public static Command decreaseHoodAngleOffset()
    • increaseDriveAngleOffset

      public static Command increaseDriveAngleOffset()
    • decreaseDriveAngleOffset

      public static Command decreaseDriveAngleOffset()
    • exitSpeedForFlywheelRpm

      public static double exitSpeedForFlywheelRpm(double rpm)
      The ball exit speed a flywheel speed stands for, the inverse of the model's RPM conversion.
      Parameters:
      rpm - flywheel speed
      Returns:
      exit speed, m/s
    • selectSetShot

      public static void selectSetShot(ShotCalculator.SetShot shot)
      Picks which fixed shot the SET_SHOT super state runs. Called from the pilot binding before the state is requested; the selection sticks until the next binding changes it. Main thread only; the binding comes from logged Driver Station inputs, so replay makes the same pick.
      Parameters:
      shot - the parking spot
    • getSelectedSetShot

      public static ShotCalculator.SetShot getSelectedSetShot()
      The fixed shot currently selected, ShotCalculator.SetShot.TOWER until a binding picks one.
    • getSetShotHoodDegrees

      public static double getSetShotHoodDegrees()
      Hood angle for the selected set shot, degrees, on the dashboard's hub model.
    • getSetShotFlywheelRPM

      public static double getSetShotFlywheelRPM()
      Flywheel speed for the selected set shot, RPM, on the dashboard's hub model.
    • getParameters

      public ShotCalculator.ShootingParameters getParameters()
      Returns the current shooting parameters, computing them from the robot's live pose and velocity if not already cached this loop.

      Approach:

      1. Apply a phase delay to the odometry pose to account for sensor latency.
      2. Compute the launcher's field-relative velocity, including the tangential component from robot rotation about its centre.
      3. Decompose that velocity into radial (toward target) and tangential (perpendicular) components.
      4. Run the 1690 Orbit iterative virtual-target solver to determine the optimal exit speed, launch angle, and yaw correction for shoot-on-the-move.
      5. Derive the drive angle, hood angle, and flywheel RPM from the result.

      Call clearShootingParameters() at the start of each loop to allow re-computation on the next call.

      Returns:
      the latest ShotCalculator.ShootingParameters
    • clearShootingParameters

      public void clearShootingParameters()
      Clears the cached parameters so they are recomputed on the next call to getParameters().