Skip to content

Commit

Permalink
fixed my pid loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ntt305 committed Oct 25, 2024
1 parent 8a7af5f commit 206c106
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,26 @@ public void runOpMode() throws InterruptedException {
waitForStart();
double error = 1.1;
double power = 0;
double difference = 0;
double preverror = 0;


refrence = 300;
Arm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
Arm.setMode(DcMotor.RunMode.RUN_USING_ENCODER);

while (opModeIsActive()) {

while (gamepad1.b)
while (gamepad1.b);

error = preverror + error;
difference = error -preverror;
preverror = error;
// power = error + what?? ask brennan on monday

// obtaining encoder position
encoderPosition = Arm.getCurrentPosition();
// calculate error
error = refrence - encoderPosition;
power = (error/250)*.7;
if(power>0.7){
power = 0.7;
}
else if(power<-.7){
power = -0.7;
}

}
}


}

0 comments on commit 206c106

Please sign in to comment.