Skip to content

Commit

Permalink
Rename module gear ratio constants in example project
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Nov 3, 2023
1 parent c6ae4c3 commit 2159a40
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class ModuleIOTalonFX implements ModuleIO {
private final StatusSignal<Double> turnCurrent;

// Gear ratios for SDS MK4i L2, adjust as necessary
private final double driveAfterEncoderReduction = (50.0 / 14.0) * (17.0 / 27.0) * (45.0 / 15.0);
private final double turnAfterEncoderReduction = 150.0 / 7.0;
private final double DRIVE_GEAR_RATIO = (50.0 / 14.0) * (17.0 / 27.0) * (45.0 / 15.0);
private final double TURN_GEAR_RATIO = 150.0 / 7.0;

private final boolean isTurnMotorInverted = true;
private final Rotation2d absoluteEncoderOffset;
Expand Down Expand Up @@ -132,19 +132,19 @@ public void updateInputs(ModuleIOInputs inputs) {
turnCurrent);

inputs.drivePositionRad =
Units.rotationsToRadians(drivePosition.getValueAsDouble()) / driveAfterEncoderReduction;
Units.rotationsToRadians(drivePosition.getValueAsDouble()) / DRIVE_GEAR_RATIO;
inputs.driveVelocityRadPerSec =
Units.rotationsToRadians(driveVelocity.getValueAsDouble()) / driveAfterEncoderReduction;
Units.rotationsToRadians(driveVelocity.getValueAsDouble()) / DRIVE_GEAR_RATIO;
inputs.driveAppliedVolts = driveAppliedVolts.getValueAsDouble();
inputs.driveCurrentAmps = new double[] {driveCurrent.getValueAsDouble()};

inputs.turnAbsolutePosition =
Rotation2d.fromRotations(turnAbsolutePosition.getValueAsDouble())
.minus(absoluteEncoderOffset);
inputs.turnPosition =
Rotation2d.fromRotations(turnPosition.getValueAsDouble() / turnAfterEncoderReduction);
Rotation2d.fromRotations(turnPosition.getValueAsDouble() / TURN_GEAR_RATIO);
inputs.turnVelocityRadPerSec =
Units.rotationsToRadians(turnVelocity.getValueAsDouble()) / turnAfterEncoderReduction;
Units.rotationsToRadians(turnVelocity.getValueAsDouble()) / TURN_GEAR_RATIO;
inputs.turnAppliedVolts = turnAppliedVolts.getValueAsDouble();
inputs.turnCurrentAmps = new double[] {turnCurrent.getValueAsDouble()};
}
Expand Down

0 comments on commit 2159a40

Please sign in to comment.