Enum Class Perspective

java.lang.Object
java.lang.Enum<Perspective>
org.team1126.lib.swerve.Perspective
All Implemented Interfaces:
Serializable, Comparable<Perspective>, Constable

public enum Perspective extends Enum<Perspective>
Describes a forward (X+ direction) perspective for ChassisSpeeds.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    The speeds are relative to the blue alliance perspective.
    The speeds are relative to the operator's perspective.
    The speeds are relative to the red alliance perspective.
    The speeds are relative to the robot's perspective.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract edu.wpi.first.math.geometry.Rotation2d
    Gets the rotation to apply as the new zero when taring the robot's rotation to the perspective.
    abstract edu.wpi.first.math.kinematics.ChassisSpeeds
    toPerspectiveSpeeds(edu.wpi.first.math.kinematics.ChassisSpeeds speeds, edu.wpi.first.math.geometry.Rotation2d robotAngle)
    Converts robot relative speeds to the perspective relative speeds.
    abstract edu.wpi.first.math.kinematics.ChassisSpeeds
    toRobotSpeeds(edu.wpi.first.math.kinematics.ChassisSpeeds speeds, edu.wpi.first.math.geometry.Rotation2d robotAngle)
    Converts perspective relative speeds to robot relative speeds.
    Returns the enum constant of this class with the specified name.
    static Perspective[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • OPERATOR

      public static final Perspective OPERATOR
      The speeds are relative to the operator's perspective. If the robot is on the blue alliance, X+ drives towards the red alliance. If the robot is on the red alliance, X+ drives towards the blue alliance.
    • BLUE

      public static final Perspective BLUE
      The speeds are relative to the blue alliance perspective. X+ drives towards the red alliance.
    • RED

      public static final Perspective RED
      The speeds are relative to the red alliance perspective. X+ drives towards the blue alliance.
    • ROBOT

      public static final Perspective ROBOT
      The speeds are relative to the robot's perspective. X+ drives forwards relative to the chassis.
  • Method Details

    • values

      public static Perspective[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Perspective valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • toRobotSpeeds

      public abstract edu.wpi.first.math.kinematics.ChassisSpeeds toRobotSpeeds(edu.wpi.first.math.kinematics.ChassisSpeeds speeds, edu.wpi.first.math.geometry.Rotation2d robotAngle)
      Converts perspective relative speeds to robot relative speeds.
      Parameters:
      speeds - The perspective relative speeds to convert.
      robotAngle - The blue origin relative angle of the robot.
    • toPerspectiveSpeeds

      public abstract edu.wpi.first.math.kinematics.ChassisSpeeds toPerspectiveSpeeds(edu.wpi.first.math.kinematics.ChassisSpeeds speeds, edu.wpi.first.math.geometry.Rotation2d robotAngle)
      Converts robot relative speeds to the perspective relative speeds.
      Parameters:
      speeds - The robot relative speeds to convert.
      robotAngle - The blue origin relative angle of the robot.
    • getTareRotation

      public abstract edu.wpi.first.math.geometry.Rotation2d getTareRotation()
      Gets the rotation to apply as the new zero when taring the robot's rotation to the perspective.