This repository has been archived by the owner on Jul 21, 2024. It is now read-only.
-
I may be missing something completely obvious, and sorry if I am, but did the Any help is appreciated, and thanks in advance! |
Beta Was this translation helpful? Give feedback.
Answered by
calcmogul
Oct 23, 2023
Replies: 1 comment 3 replies
-
Here's what changed between 2023.4.3 and 2024.1.1 beta 2. diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModulePosition.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModulePosition.java
index 7968154ae..d058764f3 100644
--- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModulePosition.java
+++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveModulePosition.java
@@ -4,11 +4,14 @@
package edu.wpi.first.math.kinematics;
+import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.geometry.Rotation2d;
+import edu.wpi.first.math.interpolation.Interpolatable;
import java.util.Objects;
/** Represents the state of one swerve module. */
-public class SwerveModulePosition implements Comparable<SwerveModulePosition> {
+public class SwerveModulePosition
+ implements Comparable<SwerveModulePosition>, Interpolatable<SwerveModulePosition> {
/** Distance measured by the wheel of the module. */
public double distanceMeters;
@@ -60,4 +63,20 @@ public class SwerveModulePosition implements Comparable<SwerveModulePosition> {
return String.format(
"SwerveModulePosition(Distance: %.2f m, Angle: %s)", distanceMeters, angle);
}
+
+ /**
+ * Returns a copy of this swerve module position.
+ *
+ * @return A copy.
+ */
+ public SwerveModulePosition copy() {
+ return new SwerveModulePosition(distanceMeters, angle);
+ }
+
+ @Override
+ public SwerveModulePosition interpolate(SwerveModulePosition endValue, double t) {
+ return new SwerveModulePosition(
+ MathUtil.interpolate(this.distanceMeters, endValue.distanceMeters, t),
+ this.angle.interpolate(endValue.angle, t));
+ }
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
grappell
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's what changed between 2023.4.3 and 2024.1.1 beta 2.