Skip to content

Commit

Permalink
changed swerve module conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
txrnqt committed Jan 14, 2025
1 parent 1e6dfc8 commit ab0507e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/frc/lib/util/swerve/SwerveModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.wpi.first.math.kinematics.SwerveModulePosition;
import edu.wpi.first.math.kinematics.SwerveModuleState;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.lib.math.Conversions;
import frc.robot.Constants;

/**
Expand Down Expand Up @@ -97,8 +98,9 @@ public Rotation2d getCANcoder() {
*/
public SwerveModuleState getState() {
return new SwerveModuleState(
inputs.driveMotorSelectedSensorVelocity.in(RotationsPerSecond)
* Constants.Swerve.wheelCircumference.in(Meters),
Conversions.rotationPerSecondToMetersPerSecond(
inputs.driveMotorSelectedSensorVelocity.in(RotationsPerSecond),
Constants.Swerve.wheelCircumference.in(Meters)),
Rotation2d.fromRotations(inputs.angleMotorSelectedPosition.in(Rotations)));
}

Expand All @@ -109,8 +111,9 @@ public SwerveModuleState getState() {
*/
public SwerveModulePosition getPosition() {
return new SwerveModulePosition(
inputs.driveMotorSelectedPosition.in(Rotations)
* Constants.Swerve.wheelCircumference.in(Meters),
Conversions.rotationsToMeters(
inputs.driveMotorSelectedSensorVelocity.in(RotationsPerSecond),
Constants.Swerve.wheelCircumference.in(Meters)),
Rotation2d.fromRotations(inputs.angleMotorSelectedPosition.in(Rotations)));
}
}

0 comments on commit ab0507e

Please sign in to comment.