Last active
February 10, 2019 00:09
-
-
Save archishou/c72f8554162bd5b7a82c8116ed19efa4 to your computer and use it in GitHub Desktop.
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
public void driveProportional(double angle, Direction direction, double ratio, double kp, double timeout) { | |
MasqClock clock = new MasqClock(); | |
MasqPIDController controller = new MasqPIDController(kp, 0, 0); | |
double out = controller.getOutput(tracker.imu.getRelativeYaw(), angle); | |
double rightRatio = 1, leftRatio = 1; | |
if (direction == Direction.RIGHT) rightRatio = ratio; | |
else leftRatio = ratio; | |
while (opModeIsActive() && out > 0.1 && !clock.elapsedTime(3, MasqClock.Resolution.SECONDS)) { | |
out = controller.getOutput(tracker.imu.getRelativeYaw(), angle); | |
driveTrain.setVelocity(out * leftRatio, out * rightRatio); | |
} | |
driveTrain.setVelocity(0); | |
} | |
public void driveProportional(double angle, Direction direction, double ratio, double kp) { | |
driveProportional(angle, direction, ratio, kp, 2); | |
} | |
public void driveProportional(double angle, Direction direction, double ratio) { | |
driveProportional(angle, direction, ratio, 0.3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment