From 2ba8fbb6f488eb83f11ebb63af22b16079cd8de6 Mon Sep 17 00:00:00 2001 From: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com> Date: Mon, 24 Jul 2023 22:46:59 -0700 Subject: [PATCH] [wpimath] Improve documentation for SwerveModulePosition::operator- (#5468) --- .../first/math/kinematics/SwerveModulePosition.java | 3 ++- .../edu/wpi/first/math/kinematics/WheelPositions.java | 2 +- .../include/frc/kinematics/SwerveModulePosition.h | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) 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 b418744be3..994041b289 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 @@ -76,7 +76,8 @@ public class SwerveModulePosition /** * Calculates the difference between two swerve module positions. The difference has a length * equal to the difference in lengths and an angle equal to the ending angle (this module - * position's angle). + * position's angle). This is suitable for representing a module's motion between two timesteps, + * because the final angle describes the direction the module moved. * * @param other The swerve module position to subtract. * @return The difference. diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/WheelPositions.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/WheelPositions.java index 13888b3ea5..67e869c094 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/WheelPositions.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/WheelPositions.java @@ -15,7 +15,7 @@ public interface WheelPositions> extends Interpolata T copy(); /** - * Returns the difference with another set of wheel positions. + * Returns a representation of how the wheels moved from other to this. * * @param other The other instance to compare to. * @return The representation of how the wheels moved from other to this. diff --git a/wpimath/src/main/native/include/frc/kinematics/SwerveModulePosition.h b/wpimath/src/main/native/include/frc/kinematics/SwerveModulePosition.h index 63f68256ee..6ae65173e2 100644 --- a/wpimath/src/main/native/include/frc/kinematics/SwerveModulePosition.h +++ b/wpimath/src/main/native/include/frc/kinematics/SwerveModulePosition.h @@ -35,6 +35,16 @@ struct WPILIB_DLLEXPORT SwerveModulePosition { */ bool operator==(const SwerveModulePosition& other) const; + /** + * Calculates the difference between two swerve module positions. The + * difference has a length equal to the difference in lengths and an angle + * equal to the ending angle (this module position's angle). This is suitable + * for representing a module's motion between two timesteps, because the final + * angle describes the direction the module moved. + * + * @param other The other swerve module position to subtract. + * @return The difference. + */ SwerveModulePosition operator-(const SwerveModulePosition& other) const { return {distance - other.distance, angle}; }