Package frc.lib.math

Class GeomUtil

java.lang.Object
frc.lib.math.GeomUtil

public class GeomUtil extends Object
Geometry utilities for working with translations, rotations, transforms, and poses.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static edu.wpi.first.math.geometry.Rotation2d
    getSmallestChangeInRotation(edu.wpi.first.math.geometry.Rotation2d rotation1, edu.wpi.first.math.geometry.Rotation2d rotation2)
     
    static edu.wpi.first.math.geometry.Pose2d
    inverse(edu.wpi.first.math.geometry.Pose2d pose)
     
    static edu.wpi.first.math.geometry.Twist2d
    multiply(edu.wpi.first.math.geometry.Twist2d twist, double factor)
    Multiplies a twist by a scaling factor
    static edu.wpi.first.math.geometry.Pose2d
    toPose2d(edu.wpi.first.math.geometry.Rotation2d rotation)
    Creates a pure rotated pose
    static edu.wpi.first.math.geometry.Pose2d
    toPose2d(edu.wpi.first.math.geometry.Transform2d transform)
    Converts a Transform2d to a Pose2d to be used as a position or as the start of a kinematic chain
    static edu.wpi.first.math.geometry.Pose2d
    toPose2d(edu.wpi.first.math.geometry.Translation2d translation)
    Creates a pure translated pose
    static edu.wpi.first.math.geometry.Pose3d
    toPose3d(edu.wpi.first.math.geometry.Transform3d transform)
    Converts a Transform3d to a Pose3d to be used as a position or as the start of a kinematic chain
    static edu.wpi.first.math.geometry.Transform2d
    toTransform2d(edu.wpi.first.math.geometry.Pose2d pose)
    Converts a Pose2d to a Transform2d to be used in a kinematic chain
    static edu.wpi.first.math.geometry.Transform2d
    toTransform2d(edu.wpi.first.math.geometry.Rotation2d rotation)
    Creates a pure rotating transform
    static edu.wpi.first.math.geometry.Transform2d
    toTransform2d(edu.wpi.first.math.geometry.Translation2d translation)
    Creates a pure translating transform
    static edu.wpi.first.math.geometry.Transform3d
    toTransform3d(edu.wpi.first.math.geometry.Pose3d pose)
    Converts a Pose3d to a Transform3d to be used in a kinematic chain
    static edu.wpi.first.math.geometry.Twist2d
    toTwist2d(edu.wpi.first.math.kinematics.ChassisSpeeds speeds)
    Converts a ChassisSpeeds to a Twist2d by extracting two dimensions (Y and Z).

    Methods inherited from class java.lang.Object

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

    • GeomUtil

      public GeomUtil()
  • Method Details

    • toTransform2d

      public static edu.wpi.first.math.geometry.Transform2d toTransform2d(edu.wpi.first.math.geometry.Translation2d translation)
      Creates a pure translating transform
      Parameters:
      translation - The translation to create the transform with
      Returns:
      The resulting transform
    • toTransform2d

      public static edu.wpi.first.math.geometry.Transform2d toTransform2d(edu.wpi.first.math.geometry.Rotation2d rotation)
      Creates a pure rotating transform
      Parameters:
      rotation - The rotation to create the transform with
      Returns:
      The resulting transform
    • toTransform2d

      public static edu.wpi.first.math.geometry.Transform2d toTransform2d(edu.wpi.first.math.geometry.Pose2d pose)
      Converts a Pose2d to a Transform2d to be used in a kinematic chain
      Parameters:
      pose - The pose that will represent the transform
      Returns:
      The resulting transform
    • inverse

      public static edu.wpi.first.math.geometry.Pose2d inverse(edu.wpi.first.math.geometry.Pose2d pose)
    • toPose2d

      public static edu.wpi.first.math.geometry.Pose2d toPose2d(edu.wpi.first.math.geometry.Transform2d transform)
      Converts a Transform2d to a Pose2d to be used as a position or as the start of a kinematic chain
      Parameters:
      transform - The transform that will represent the pose
      Returns:
      The resulting pose
    • toPose2d

      public static edu.wpi.first.math.geometry.Pose2d toPose2d(edu.wpi.first.math.geometry.Translation2d translation)
      Creates a pure translated pose
      Parameters:
      translation - The translation to create the pose with
      Returns:
      The resulting pose
    • toPose2d

      public static edu.wpi.first.math.geometry.Pose2d toPose2d(edu.wpi.first.math.geometry.Rotation2d rotation)
      Creates a pure rotated pose
      Parameters:
      rotation - The rotation to create the pose with
      Returns:
      The resulting pose
    • multiply

      public static edu.wpi.first.math.geometry.Twist2d multiply(edu.wpi.first.math.geometry.Twist2d twist, double factor)
      Multiplies a twist by a scaling factor
      Parameters:
      twist - The twist to multiply
      factor - The scaling factor for the twist components
      Returns:
      The new twist
    • toTransform3d

      public static edu.wpi.first.math.geometry.Transform3d toTransform3d(edu.wpi.first.math.geometry.Pose3d pose)
      Converts a Pose3d to a Transform3d to be used in a kinematic chain
      Parameters:
      pose - The pose that will represent the transform
      Returns:
      The resulting transform
    • toPose3d

      public static edu.wpi.first.math.geometry.Pose3d toPose3d(edu.wpi.first.math.geometry.Transform3d transform)
      Converts a Transform3d to a Pose3d to be used as a position or as the start of a kinematic chain
      Parameters:
      transform - The transform that will represent the pose
      Returns:
      The resulting pose
    • toTwist2d

      public static edu.wpi.first.math.geometry.Twist2d toTwist2d(edu.wpi.first.math.kinematics.ChassisSpeeds speeds)
      Converts a ChassisSpeeds to a Twist2d by extracting two dimensions (Y and Z). chain
      Parameters:
      speeds - The original translation
      Returns:
      The resulting translation
    • getSmallestChangeInRotation

      public static edu.wpi.first.math.geometry.Rotation2d getSmallestChangeInRotation(edu.wpi.first.math.geometry.Rotation2d rotation1, edu.wpi.first.math.geometry.Rotation2d rotation2)