From 2460b87aa71b7c0200ade6d6d24e1f99e3c55e07 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Fri, 22 Jan 2016 19:20:33 -0800 Subject: [PATCH] add catch to getspeed and change names --- .../frc/team3501/robot/subsystems/Shooter.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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); } } -- 2.30.2