Class WrappedRotation2d

java.lang.Object
edu.wpi.first.math.geometry.Rotation2d
xbot.common.math.WrappedRotation2d
All Implemented Interfaces:
Interpolatable<Rotation2d>, ProtobufSerializable, StructSerializable, WPISerializable

public class WrappedRotation2d extends Rotation2d
A rotation in a 2d coordinate frame, with its rotation wrapped from -pi to pi radians (-180 to 180 degrees). Prefer this class over Rotation2d when representing robot pose.
  • Constructor Details

    • WrappedRotation2d

      public WrappedRotation2d(double value)
      Constructs a WrappedRotation2d with the given radian value.
      Parameters:
      value - The value of the angle in radians.
    • WrappedRotation2d

      public WrappedRotation2d(double x, double y)
      Constructs a WrappedRotation2d with the given x and y (cosine and sine) components. The x and y don't have to be normalized.
      Parameters:
      x - The x component or cosine of the rotation.
      y - The y component or sine of the rotation.
  • Method Details

    • fromRotation2d

      public static WrappedRotation2d fromRotation2d(Rotation2d rotation)
      Converts a Rotation2d to the wrapped equivalent.
      Parameters:
      rotation - The rotation.
      Returns:
      The rotation with its angle wrapped from -pi to pi radians.
    • fromDegrees

      public static WrappedRotation2d fromDegrees(double degrees)
      Constructs and returns a Rotation2d with the given degree value.
      Parameters:
      degrees - The value of the angle in degrees.
      Returns:
      The rotation object with the desired angle value.