X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fcommands%2Fshooter%2FRunIndexWheel.java;h=6abb095b60a0a5ac74de61627244f479ae2248f6;hb=7ba6bc91b8cf7205e05cdb974dc80fdd668ebe59;hp=5d330700750d82048ce6fc9e3028f9e260e62416;hpb=a149fd6464625f6abf7398139259e6bc5fb735d4;p=3501%2F2017steamworks diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheel.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheel.java index 5d33070..6abb095 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheel.java +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheel.java @@ -1,5 +1,8 @@ package org.usfirst.frc.team3501.robot.commands.shooter; +import org.usfirst.frc.team3501.robot.Robot; +import org.usfirst.frc.team3501.robot.subsystems.Shooter; + import edu.wpi.first.wpilibj.command.Command; /** @@ -8,19 +11,22 @@ import edu.wpi.first.wpilibj.command.Command; * pre-condition: fly wheel is running at full speed to prepare for shooting * fuel * - * - * @param motorVal - * value range is from -1 to 1 - * @param time - * in seconds - * @author shaina + * @author Shaina */ public class RunIndexWheel extends Command { + private Shooter shooter = Robot.getShooter(); private double time; - private double motorVal; - public RunIndexWheel(double motorVal, double time) { - this.motorVal = motorVal; + /** + * See JavaDoc comment in class for details + * + * @param motorVal + * value range from -1 to 1 + * @param time + * in seconds, amount of time to run index wheel motor + */ + public RunIndexWheel(double time) { + requires(shooter); this.time = time; } @@ -32,22 +38,29 @@ public class RunIndexWheel extends Command { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { + double shooterSpeed = shooter.getShooterRPM(); + double targetShooterSpeed = shooter.getTargetShootingSpeed(); + double threshold = shooter.getRPMThreshold(); + if (Math.abs(shooterSpeed - targetShooterSpeed) <= threshold) + shooter.runIndexWheel(); } // Called once after isFinished returns true @Override protected void end() { + shooter.stopIndexWheel(); } // Called when another command which requires one or more of the same // subsystems is scheduled to run @Override protected void interrupted() { + end(); } @Override protected boolean isFinished() { - return false; + return timeSinceInitialized() >= time; } }