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=aa2dbb26dd95c7a2717312909faeb69551ea4d64;hpb=210ebccbd7371afb041817be032f2d0be0bbc269;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 aa2dbb2..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,50 +1,55 @@ 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; /** - * This command will run the index wheel motor continuously until the button + * 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. + * * 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; /** * See JavaDoc comment in class for details - * - * @param motorVal - * value range from -1 to 1 */ - public RunIndexWheelContinuous(double motorVal) { - this.motorVal = motorVal; + public RunIndexWheelContinuous() { } - // Called just before this Command runs the first time @Override protected void initialize() { - Robot.getShooter().setIndexWheelMotorVal(motorVal); } - // 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() { - Robot.getShooter().stopIndexWheel(); + shooter.stopIndexWheel(); } - // Called when another command which requires one or more of the same - // subsystems is scheduled to run @Override protected void interrupted() { end();