From: Rohan Rodrigues Date: Sat, 4 Mar 2017 22:09:55 +0000 (-0800) Subject: Finalize Shooter and RunIndexWheelContinuous X-Git-Url: http://challenge-bot.com/repos/?p=3501%2F2017steamworks;a=commitdiff_plain;h=dd4a87932b7956021f78c8e86cff6adf0187aa8f Finalize Shooter and RunIndexWheelContinuous --- diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java index e86f3ee..2004c1d 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java @@ -51,8 +51,7 @@ public class RunIndexWheelContinuous extends Command { t.reset(); } - double shooterSpeed = shooter.getShooterRPM(); - if (shooterSpeed > 0) + if (shooter.isShooterRPMWithinRangeOfTargetSpeed(25)) shooter.runIndexWheel(); } diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index e526dac..75737a6 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -19,6 +19,7 @@ public class Shooter extends Subsystem { private static final double DEFAULT_INDEXING_SPEED = -0.75; private static final double DEFAULT_SHOOTING_SPEED = 2800; // rpm private static final double SHOOTING_SPEED_INCREMENT = 25; + private static final int ACCEPTABLE_SHOOTING_DEVIATION = 300; private double currentShootingSpeed = DEFAULT_SHOOTING_SPEED; @@ -137,4 +138,17 @@ public class Shooter extends Subsystem { private void changeGear(DoubleSolenoid.Value gear) { piston.set(gear); } + + public boolean isShooterRPMAtTargetSpeed() { + return isShooterRPMWithinRangeOfTargetSpeed(ACCEPTABLE_SHOOTING_DEVIATION); + } + + public boolean isShooterRPMWithinRangeOfTargetSpeed(int acceptableRPMError) { + double shooterSpeed = getShooterRPM(); + if (shooterSpeed > DEFAULT_SHOOTING_SPEED - acceptableRPMError + && shooterSpeed < DEFAULT_SHOOTING_SPEED + acceptableRPMError) { + return true; + } + return false; + } }