Package edu.wpi.first.math.kinematics
Class SwerveModulePosition
java.lang.Object
edu.wpi.first.math.kinematics.SwerveModulePosition
- All Implemented Interfaces:
Interpolatable<SwerveModulePosition>
,Comparable<SwerveModulePosition>
public class SwerveModulePosition extends Object implements Comparable<SwerveModulePosition>, Interpolatable<SwerveModulePosition>
Represents the state of one swerve module.
-
Field Summary
Fields Modifier and Type Field Description Rotation2d
angle
Angle of the module.double
distanceMeters
Distance measured by the wheel of the module. -
Constructor Summary
Constructors Constructor Description SwerveModulePosition()
Constructs a SwerveModulePosition with zeros for distance and angle.SwerveModulePosition(double distanceMeters, Rotation2d angle)
Constructs a SwerveModulePosition. -
Method Summary
Modifier and Type Method Description int
compareTo(SwerveModulePosition other)
Compares two swerve module positions.SwerveModulePosition
copy()
Returns a copy of this swerve module position.boolean
equals(Object obj)
int
hashCode()
SwerveModulePosition
interpolate(SwerveModulePosition endValue, double t)
Return the interpolated value.SwerveModulePosition
minus(SwerveModulePosition other)
Calculates the difference between two swerve module positions.String
toString()
-
Field Details
-
distanceMeters
Distance measured by the wheel of the module. -
angle
Angle of the module.
-
-
Constructor Details
-
SwerveModulePosition
public SwerveModulePosition()Constructs a SwerveModulePosition with zeros for distance and angle. -
SwerveModulePosition
Constructs a SwerveModulePosition.- Parameters:
distanceMeters
- The distance measured by the wheel of the module.angle
- The angle of the module.
-
-
Method Details
-
equals
-
hashCode
-
compareTo
Compares two swerve module positions. One swerve module is "greater" than the other if its distance is higher than the other.- Specified by:
compareTo
in interfaceComparable<SwerveModulePosition>
- Parameters:
other
- The other swerve module.- Returns:
- 1 if this is greater, 0 if both are equal, -1 if other is greater.
-
toString
-
copy
Returns a copy of this swerve module position.- Returns:
- A copy.
-
minus
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).- Parameters:
other
- The swerve module position to subtract.- Returns:
- The difference.
-
interpolate
Description copied from interface:Interpolatable
Return the interpolated value. This object is assumed to be the starting position, or lower bound.- Specified by:
interpolate
in interfaceInterpolatable<SwerveModulePosition>
- Parameters:
endValue
- The upper bound, or end.t
- How far between the lower and upper bound we are. This should be bounded in [0, 1].- Returns:
- The interpolated value.
-