Package frc.lib.util
Class FieldUtil
java.lang.Object
frc.lib.util.FieldUtil
Utility class for performing field geometry operations that automatically flip based on the
current alliance color.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Pose2dflipAlliance(Pose2d pose) Forces a flip of aPose2dto the opposite side of the field.static Rectangle2dflipAlliance(Rectangle2d rectangle) Forces a flip of aRectangle2dto the opposite side of the field.static Rotation2dflipAlliance(Rotation2d rotation) Forces a flip of aRotation2dto the opposite side of the field.static Translation2dflipAlliance(Translation2d translation) Forces a flip of aTranslation2dto the opposite side of the field.static Pose2dflipAllianceIfNeeded(Pose2d pose) Flips aPose2dto the opposite side of the field if on the Red alliance.static Rectangle2dflipAllianceIfNeeded(Rectangle2d rectangle) Flips aRectangle2dto the opposite side of the field if on the Red alliance.static Rotation2dflipAllianceIfNeeded(Rotation2d rotation) Flips aRotation2dto the opposite side of the field if on the Red alliance.static Translation2dflipAllianceIfNeeded(Translation2d translation) Flips aTranslation2dto the opposite side of the field if on the Red alliance.static booleanChecks if the robot needs to flip its coordinate system for the Red alliance.
-
Field Details
-
FIELD_LENGTH
Total length of the field. -
FIELD_WIDTH
Total width of the field.
-
-
Method Details
-
shouldFlip
public static boolean shouldFlip()Checks if the robot needs to flip its coordinate system for the Red alliance.- Returns:
- True if on the Red alliance, false if Blue or unknown.
-
flipAllianceIfNeeded
Flips aRectangle2dto the opposite side of the field if on the Red alliance.- Parameters:
rectangle- The rectangle to flip.- Returns:
- The flipped rectangle, or the original if not needed.
-
flipAllianceIfNeeded
Flips aPose2dto the opposite side of the field if on the Red alliance.- Parameters:
pose- The pose to flip.- Returns:
- The flipped pose, or the original if not needed.
-
flipAllianceIfNeeded
Flips aTranslation2dto the opposite side of the field if on the Red alliance.- Parameters:
translation- The translation to flip.- Returns:
- The flipped translation, or the original if not needed.
-
flipAllianceIfNeeded
Flips aRotation2dto the opposite side of the field if on the Red alliance.- Parameters:
rotation- The rotation to flip.- Returns:
- The flipped rotation, or the original if not needed.
-
flipAlliance
Forces a flip of aRectangle2dto the opposite side of the field.- Parameters:
rectangle- The rectangle to flip.- Returns:
- The flipped rectangle.
-
flipAlliance
Forces a flip of aPose2dto the opposite side of the field.- Parameters:
pose- The pose to flip.- Returns:
- The flipped pose.
-
flipAlliance
Forces a flip of aTranslation2dto the opposite side of the field.- Parameters:
translation- The translation to flip.- Returns:
- The flipped translation.
-
flipAlliance
Forces a flip of aRotation2dto the opposite side of the field.- Parameters:
rotation- The rotation to flip.- Returns:
- The flipped rotation.
-