Package choreo.util

Class AllianceFlipUtil

java.lang.Object
choreo.util.AllianceFlipUtil

public class AllianceFlipUtil extends Object
A utility to standardize flipping of coordinate data based on the current alliance across different years.

If every vendor used this, the user would be able to specify the year and no matter the year the vendor's code is from, the user would be able to flip as expected.

This API still allows vendors and users to match case against the flipping variant as a way to specially handle cases or throw errors if a variant is explicitly not supported.

  • Method Details

    • getFlipper

      Get the flipper that is currently active for flipping coordinates. It's recommended not to store this locally as the flipper may change.
      Returns:
      The active flipper.
    • shouldFlip

      public static boolean shouldFlip()
      Returns if you are on red alliance.
      Returns:
      If you are on red alliance.
    • setYear

      public static void setYear(int year)
      Set the year to determine the Alliance Coordinate Flipper to use.
      Parameters:
      year - The year to set the flipper to. [2020 - 2024]
    • flipX

      public static double flipX(double x)
      Flips the X coordinate.
      Parameters:
      x - The X coordinate to flip.
      Returns:
      The flipped X coordinate.
    • flipY

      public static double flipY(double y)
      Flips the Y coordinate.
      Parameters:
      y - The Y coordinate to flip.
      Returns:
      The flipped Y coordinate.
    • flipHeading

      public static double flipHeading(double heading)
      Flips the heading.
      Parameters:
      heading - The heading to flip.
      Returns:
      The flipped heading.
    • flip

      public static Translation2d flip(Translation2d translation)
      Flips the translation.
      Parameters:
      translation - The translation to flip.
      Returns:
      The flipped translation.
    • flip

      public static Rotation2d flip(Rotation2d rotation)
      Flips the rotation.
      Parameters:
      rotation - The rotation to flip.
      Returns:
      The flipped rotation.
    • flip

      public static Pose2d flip(Pose2d pose)
      Flips the pose.
      Parameters:
      pose - The pose to flip.
      Returns:
      The flipped pose.
    • flip

      public static Translation3d flip(Translation3d translation)
      Flips the translation.
      Parameters:
      translation - The translation to flip.
      Returns:
      The flipped translation.
    • flip

      public static Rotation3d flip(Rotation3d rotation)
      Flips the rotation.
      Parameters:
      rotation - The rotation to flip.
      Returns:
      The flipped rotation.
    • flip

      public static Pose3d flip(Pose3d pose)
      Flips the pose.
      Parameters:
      pose - The pose to flip.
      Returns:
      The flipped pose.