Skip to content

Commit

Permalink
Truncate to Avoid Tweaking the PID
Browse files Browse the repository at this point in the history
  • Loading branch information
Java4First committed Mar 29, 2024
1 parent 15738d8 commit 4dff328
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/frc/robot/subsystems/Mast.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import java.math.BigDecimal;
import java.math.RoundingMode;
import org.littletonrobotics.junction.Logger;
import org.littletonrobotics.junction.networktables.LoggedDashboardNumber;

Expand Down Expand Up @@ -207,9 +209,13 @@ public void periodic() {

// Remove backlash from Launcher by syncing constantly
if (counts == 30) {
double ABStoRel = getAbsoluteEncoderDegrees() * gearRatio / 360;
relmastLeftEncoder.setPosition(ABStoRel);
// relmastRightEncoder.setPosition(-ABStoRel);
// double AbsToRel = getAbsoluteEncoderDegrees() * gearRatio / 360;
double AbsToRel =
new BigDecimal(getAbsoluteEncoderDegrees() * gearRatio / 360)
.setScale(3, RoundingMode.DOWN)
.doubleValue();
relmastLeftEncoder.setPosition(AbsToRel);
// relmastRightEncoder.setPosition(-AbsToRel);
counts = 0;
}
counts++;
Expand Down

0 comments on commit 4dff328

Please sign in to comment.