Class BallFlightSimulator

java.lang.Object
frc.robot.shared.targeting.BallFlightSimulator

public class BallFlightSimulator extends Object
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

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Advances all in-flight balls, checks for new launches, and logs positions to AdvantageKit.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 radians
      turretAngleDegreesSupplier - supplier for the turret's measured angle in degrees relative to its mechanical zero
      shooterRpmSupplier - supplier for the current measured flywheel RPM
      shooterReadySupplier - supplier returning true when the shooter is at shooting velocity
      indexerFeedingSupplier - supplier returning true when the indexer is actively feeding forward
      fieldVelocitySupplier - supplier for the robot's field-relative velocity
      turretZeroOffsetDegrees - 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 meters
      dragCoefficient - aerodynamic drag coefficient for the ball in flight
      distanceRpmPoints - 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().