Package frc.robot.shared.field
Class FieldTargetSelector
java.lang.Object
frc.robot.shared.field.FieldTargetSelector
Selects the active field target for the turret based on the robot's position and alliance color.
When the robot is in its alliance zone, the turret aims at the Alliance Hub. When the robot is in the neutral zone (collecting fuel), the turret aims at whichever alliance-zone rally point is closer based on the robot's Y position. All positions are configured from the Blue alliance perspective and mirrored at runtime for Red.
-
Constructor Summary
ConstructorsConstructorDescriptionFieldTargetSelector(FieldTargetConfig config, Supplier<edu.wpi.first.math.geometry.Pose2d> robotPoseSupplier, Supplier<Optional<edu.wpi.first.wpilibj.DriverStation.Alliance>> allianceSupplier) Creates a field target selector that evaluates position and alliance each time a target is requested. -
Method Summary
Modifier and TypeMethodDescriptionReturns a human-readable name for the active field target based on the robot's current zone and alliance.edu.wpi.first.math.geometry.Translation2dComputes the active field target position based on the robot's current zone and alliance.
-
Constructor Details
-
Method Details
-
getActiveTargetPosition
public edu.wpi.first.math.geometry.Translation2d getActiveTargetPosition()Computes the active field target position based on the robot's current zone and alliance.Call this each cycle to get the turret's tracking target. The returned position accounts for alliance-based coordinate mirroring so callers always receive field-relative meters.
- Returns:
- field-relative target position in meters
-
getActiveTargetName
Returns a human-readable name for the active field target based on the robot's current zone and alliance.Use this for operator telemetry so drivers can see whether the turret is aiming at the hub or a rally point.
- Returns:
- display name of the active target: "Hub", "Left Rally", or "Right Rally"
-