X-Git-Url: http://challenge-bot.com/repos/?p=3501%2F2017steamworks;a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fcommands%2Fdriving%2FTurnForAngle.java;h=f9f5c7f0e285676a21b0548baa6d3a80df75879c;hp=86176f15fe9e3b03ebaf0ac447af00f597f1cb17;hb=571fb5c99d2323fed344b332f687597cd53d4d31;hpb=bf921ece957cae792bd5c52b2c7005bbf09ca469 diff --git a/src/org/usfirst/frc/team3501/robot/commands/driving/TurnForAngle.java b/src/org/usfirst/frc/team3501/robot/commands/driving/TurnForAngle.java index 86176f1..f9f5c7f 100755 --- a/src/org/usfirst/frc/team3501/robot/commands/driving/TurnForAngle.java +++ b/src/org/usfirst/frc/team3501/robot/commands/driving/TurnForAngle.java @@ -28,11 +28,14 @@ public class TurnForAngle extends Command { private double gyroI; private double gyroD; + private double zeroAngle; + public TurnForAngle(double angle, Direction direction, double maxTimeOut) { requires(Robot.getDriveTrain()); this.direction = direction; this.maxTimeOut = maxTimeOut; - this.target = angle; + this.target = Math.abs(angle); + this.zeroAngle = driveTrain.getAngle(); this.gyroP = driveTrain.defaultGyroP; this.gyroI = driveTrain.defaultGyroI; @@ -46,7 +49,6 @@ public class TurnForAngle extends Command { @Override protected void initialize() { this.driveTrain.resetEncoders(); - this.driveTrain.resetGyro(); this.gyroController.setSetPoint(this.target); } @@ -55,14 +57,14 @@ public class TurnForAngle extends Command { double xVal = 0; xVal = this.gyroController - .calcPID(this.driveTrain.getAngle() - this.driveTrain.getZeroAngle()); + .calcPID(Math.abs(this.driveTrain.getAngle() - this.zeroAngle)); - double leftDrive; - double rightDrive; + double leftDrive = 0; + double rightDrive = 0; if (direction == Constants.Direction.RIGHT) { leftDrive = xVal; rightDrive = -xVal; - } else { + } else if (direction == Constants.Direction.LEFT) { leftDrive = -xVal; rightDrive = xVal; }