Package frc.robot.superstructure
Class ShootingCalculator
java.lang.Object
frc.robot.superstructure.ShootingCalculator
Some static utility methods for calculating shooter values.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AnglecalculateHoodAngle(Translation2d targetTranslation) Calculates the desired gamepiece theta for the given target translation.static TimecalculateTimeTillScore(Translation2d gamepieceTranslation, Angle gamepieceTheta, LinearVelocity gamepieceSpeed) Calculates the time until the gamepiece hits the targetgetTargetPoseForPosition(Pose2d robotPose) Gets the desired target pose for the given robot position.static ShooterValuessolve(Pose3d robotPose, Pose3d targetPose, ChassisSpeeds robotVelocity) Solves shooter values for a given robot pose and target.static Pose3dsolveExitPose(Pose3d robotPose, Angle thetaTurret, Angle thetaHood) Gets the pose where the ball will exit the shooter.static Translation2dsolveGamepieceTranslation(Pose3d turretPose, Pose3d targetPose) Gets the 2d translation from the turret to the target.static ShooterValuessolveInterpolated(Pose3d robotPose, Pose3d targetPose) Solves shooter values for a given robot pose and target using interpolation.
-
Field Details
-
SHOOTING_CALCULATOR_TABLE_NAME
The NetworkTables table name for the shooting calculator. -
SHOOTING_CALCULATOR_MODELED_TABLE_NAME
-
SHOOTING_CALCULATOR_INTERPOLATED_TABLE_NAME
-
-
Constructor Details
-
ShootingCalculator
public ShootingCalculator()
-
-
Method Details
-
solve
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
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
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
Gets the pose where the ball will exit the shooter.- Parameters:
robotPose- the pose of the robotthetaTurret- the angle of the turret, where 0 is facing towards the intake, ccw positivethetaHood- the angle of the shooter hood, ranging from 37 to 69 degrees- Returns:
- the pose of where the ball leaves the shooter
-
solveGamepieceTranslation
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 targetgamepieceTheta- The theta the gamePiece will be fired atgamepieceSpeed- The speed the gamePiece will be fired at- Returns:
- The time it will take for the gamepiece to hit the target.
-
getTargetPoseForPosition
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.
-