X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fcommands%2Fshooter%2FRunIndexWheelContinuous.java;h=1cd3e772762b5cdf6907338997a73fdc4973dde2;hb=f74d236db406193b851bff99e4daec7b7abf35e7;hp=66ccb3dfbb3c3f147d588e37c5274304bd4ec00e;hpb=0e77dfdedd8fe92dc6d8fb4ce58682cf37b9542b;p=3501%2F2017steamworks 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 66ccb3d..1cd3e77 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java @@ -1,40 +1,58 @@ 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; /** - * Runs index wheel continuously when corresponding button is pressed + * This command runs index wheel continuously when OI button managing index + * wheel is pressed. The command will run the index wheel motor until the button + * triggering it is released. + * + * Should only be run from the operator interface. * - * @param motorVal - * [-1,1] - * @author shaina + * pre-condition: This command must be run by a button in OI with + * button.whileHeld(...). + * + * @author Shaina */ public class RunIndexWheelContinuous extends Command { - private double motorVal; + private Shooter shooter = Robot.getShooter(); + + private double previousMotorValue = 0; + private double targetMotorValue = shooter.DEFAULT_INDEXING_MOTOR_VALUE; - public RunIndexWheelContinuous(double motorVal) { - this.motorVal = motorVal; + /** + * See JavaDoc comment in class for details + */ + public RunIndexWheelContinuous() { } - // Called just before this Command runs the first time @Override protected void initialize() { } - // 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) { + double motorValue = (6 * previousMotorValue + targetMotorValue) / 7; + previousMotorValue = motorValue; + shooter.setIndexWheelMotorVal(motorValue); + } } - // 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