Package edu.wpi.first.math.kinematics
Class SwerveModulePosition
java.lang.Object
edu.wpi.first.math.kinematics.SwerveModulePosition
- All Implemented Interfaces:
Interpolatable<SwerveModulePosition>
,ProtobufSerializable
,StructSerializable
,WPISerializable
,Comparable<SwerveModulePosition>
public class SwerveModulePosition
extends Object
implements Comparable<SwerveModulePosition>, Interpolatable<SwerveModulePosition>, ProtobufSerializable, StructSerializable
Represents the state of one swerve module.
-
Field Summary
Modifier and TypeFieldDescriptionAngle of the module.double
Distance measured by the wheel of the module.static final SwerveModulePositionProto
SwerveModulePosition protobuf for serialization.static final SwerveModulePositionStruct
SwerveModulePosition struct for serialization. -
Constructor Summary
ConstructorDescriptionConstructs a SwerveModulePosition with zeros for distance and angle.SwerveModulePosition
(double distanceMeters, Rotation2d angle) Constructs a SwerveModulePosition.SwerveModulePosition
(Distance distance, Rotation2d angle) Constructs a SwerveModulePosition. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(SwerveModulePosition other) Compares two swerve module positions.copy()
Returns a copy of this swerve module position.boolean
int
hashCode()
interpolate
(SwerveModulePosition endValue, double t) Return the interpolated value.toString()
-
Field Details
-
distanceMeters
Distance measured by the wheel of the module. -
angle
Angle of the module. -
proto
SwerveModulePosition protobuf for serialization. -
struct
SwerveModulePosition struct for serialization.
-
-
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.
-
SwerveModulePosition
Constructs a SwerveModulePosition.- Parameters:
distance
- 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.
-
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.
-