Class ShotCalculator
java.lang.Object
frc.rebuilt.ShotCalculator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe fixed shots, one per parking spot, from the offseason bot's set shots (463c465, fa1376b) less its hub-face shot, which FM cannot make.static final recordImmutable snapshot of all quantities needed to command the drive, hood, and flywheel subsystems for a single shot. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic doublestatic final doubleFM's centre to its bumper face, metres: half the 0.84 m bumpered frame PathPlanner uses (settings.json).static doublestatic final doublestatic final doublestatic final doubleThe y of the tower's centreline, metres. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the cached parameters so they are recomputed on the next call togetParameters().static Commandstatic Commandstatic doubleexitSpeedForFlywheelRpm(double rpm) The ball exit speed a flywheel speed stands for, the inverse of the model's RPM conversion.static ShotCalculatorReturns the current shooting parameters, computing them from the robot's live pose and velocity if not already cached this loop.static ShotCalculator.SetShotThe fixed shot currently selected,ShotCalculator.SetShot.TOWERuntil a binding picks one.static doubleFlywheel speed for the selected set shot, RPM, on the dashboard's hub model.static doubleHood angle for the selected set shot, degrees, on the dashboard's hub model.static Commandstatic Commandstatic voidPicks which fixed shot the SET_SHOT super state runs.
-
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_METERSFM'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_METERSThe 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 ownField.BlueTower.tag31Yputs 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
-
increaseHoodAngleOffset
-
decreaseHoodAngleOffset
-
increaseDriveAngleOffset
-
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
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
The fixed shot currently selected,ShotCalculator.SetShot.TOWERuntil 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
Returns the current shooting parameters, computing them from the robot's live pose and velocity if not already cached this loop.Approach:
- Apply a phase delay to the odometry pose to account for sensor latency.
- Compute the launcher's field-relative velocity, including the tangential component from robot rotation about its centre.
- Decompose that velocity into radial (toward target) and tangential (perpendicular) components.
- Run the 1690 Orbit iterative virtual-target solver to determine the optimal exit speed, launch angle, and yaw correction for shoot-on-the-move.
- 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 togetParameters().
-