Package frc.reefscape

Class FieldHelpers

java.lang.Object
frc.reefscape.FieldHelpers

public class FieldHelpers extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Converts a given Reef Tag Id into index form for center faces to pull from
    static int
    blueToRedTagID(int blueTagID)
    Converts a blue reef tag ID to a red reef tag ID
    static double
    flipAngle(double angle)
     
    static edu.wpi.first.math.geometry.Rotation2d
    flipAngle(edu.wpi.first.math.geometry.Rotation2d angle)
     
    static double
    flipAngleIfRed(double blue)
     
    static edu.wpi.first.math.geometry.Rotation2d
    flipAngleIfRed(edu.wpi.first.math.geometry.Rotation2d blue)
     
    static edu.wpi.first.math.geometry.Pose2d
    flipIfRed(edu.wpi.first.math.geometry.Pose2d red)
     
    static edu.wpi.first.math.geometry.Translation2d
    flipIfRed(edu.wpi.first.math.geometry.Translation2d blue)
     
    static edu.wpi.first.math.geometry.Translation3d
    flipIfRed(edu.wpi.first.math.geometry.Translation3d blue)
     
    static edu.wpi.first.math.geometry.Pose2d
    flipIfRedSide(edu.wpi.first.math.geometry.Pose2d red)
     
    static edu.wpi.first.math.geometry.Translation2d
    flipIfRedSide(edu.wpi.first.math.geometry.Translation2d red)
     
    static double
    flipX(double xCoordinate)
     
    static double
    flipXifRed(double xCoordinate)
     
    static double
    flipY(double yCoordinate)
     
    static double
    flipYifRed(double yCoordinate)
     
    static edu.wpi.first.math.geometry.Pose2d
    getOffsetPosition(int tagID, double offsetMeters, double offsetRadians)
     
    static double
     
    static double
     
    static edu.wpi.first.math.geometry.Pose2d
    getReefSideFromTagID(int faceIndex)
    Returns the reef face pose based on the tag ID sent from either red or blue
    static double
    Get the angle the robot should turn to based on the id the limelight is seeing.
    static int
    getReefZone(edu.wpi.first.math.geometry.Pose2d pose)
    Returns the reef index zone based on the robot's pose changed to blue pose including the center is consistently blue center
    static int
    getReefZoneTagID(edu.wpi.first.math.geometry.Pose2d pose)
    Returns the reef tag ID based on the robot's pose
    static edu.wpi.first.math.geometry.Pose2d
    getScorePoseFromTagID(int blueReefTagID)
    Returns the score pose based on the reef tag ID received by the limelight
    static double
    getTagAngleOffset(int tagID)
     
    static edu.wpi.first.math.geometry.Pose2d
    getXYOffsetFromTag(int tagID, double distanceAway, double centerOffset)
    Method gets
    static int
    indexOfSmallest(double[] array)
     
    static int
    indexToReefTagID(int index)
    Converts an index to a reef tag ID
    static double
    offSetMeters(int tagID)
     
    static boolean
    poseOutOfField(edu.wpi.first.math.geometry.Pose2d pose2D)
     
    static boolean
    poseOutOfField(edu.wpi.first.math.geometry.Pose3d pose3D)
     
    static int
    redToBlueTagID(int redTagID)
     
    static boolean
    Converts a target angle into a reverse rotation if the back is closer; otherwise, returns the original target angle for front heading.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FieldHelpers

      public FieldHelpers()
  • Method Details

    • flipAngle

      public static double flipAngle(double angle)
    • flipAngle

      public static edu.wpi.first.math.geometry.Rotation2d flipAngle(edu.wpi.first.math.geometry.Rotation2d angle)
    • flipAngleIfRed

      public static double flipAngleIfRed(double blue)
    • flipAngleIfRed

      public static edu.wpi.first.math.geometry.Rotation2d flipAngleIfRed(edu.wpi.first.math.geometry.Rotation2d blue)
    • flipIfRed

      public static edu.wpi.first.math.geometry.Translation2d flipIfRed(edu.wpi.first.math.geometry.Translation2d blue)
    • flipIfRed

      public static edu.wpi.first.math.geometry.Translation3d flipIfRed(edu.wpi.first.math.geometry.Translation3d blue)
    • flipIfRed

      public static edu.wpi.first.math.geometry.Pose2d flipIfRed(edu.wpi.first.math.geometry.Pose2d red)
    • flipIfRedSide

      public static edu.wpi.first.math.geometry.Translation2d flipIfRedSide(edu.wpi.first.math.geometry.Translation2d red)
    • flipIfRedSide

      public static edu.wpi.first.math.geometry.Pose2d flipIfRedSide(edu.wpi.first.math.geometry.Pose2d red)
    • flipX

      public static double flipX(double xCoordinate)
    • flipY

      public static double flipY(double yCoordinate)
    • flipXifRed

      public static double flipXifRed(double xCoordinate)
    • flipYifRed

      public static double flipYifRed(double yCoordinate)
    • poseOutOfField

      public static boolean poseOutOfField(edu.wpi.first.math.geometry.Pose2d pose2D)
    • poseOutOfField

      public static boolean poseOutOfField(edu.wpi.first.math.geometry.Pose3d pose3D)
    • indexOfSmallest

      public static int indexOfSmallest(double[] array)
    • indexToReefTagID

      public static int indexToReefTagID(int index)
      Converts an index to a reef tag ID
      Parameters:
      index -
      Returns:
    • blueReefTagIDToIndex

      public static int blueReefTagIDToIndex(int tagID)
      Converts a given Reef Tag Id into index form for center faces to pull from
      Parameters:
      tagID -
      Returns:
    • blueToRedTagID

      public static int blueToRedTagID(int blueTagID)
      Converts a blue reef tag ID to a red reef tag ID
      Parameters:
      blueTagID -
      Returns:
    • redToBlueTagID

      public static int redToBlueTagID(int redTagID)
    • getReefZoneTagID

      public static int getReefZoneTagID(edu.wpi.first.math.geometry.Pose2d pose)
      Returns the reef tag ID based on the robot's pose
      Parameters:
      pose -
      Returns:
    • getReefZone

      public static int getReefZone(edu.wpi.first.math.geometry.Pose2d pose)
      Returns the reef index zone based on the robot's pose changed to blue pose including the center is consistently blue center
      Parameters:
      pose -
      Returns:
    • getOffsetPosition

      public static edu.wpi.first.math.geometry.Pose2d getOffsetPosition(int tagID, double offsetMeters, double offsetRadians)
    • reverseRotationBlue

      public static boolean reverseRotationBlue()
      Converts a target angle into a reverse rotation if the back is closer; otherwise, returns the original target angle for front heading.

      variable robotAngle The current angle of the robot in radians. variable reefRotation The rotation adjustment factor in radians. targetAngle The desired target angle in radians.

      Returns:
      true/false if robot heading is reversed to reef face
    • getReefSideFromTagID

      public static edu.wpi.first.math.geometry.Pose2d getReefSideFromTagID(int faceIndex)
      Returns the reef face pose based on the tag ID sent from either red or blue
      Parameters:
      tagID -
      Returns:
      Pose2d of reef side
    • getScorePoseFromTagID

      public static edu.wpi.first.math.geometry.Pose2d getScorePoseFromTagID(int blueReefTagID)
      Returns the score pose based on the reef tag ID received by the limelight
      Parameters:
      blueReefTagID - may also be a red reef tag ID that will later be converted from a blue reef tagID
      Returns:
    • offSetMeters

      public static double offSetMeters(int tagID)
    • getTagAngleOffset

      public static double getTagAngleOffset(int tagID)
    • getXYOffsetFromTag

      public static edu.wpi.first.math.geometry.Pose2d getXYOffsetFromTag(int tagID, double distanceAway, double centerOffset)
      Method gets
      Parameters:
      tagID -
      distanceAway -
      centerOffset -
      Returns:
    • getReefOffsetFromTagX

      public static double getReefOffsetFromTagX()
    • getReefOffsetFromTagY

      public static double getReefOffsetFromTagY()
    • getReefTagAngle

      public static double getReefTagAngle()
      Get the angle the robot should turn to based on the id the limelight is seeing.
      Returns: