From: Kevin Zhang Date: Sat, 23 Jan 2016 03:20:33 +0000 (-0800) Subject: add catch to getspeed and change names X-Git-Url: http://challenge-bot.com/repos/?p=3501%2Fstronghold-2016;a=commitdiff_plain;h=2460b87aa71b7c0200ade6d6d24e1f99e3c55e07 add catch to getspeed and change names --- diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index 7376255d..e6773171 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -13,12 +13,17 @@ public class Shooter extends Subsystem { shooter = new CANTalon(Constants.Shooter.PORT); } - public double getCurrentSpeed() { + public double getCurrentSetPoint() { return shooter.get(); } public void setSpeed(double speed) { - shooter.set(speed); + if (speed >= 1.0) + shooter.set(1.0); + else if (speed <= -1.0) + shooter.set(-1.0); + else + shooter.set(speed); } public void stop() { @@ -26,17 +31,17 @@ public class Shooter extends Subsystem { } public State getState() { - return (this.getCurrentSpeed() == 0) ? State.RUNNING : State.STOPPED; + return (this.getCurrentSetPoint() == 0) ? State.RUNNING : State.STOPPED; } // Use negative # for decrement. Positive for increment. public void changeSpeed(double change) { - if (getCurrentSpeed() + change >= 1.0) + if (getCurrentSetPoint() + change >= 1.0) shooter.set(1.0); - else if (getCurrentSpeed() + change <= -1.0) + else if (getCurrentSetPoint() + change <= -1.0) shooter.set(-1.0); else { - double newSpeed = getCurrentSpeed() + change; + double newSpeed = getCurrentSetPoint() + change; setSpeed(newSpeed); } }