Package frc.lib.math
Class GeomUtil
java.lang.Object
frc.lib.math.GeomUtil
Geometry utilities for working with translations, rotations, transforms, and poses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic edu.wpi.first.math.geometry.Rotation2dgetSmallestChangeInRotation(edu.wpi.first.math.geometry.Rotation2d rotation1, edu.wpi.first.math.geometry.Rotation2d rotation2) static edu.wpi.first.math.geometry.Pose2dinverse(edu.wpi.first.math.geometry.Pose2d pose) static edu.wpi.first.math.geometry.Twist2dmultiply(edu.wpi.first.math.geometry.Twist2d twist, double factor) Multiplies a twist by a scaling factorstatic edu.wpi.first.math.geometry.Pose2dtoPose2d(edu.wpi.first.math.geometry.Rotation2d rotation) Creates a pure rotated posestatic edu.wpi.first.math.geometry.Pose2dtoPose2d(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 chainstatic edu.wpi.first.math.geometry.Pose2dtoPose2d(edu.wpi.first.math.geometry.Translation2d translation) Creates a pure translated posestatic edu.wpi.first.math.geometry.Pose3dtoPose3d(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 chainstatic edu.wpi.first.math.geometry.Transform2dtoTransform2d(edu.wpi.first.math.geometry.Pose2d pose) Converts a Pose2d to a Transform2d to be used in a kinematic chainstatic edu.wpi.first.math.geometry.Transform2dtoTransform2d(edu.wpi.first.math.geometry.Rotation2d rotation) Creates a pure rotating transformstatic edu.wpi.first.math.geometry.Transform2dtoTransform2d(edu.wpi.first.math.geometry.Translation2d translation) Creates a pure translating transformstatic edu.wpi.first.math.geometry.Transform3dtoTransform3d(edu.wpi.first.math.geometry.Pose3d pose) Converts a Pose3d to a Transform3d to be used in a kinematic chainstatic edu.wpi.first.math.geometry.Twist2dtoTwist2d(edu.wpi.first.math.kinematics.ChassisSpeeds speeds) Converts a ChassisSpeeds to a Twist2d by extracting two dimensions (Y and Z).
-
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 multiplyfactor- 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)
-