Skip to main content
LauncherConstants.java defines interpolating lookup tables that map distance-to-target to flywheel speed, hood angle, and time of flight for both the Alpha and Competition bots. At runtime the correct dataset is selected automatically based on RobotType, and all three maps are populated in a static initializer so lookup is allocation-free during the match.

LauncherDistanceDataPoint record

Each row in a distance table is represented by a LauncherDistanceDataPoint object with four fields: Constructor argument order: (distance, hoodAngle, flywheelPower, time).

Competition bot lookup table

The comp bot table has 12 data points covering 1 m through 8 m. Linear interpolation fills in values between measured points.

Alpha bot lookup table

The alpha bot uses a simpler 4-point table (different hood geometry and gear ratio):

Interpolation

All three lookup dimensions use InterpolatingDoubleTreeMap from WPILib, which performs linear interpolation between adjacent keys. The maps are populated once in a static block at class load time:
Distances outside the table’s range clamp to the nearest endpoint (WPILib InterpolatingDoubleTreeMap behavior).

Static lookup methods

Moving-shot prediction

Two methods support shooting while the robot is moving by iteratively predicting where the target will be when the projectile arrives.

predictTargetPos(target, fieldSpeeds, timeOfFlight, robot)

Moves the target backwards along the robot’s current velocity vector (translational + rotational component from the launcher offset) by one time-of-flight step:

iterativeMovingShotFromFunnelClearance(robot, fieldSpeeds, target, iterations)

Runs the prediction loop iterations times. Each pass re-estimates the time of flight from the updated predicted distance, converging toward a self-consistent solution:
  1. Compute initial distance from launcher to the original target.
  2. Look up initial time of flight from the distance map.
  3. For each iteration: predict a new target position from the original target using the current time of flight → recompute distance from launcher to the predicted position → update time of flight.
  4. Return the final predicted target Translation2d.

angularVelocity(robot, fieldSpeeds)

Computes the tangent velocity of the launcher mount point due to robot rotation (ω × r), accounting for the launcher’s offset from the robot center of rotation.

Launcher offset (LAUNCHER_OFFSET)

The launcher is not mounted at the robot’s geometric center. LAUNCHER_OFFSET is a Transform2d from the robot pose to the launcher’s exit point: Use turretTransform() to retrieve the offset as a Transform2d, or launcherFromRobot(robotPose) to get the launcher offset’s Translation2d (the X/Y components of LAUNCHER_OFFSET relative to the robot center — note the current implementation returns the offset vector directly).

NetworkTables telemetry

UpdateNT(Pose2d robot) must be called each loop. It is called from Robot.robotPeriodic() (not from a subsystem periodic) using the current drivebase pose. It publishes two entries under /SmartDashboard/LiveLauncherData/:
To add a new calibration point for the comp bot, append a new LauncherDistanceDataPoint to compDistanceData with measured values from field testing. Keep the array sorted by distance — InterpolatingDoubleTreeMap is a sorted tree, but human readability is easier when the source array is ordered.