Class ExtRotation

java.lang.Object
org.team1126.lib.math.geometry.ExtRotation
All Implemented Interfaces:
Supplier<edu.wpi.first.math.geometry.Rotation2d>, Tunables.Tunable

public final class ExtRotation extends Object
A container for Rotation2d objects that enables live tuning via NetworkTables, and dynamically returns flipped variants of the original rotation based on the robot's current alliance via Supplier.get().
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected edu.wpi.first.math.geometry.Rotation2d
     
    protected edu.wpi.first.math.geometry.Rotation2d
     
    protected edu.wpi.first.math.geometry.Rotation2d
     
    protected edu.wpi.first.math.geometry.Rotation2d
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExtRotation(double value)
    Creates an extended Rotation2d.
    ExtRotation(double x, double y)
    Creates an extended Rotation2d.
    ExtRotation(edu.wpi.first.math.geometry.Rotation2d rotation)
    Creates an extended Rotation2d.
  • Method Summary

    Modifier and Type
    Method
    Description
    fromDegrees(double degrees)
    Constructs and returns an extended Rotation2d with the given degree value.
    fromRadians(double radians)
    Constructs and returns an extended Rotation2d with the given radian value.
    fromRotations(double rotations)
    Constructs and returns an extended Rotation2d with the given rotations value.
    edu.wpi.first.math.geometry.Rotation2d
    get()
    Gets the value for the robot's current alliance.
    edu.wpi.first.math.geometry.Rotation2d
    get(boolean flipWidth)
    Gets the value for the robot's current alliance.
    edu.wpi.first.math.geometry.Rotation2d
    get(boolean blue, boolean flipWidth)
    Gets the value for the specified alliance.
    edu.wpi.first.math.geometry.Rotation2d
    Gets the value for the blue alliance.
    edu.wpi.first.math.geometry.Rotation2d
    getBlue(boolean flipWidth)
    Gets the value for the blue alliance.
    edu.wpi.first.math.geometry.Rotation2d
    Gets the value for the red alliance.
    edu.wpi.first.math.geometry.Rotation2d
    getRed(boolean flipWidth)
    Gets the value for the red alliance.
    void
    Initializes the object to be tuned.
    protected void
    set(edu.wpi.first.math.geometry.Rotation2d newValue)
    Saves a new value to the container, with all flipped variations.

    Methods inherited from class java.lang.Object

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

    • original

      protected edu.wpi.first.math.geometry.Rotation2d original
    • overWidth

      protected edu.wpi.first.math.geometry.Rotation2d overWidth
    • overLength

      protected edu.wpi.first.math.geometry.Rotation2d overLength
    • overDiagonal

      protected edu.wpi.first.math.geometry.Rotation2d overDiagonal
  • Constructor Details

    • ExtRotation

      public ExtRotation(double value)
      Creates an extended Rotation2d.
      Parameters:
      value - The blue origin relative value of the angle in radians.
    • ExtRotation

      public ExtRotation(double x, double y)
      Creates an extended Rotation2d.
      Parameters:
      x - The blue origin relative x component or cosine of the rotation.
      y - The blue origin relative y component or sine of the rotation.
    • ExtRotation

      public ExtRotation(edu.wpi.first.math.geometry.Rotation2d rotation)
      Creates an extended Rotation2d.
      Parameters:
      rotation - The blue origin relative rotation.
  • Method Details

    • fromRadians

      public static ExtRotation fromRadians(double radians)
      Constructs and returns an extended Rotation2d with the given radian value.
      Parameters:
      radians - The blue origin relative value of the angle in radians.
    • fromDegrees

      public static ExtRotation fromDegrees(double degrees)
      Constructs and returns an extended Rotation2d with the given degree value.
      Parameters:
      degrees - The blue origin relative value of the angle in degrees.
    • fromRotations

      public static ExtRotation fromRotations(double rotations)
      Constructs and returns an extended Rotation2d with the given rotations value.
      Parameters:
      rotations - The blue origin relative value of the angle in rotations.
    • set

      protected void set(edu.wpi.first.math.geometry.Rotation2d newValue)
      Saves a new value to the container, with all flipped variations. This method is invoked in the constructor, and can also be utilized by Tunables.Tunable.initTunable(TunableTable).

      This method should implement setting the values of original, overWidth, overLength, and overDiagonal.

      Parameters:
      newValue - The new blue origin relative value.
    • initTunable

      public void initTunable(TunableTable table)
      Description copied from interface: Tunables.Tunable
      Initializes the object to be tuned. This method is called when adding the object to a TunableTable.
      Parameters:
      table - The table the object is being added to.
    • get

      public edu.wpi.first.math.geometry.Rotation2d get()
      Gets the value for the robot's current alliance. Flipping behavior is inherited from FieldInfo.symmetryType().
      Specified by:
      get in interface Supplier<T>
    • get

      public edu.wpi.first.math.geometry.Rotation2d get(boolean flipWidth)
      Gets the value for the robot's current alliance. Flipping behavior is inherited from FieldInfo.symmetryType().
      Parameters:
      flipWidth - If the value should also be flipped over the field's width, regardless of the robot's alliance.
    • get

      public edu.wpi.first.math.geometry.Rotation2d get(boolean blue, boolean flipWidth)
      Gets the value for the specified alliance. Flipping behavior is inherited from FieldInfo.symmetryType().
      Parameters:
      blue - If the blue alliance value should be returned.
      flipWidth - If the value should also be flipped over the field's width, regardless of the alliance.
    • getBlue

      public edu.wpi.first.math.geometry.Rotation2d getBlue()
      Gets the value for the blue alliance.
    • getBlue

      public edu.wpi.first.math.geometry.Rotation2d getBlue(boolean flipWidth)
      Gets the value for the blue alliance.
      Parameters:
      flipWidth - If the value should also be flipped over the field's width.
    • getRed

      public edu.wpi.first.math.geometry.Rotation2d getRed()
      Gets the value for the red alliance.
    • getRed

      public edu.wpi.first.math.geometry.Rotation2d getRed(boolean flipWidth)
      Gets the value for the red alliance.
      Parameters:
      flipWidth - If the value should also be flipped over the field's width.