Skip to content

Instantly share code, notes, and snippets.

@archishou
Last active February 10, 2019 00:09
Show Gist options
  • Save archishou/c72f8554162bd5b7a82c8116ed19efa4 to your computer and use it in GitHub Desktop.
Save archishou/c72f8554162bd5b7a82c8116ed19efa4 to your computer and use it in GitHub Desktop.
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