Class SwerveModuleState2
- java.lang.Object
-
- edu.wpi.first.math.kinematics.SwerveModuleState
-
- frc.robot.subsystems.swervedrive.swerve.kinematics.SwerveModuleState2
-
- All Implemented Interfaces:
java.lang.Comparable<edu.wpi.first.math.kinematics.SwerveModuleState>
public class SwerveModuleState2 extends edu.wpi.first.math.kinematics.SwerveModuleState
-
-
Field Summary
Fields Modifier and Type Field Description doubleangularVelocityRadPerSecondAngular velocity in radians per second.
-
Constructor Summary
Constructors Constructor Description SwerveModuleState2()Constructs a SwerveModuleState with zeros for speed and angle.SwerveModuleState2(double speedMetersPerSecond, edu.wpi.first.math.geometry.Rotation2d angle)Constructs a SwerveModuleState.SwerveModuleState2(double speedMetersPerSecond, edu.wpi.first.math.geometry.Rotation2d angle, double angularVelocityRadPerSecond)Constructs a SwerveModuleState.SwerveModuleState2(edu.wpi.first.math.kinematics.SwerveModuleState self)Constructs a SwerveModuleState with zeros for speed and angle.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SwerveModuleState2optimize(SwerveModuleState2 desiredState, edu.wpi.first.math.geometry.Rotation2d currentAngle)Minimize the change in heading the desired swerve module state would require by potentially reversing the direction the wheel spins.static doubleplaceInAppropriate0To360Scope(double scopeReference, double newAngle)
-
-
-
Constructor Detail
-
SwerveModuleState2
public SwerveModuleState2()
Constructs a SwerveModuleState with zeros for speed and angle.
-
SwerveModuleState2
public SwerveModuleState2(edu.wpi.first.math.kinematics.SwerveModuleState self)
Constructs a SwerveModuleState with zeros for speed and angle.
-
SwerveModuleState2
public SwerveModuleState2(double speedMetersPerSecond, edu.wpi.first.math.geometry.Rotation2d angle)Constructs a SwerveModuleState.- Parameters:
speedMetersPerSecond- The speed of the wheel of the module.angle- The angle of the module.
-
SwerveModuleState2
public SwerveModuleState2(double speedMetersPerSecond, edu.wpi.first.math.geometry.Rotation2d angle, double angularVelocityRadPerSecond)Constructs a SwerveModuleState.- Parameters:
speedMetersPerSecond- The speed of the wheel of the module.angle- The angle of the module.angularVelocityRadPerSecond- The angular velocity of the module.
-
-
Method Detail
-
optimize
public static SwerveModuleState2 optimize(SwerveModuleState2 desiredState, edu.wpi.first.math.geometry.Rotation2d currentAngle)
Minimize the change in heading the desired swerve module state would require by potentially reversing the direction the wheel spins. Customized from WPILib's version to include placing in appropriate scope for CTRE and REV onboard control as both controllers as of writing don't have support for continuous input.- Parameters:
desiredState- The desired state.currentAngle- The current module angle.
-
placeInAppropriate0To360Scope
public static double placeInAppropriate0To360Scope(double scopeReference, double newAngle)- Parameters:
scopeReference- Current AnglenewAngle- Target Angle- Returns:
- Closest angle within scope
-
-