Package frc.lib.util.swerve
Class SwerveModule
java.lang.Object
frc.lib.util.swerve.SwerveModule
Swerve Module
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSwerveModule(int moduleNumber, int driveMotorID, int angleMotorID, int cancoderID, Rotation2d angleOffset, SwerveModuleIO io) Swerve Module -
Method Summary
Modifier and TypeMethodDescriptionGet the rotation of the CANCoderGet the current Swerve Module PositiongetState()Get the current Swerve Module Statevoidperiodic()voidReset the Swerve Module angle to face forwardvoidsetDesiredState(SwerveModuleState desiredState, boolean isOpenLoop) Set the desired state of the Swerve Module
-
Field Details
-
moduleNumber
public int moduleNumber
-
-
Constructor Details
-
SwerveModule
public SwerveModule(int moduleNumber, int driveMotorID, int angleMotorID, int cancoderID, Rotation2d angleOffset, SwerveModuleIO io) Swerve Module- Parameters:
moduleNumber- Module NumberdriveMotorID- CAN ID of the Drive MotorangleMotorID- CAN ID of the Angle MotorcancoderID- CAN ID of the CANCoderangleOffset- Angle Offset of the CANCoder to align the wheels
-
-
Method Details
-
periodic
public void periodic() -
setDesiredState
Set the desired state of the Swerve Module- Parameters:
desiredState- The desiredSwerveModuleStatefor the moduleisOpenLoop- Whether the state should be open or closed loop controlled
-
getCANcoder
Get the rotation of the CANCoder- Returns:
- The rotation of the CANCoder in
Rotation2d
-
resetToAbsolute
public void resetToAbsolute()Reset the Swerve Module angle to face forward -
getState
Get the current Swerve Module State- Returns:
- The current
SwerveModuleState
-
getPosition
Get the current Swerve Module Position- Returns:
- The current
SwerveModulePosition
-