Package frc.robot.shared.targeting
Class BallFlightSimulator
java.lang.Object
frc.robot.shared.targeting.BallFlightSimulator
Simulation-only utility that models Fuel launched from the shooter as 3D projectiles.
Each cycle the simulator checks whether the shooter and indexer are ready to fire. When they are, a new ball is spawned at the turret exit with a
velocity derived from the current flywheel RPM. All active balls advance through simple projectile kinematics (gravity + drag) and their positions
are logged as a Pose3d[] for AdvantageScope's 3D field view using the Fuel game piece type.
This class is not a subsystem and does not participate in the command scheduler. It is instantiated in RobotContainer only when
RobotEnvironment.isSimulation() is true, and its periodic() method is called from the container's periodic loop.
-
Constructor Summary
ConstructorsConstructorDescriptionBallFlightSimulator(Supplier<edu.wpi.first.math.geometry.Pose2d> robotPoseSupplier, Supplier<Double> turretAngleDegreesSupplier, Supplier<Double> shooterRpmSupplier, Supplier<Boolean> shooterReadySupplier, Supplier<Boolean> indexerFeedingSupplier, Supplier<edu.wpi.first.math.kinematics.ChassisSpeeds> fieldVelocitySupplier, double turretZeroOffsetDegrees, double turretPivotX, double turretPivotY, double turretPivotZ, double dragCoefficient, DistanceRpmPoint[] distanceRpmPoints) Creates the ball flight simulator with suppliers for all required robot state. -
Method Summary
Modifier and TypeMethodDescriptionvoidperiodic()Advances all in-flight balls, checks for new launches, and logs positions to AdvantageKit.
-
Constructor Details
-
BallFlightSimulator
public BallFlightSimulator(Supplier<edu.wpi.first.math.geometry.Pose2d> robotPoseSupplier, Supplier<Double> turretAngleDegreesSupplier, Supplier<Double> shooterRpmSupplier, Supplier<Boolean> shooterReadySupplier, Supplier<Boolean> indexerFeedingSupplier, Supplier<edu.wpi.first.math.kinematics.ChassisSpeeds> fieldVelocitySupplier, double turretZeroOffsetDegrees, double turretPivotX, double turretPivotY, double turretPivotZ, double dragCoefficient, DistanceRpmPoint[] distanceRpmPoints) Creates the ball flight simulator with suppliers for all required robot state.- Parameters:
robotPoseSupplier- supplier for the current robot pose in meters and radiansturretAngleDegreesSupplier- supplier for the turret's measured angle in degrees relative to its mechanical zeroshooterRpmSupplier- supplier for the current measured flywheel RPMshooterReadySupplier- supplier returning true when the shooter is at shooting velocityindexerFeedingSupplier- supplier returning true when the indexer is actively feeding forwardfieldVelocitySupplier- supplier for the robot's field-relative velocityturretZeroOffsetDegrees- turret zero offset in degrees (180 means turret faces rear at mechanical zero)turretPivotX- turret pivot X offset from robot center in meters (positive = forward)turretPivotY- turret pivot Y offset from robot center in meters (positive = left)turretPivotZ- turret pivot height in metersdragCoefficient- aerodynamic drag coefficient for the ball in flightdistanceRpmPoints- distance-RPM-TOF calibration data used to derive exit velocity from RPM
-
-
Method Details
-
periodic
public void periodic()Advances all in-flight balls, checks for new launches, and logs positions to AdvantageKit.Call once per robot loop from
RobotContainer.periodic().
-