Class ShootingCalculator

java.lang.Object
frc.robot.superstructure.ShootingCalculator

public class ShootingCalculator extends Object
Some static utility methods for calculating shooter values.
  • Field Details

    • SHOOTING_CALCULATOR_TABLE_NAME

      public static String SHOOTING_CALCULATOR_TABLE_NAME
      The NetworkTables table name for the shooting calculator.
    • SHOOTING_CALCULATOR_MODELED_TABLE_NAME

      public static String SHOOTING_CALCULATOR_MODELED_TABLE_NAME
    • SHOOTING_CALCULATOR_INTERPOLATED_TABLE_NAME

      public static String SHOOTING_CALCULATOR_INTERPOLATED_TABLE_NAME
  • Constructor Details

    • ShootingCalculator

      public ShootingCalculator()
  • Method Details

    • solve

      public static ShooterValues solve(Pose3d robotPose, Pose3d targetPose, ChassisSpeeds robotVelocity)
      Solves shooter values for a given robot pose and target.

      The math behind this is documented in this Desmos calculator.

      Parameters:
      robotPose - The pose of the robot.
      targetPose - The pose of the target to point at.
      robotVelocity - The robot-relative velocity of the robot.
      Returns:
      The resulting values to apply.
    • solveInterpolated

      public static ShooterValues solveInterpolated(Pose3d robotPose, Pose3d targetPose)
      Solves shooter values for a given robot pose and target using interpolation.
      Parameters:
      robotPose - The pose of the robot.
      targetPose - The pose of the target to point at.
      Returns:
      The resulting values to apply.
    • calculateHoodAngle

      public static Angle calculateHoodAngle(Translation2d targetTranslation)
      Calculates the desired gamepiece theta for the given target translation.
      Parameters:
      targetTranslation - The translation to shoot at.
      Returns:
      The theta to shoot the gamepiece at.
    • solveExitPose

      public static Pose3d solveExitPose(Pose3d robotPose, Angle thetaTurret, Angle thetaHood)
      Gets the pose where the ball will exit the shooter.
      Parameters:
      robotPose - the pose of the robot
      thetaTurret - the angle of the turret, where 0 is facing towards the intake, ccw positive
      thetaHood - the angle of the shooter hood, ranging from 37 to 69 degrees
      Returns:
      the pose of where the ball leaves the shooter
    • solveGamepieceTranslation

      public static Translation2d solveGamepieceTranslation(Pose3d turretPose, Pose3d targetPose)
      Gets the 2d translation from the turret to the target.
      Parameters:
      turretPose - The pose of the turret.
      targetPose - The pose of the target to point at.
      Returns:
      The translation from the turret to the target as a 2d plane where X is horizontal distance and Y is vertical distance.
    • calculateTimeTillScore

      public static Time calculateTimeTillScore(Translation2d gamepieceTranslation, Angle gamepieceTheta, LinearVelocity gamepieceSpeed)
      Calculates the time until the gamepiece hits the target
      Parameters:
      gamepieceTranslation - The translation to the target
      gamepieceTheta - The theta the gamePiece will be fired at
      gamepieceSpeed - The speed the gamePiece will be fired at
      Returns:
      The time it will take for the gamepiece to hit the target.
    • getTargetPoseForPosition

      public static Optional<Pose3d> getTargetPoseForPosition(Pose2d robotPose)
      Gets the desired target pose for the given robot position.
      Parameters:
      robotPose - The current pose of the robot.
      Returns:
      Hub receptacle if viable, on to our side if in the center, or empty if otherwise.