Skip to content

Commit

Permalink
fixed some things i broke earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
24cirinom committed Feb 24, 2024
1 parent fb293a3 commit 2b2fa52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public static Command joystickDrive(
DoubleSupplier omegaSupplier) {
return Commands.run(
() -> {

double linearMagnitude;
Rotation2d linearDirection;
double omega;
Expand All @@ -57,15 +56,16 @@ public static Command joystickDrive(
omega = MathUtil.applyDeadband(omegaSupplier.getAsDouble(), DEADBAND);
} else {
linearMagnitude =
(MathUtil.applyDeadband(
Math.hypot(xSupplier.getAsDouble(), ySupplier.getAsDouble()), DEADBAND)) / 2;
(MathUtil.applyDeadband(
Math.hypot(xSupplier.getAsDouble(), ySupplier.getAsDouble()), DEADBAND))
/ 2;
linearDirection =
new Rotation2d(
-MathUtil.applyDeadband(xSupplier.getAsDouble(), DEADBAND),
-MathUtil.applyDeadband(ySupplier.getAsDouble(), DEADBAND));
omega = (MathUtil.applyDeadband(omegaSupplier.getAsDouble(), DEADBAND)) / 2;
}

// Square values
linearMagnitude = linearMagnitude * linearMagnitude;
omega = -Math.copySign(omega * omega, omega);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ModuleIOSparkMax implements ModuleIO {
// Gear ratios for SDS MK4i L2, adjust as necessary
private static final double DRIVE_GEAR_RATIO = (50.0 / 14.0) * (17.0 / 27.0) * (45.0 / 15.0);
private static final double TURN_GEAR_RATIO = 1.0; // 46.42/1.0;
private static final double RELATIVE_ENCODER_TURN_GEAR_RATIO = 46.42/1.0;
private static final double RELATIVE_ENCODER_TURN_GEAR_RATIO = 46.42 / 1.0;

private final CANSparkMax driveSparkMax;
private final CANSparkMax turnSparkMax;
Expand Down Expand Up @@ -117,10 +117,9 @@ public ModuleIOSparkMax(int index) {
driveEncoder.setMeasurementPeriod(10);
driveEncoder.setAverageDepth(2);

turnRelativeEncoder.setPosition(turnAbsoluteEncoderNew.getPosition() * RELATIVE_ENCODER_TURN_GEAR_RATIO);
turnRelativeEncoder.setPosition(0.0);
turnRelativeEncoder.setMeasurementPeriod(10);
turnRelativeEncoder.setAverageDepth(2);


driveSparkMax.setCANTimeout(0);
turnSparkMax.setCANTimeout(0);
Expand Down Expand Up @@ -156,7 +155,7 @@ public void updateInputs(ModuleIOInputs inputs) {
// .minus(absoluteEncoderOffset);

inputs.turnAbsolutePosition =
Rotation2d.fromRotations(turnAbsoluteEncoderNew.getPosition())
Rotation2d.fromRotations(turnAbsoluteEncoderNew.getPosition() / TURN_GEAR_RATIO)
.minus(absoluteEncoderOffset);

// New code to get the absolute encoder with the CTRE through bore absolute encoder
Expand Down

0 comments on commit 2b2fa52

Please sign in to comment.