Class ShotGate
java.lang.Object
frc.robot.subsystems.ShotGate
Decides, once per loop, whether fuel may be fed into the flywheel. Pure logic:
SuperStructure fills an ShotGate.Inputs from logged inputs (motor inputs, the fused pose, the
Driver Station) and applies the ShotGate.Decision, so the whole gate replays and is unit tested.
FM on 2026 main fed the moment a launch state began. This is the offseason bot's feed
gate (commits dcb88dc, 067af02, ddd564a) with FM's drivetrain in place of that bot's turret:
- Start a volley only once the hood is within
ShotGate.Tolerances.hoodStartDeg, the heading within the aim tolerance, and the shot inside the model's range, all held forShotGate.Tolerances.settleSeconds. Flywheel speed is not checked: waiting for it slowed FM's shots. - Keep feeding on wider tolerances, so the volley is not chopped between balls. Range is not part of keeping: it comes from the pose, and one bad frame mid-volley would chop the feed.
- Time out: blocked for
ShotGate.Tolerances.timeoutSecondsin a launch state, feed anyway for the rest of that launch, so a stuck sensor or an unreachable target can delay a shot but never stop one. That is also what makes the gate safe in autos. - Override: the operator's bypass feeds while it is held.
Leaving the launch state resets everything, so the next volley re-earns the strict window.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhy the feed is being held, orShotGate.Blocker.NONE.static final recordThe gate's answer for one loop.static enumWhy fuel is (or is not) going in.static final recordOne loop's view of the shot, every field from a logged input or something computed from one.static final recordGate tolerances. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final doubleA fuel ball, 5.91 in (4499 uses 0.15 m).static final doubleHalf of the hub's 41.7 in inner opening (Field.BlueHub.innerOpeningWidth).static final doublestatic final double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleaimToleranceRad(double distanceMeters, boolean feedShot) Heading tolerance for a shot: 4499'satan((hubRadius - ballWidth) / distance), the angle at which a ball's edge reaches the rim, for hub shots; a flat 10 deg for feed shots, whose target is a patch of floor (9470 uses 10 deg for feed shots against 2.5 for the hub).Advances the gate one loop.
-
Field Details
-
HUB_OPENING_RADIUS_METERS
public static final double HUB_OPENING_RADIUS_METERSHalf of the hub's 41.7 in inner opening (Field.BlueHub.innerOpeningWidth).- See Also:
-
FUEL_DIAMETER_METERS
public static final double FUEL_DIAMETER_METERSA fuel ball, 5.91 in (4499 uses 0.15 m).- See Also:
-
MIN_AIM_TOLERANCE_RAD
public static final double MIN_AIM_TOLERANCE_RAD -
MAX_AIM_TOLERANCE_RAD
public static final double MAX_AIM_TOLERANCE_RAD -
FEED_AIM_TOLERANCE_RAD
public static final double FEED_AIM_TOLERANCE_RAD
-
-
Constructor Details
-
ShotGate
-
-
Method Details
-
getTolerances
-
aimToleranceRad
public static double aimToleranceRad(double distanceMeters, boolean feedShot) Heading tolerance for a shot: 4499'satan((hubRadius - ballWidth) / distance), the angle at which a ball's edge reaches the rim, for hub shots; a flat 10 deg for feed shots, whose target is a patch of floor (9470 uses 10 deg for feed shots against 2.5 for the hub). Clamped to 2 to 10 deg so a very long shot is not held to an angle the heading PID cannot settle to, and a very close one is not accepted at any heading.- Parameters:
distanceMeters- distance to the aim pointfeedShot- a feed (passing) shot rather than a hub shot- Returns:
- radians
-
update
Advances the gate one loop.- Parameters:
in- this loop's view of the shot- Returns:
- whether to feed, and why
-