-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
45 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/PIDLOOP.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,42 @@ | ||
package org.firstinspires.ftc.teamcode.opmode; | ||
////this loop is for driving forward and backwards//// | ||
|
||
import com.acmerobotics.dashboard.config.Config; | ||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; | ||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp; | ||
import com.qualcomm.robotcore.hardware.DcMotor; | ||
|
||
|
||
@TeleOp | ||
@Config | ||
public class PIDLOOP extends LinearOpMode { | ||
private double k1 = 0.01; | ||
private double k2 = -0.0002; | ||
private double k3 = 0.0; | ||
private double reference = 300; | ||
private double ierror = 0; | ||
private double diff = 0; | ||
private double prevError = 0; | ||
public void runOpMode() throws InterruptedException { | ||
DcMotor topLeftMotor = hardwareMap.get(DcMotor.class, "FL"); | ||
DcMotor topRightMotor = hardwareMap.get(DcMotor.class, "FR"); | ||
DcMotor bottomLeftMotor = hardwareMap.get(DcMotor.class, "BL"); | ||
DcMotor bottomRightMotor = hardwareMap.get(DcMotor.class, "BR"); | ||
|
||
topLeftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); | ||
topLeftMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER); | ||
|
||
|
||
|
||
waitForStart(); | ||
while (opModeIsActive()) { | ||
telemetry.addData("ticks",topLeftMotor.getCurrentPosition()); | ||
double error = reference - topLeftMotor.getCurrentPosition(); | ||
ierror = ierror + error; | ||
diff = error - prevError; | ||
prevError = error; | ||
topLeftMotor.setPower(k1*error+k2*ierror+k3*diff); | ||
telemetry.update(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/tictacs.java
This file was deleted.
Oops, something went wrong.