Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/robototes/REBUILT2026/llms.txt

Use this file to discover all available pages before exploring further.

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:
FieldTypeUnitDescription
distancedoublemetersDistance from the launcher to the target
hoodAngledoublerotationsHood angle setpoint at this distance
flywheelPowerdoubleRPSFlywheel velocity setpoint at this distance
timedoublesecondsEstimated projectile time of flight
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.
Distance (m)Hood Angle (rot)Flywheel (RPS)Time of Flight (s)
1.01.5401.018
1.52.0421.138
2.03.0431.104
2.553.5451.204
3.24.5481.150
3.54.8511.229
3.755.051.51.217
4.25.12553.51.275
4.55.5581.305
5.05.8601.349
5.86.6641.378
8.09.0901.530
private static final LauncherDistanceDataPoint[] compDistanceData = {
  new LauncherDistanceDataPoint(1,    1.5,   40,   1.018),
  new LauncherDistanceDataPoint(1.5,  2,     42,   1.138),
  new LauncherDistanceDataPoint(2,    3,     43,   1.104),
  new LauncherDistanceDataPoint(2.55, 3.5,   45,   1.204),
  new LauncherDistanceDataPoint(3.2,  4.5,   48,   1.15),
  new LauncherDistanceDataPoint(3.5,  4.8,   51,   1.229),
  new LauncherDistanceDataPoint(3.75, 5,     51.5, 1.217),
  new LauncherDistanceDataPoint(4.2,  5.125, 53.5, 1.275),
  new LauncherDistanceDataPoint(4.5,  5.5,   58,   1.305),
  new LauncherDistanceDataPoint(5,    5.8,   60,   1.349),
  new LauncherDistanceDataPoint(5.8,  6.6,   64,   1.378),
  new LauncherDistanceDataPoint(8,    9,     90,   1.53)
};

Alpha bot lookup table

The alpha bot uses a simpler 4-point table (different hood geometry and gear ratio):
Distance (m)Hood Angle (rot)Flywheel (RPS)Time of Flight (s)
1.00.1550.7
2.00.3591.3
3.00.6651.6
4.01.2711.9

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:
private static final InterpolatingDoubleTreeMap flywheelMap = new InterpolatingDoubleTreeMap();
private static final InterpolatingDoubleTreeMap hoodMap     = new InterpolatingDoubleTreeMap();
private static final InterpolatingDoubleTreeMap timeMap     = new InterpolatingDoubleTreeMap();

static {
  LauncherDistanceDataPoint[] distanceData =
      RobotType.isAlpha() ? alphaDistanceData : compDistanceData;
  for (var point : distanceData) {
    flywheelMap.put(point.distance, point.flywheelPower);
    hoodMap.put(point.distance, point.hoodAngle);
    timeMap.put(point.distance, point.time);
  }
}
Distances outside the table’s range clamp to the nearest endpoint (WPILib InterpolatingDoubleTreeMap behavior).

Static lookup methods

MethodReturnsDescription
getFlywheelSpeedFromDistance(distance)double (RPS)Interpolated flywheel velocity for a given distance
getHoodAngleFromDistance(distance)double (rot)Interpolated hood angle for a given distance
getTimeFromDistance(distance)double (s)Interpolated time of flight for a given distance
minTimeOfFlight()double (s)Minimum time across all data points (used by HubShiftUtil)
maxTimeOfFlight()double (s)Maximum time across all data points (used by HubShiftUtil)
distToHub()double (m)Last computed turret-to-hub distance, floored at 0.1 m

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:
public static Translation2d predictTargetPos(
    Translation2d target, ChassisSpeeds fieldSpeeds, Double timeOfFlight, Pose2d robot) {
  Translation2d angularVelocity = angularVelocity(robot, fieldSpeeds);
  double vx = fieldSpeeds.vxMetersPerSecond + angularVelocity.getX();
  double vy = fieldSpeeds.vyMetersPerSecond + angularVelocity.getY();
  double predictedX = target.getX() - vx * timeOfFlight;
  double predictedY = target.getY() - vy * timeOfFlight;
  return new Translation2d(predictedX, predictedY);
}

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:
RobotX offsetY offset
Competition+0.2159 m (forward)+0.1397 m (left)
Alpha+0.2159 m (forward)−0.1397 m (right)
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/:
NT KeyTypeContent
Turret PosePose2d structRobot pose transformed by LAUNCHER_OFFSET
Turret to hub distancedoubleDistance from the turret to the alliance hub (meters)
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.

Build docs developers (and LLMs) love