Skip to content

Commit

Permalink
disables pid once it is wihtin tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonS09 committed Mar 5, 2024
1 parent ca60b94 commit 96f6cb5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/carlmontrobotics/subsystems/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.carlmontrobotics.commands.ArmTeleop;
import org.carlmontrobotics.lib199.MotorConfig;
import org.carlmontrobotics.lib199.MotorControllerFactory;
import org.opencv.core.Mat;

import com.revrobotics.AbsoluteEncoder;
import com.revrobotics.CANSparkBase;
Expand Down Expand Up @@ -165,6 +166,9 @@ private void driveArm() {
armFeedVolts = armFeed.calculate(getCurrentArmGoal().position, 0);
}
armPIDMaster.setReference(setPoint.position, CANSparkBase.ControlType.kVelocity, 0, armFeedVolts);
if (armAtSetpoint()){
armPIDMaster.setIZone(Double.POSITIVE_INFINITY);//turns off pid once it reaches the setpoint
}

}

Expand Down

0 comments on commit 96f6cb5

Please sign in to comment.