From: Shivani Ghanta Date: Tue, 31 Jan 2017 05:06:09 +0000 (-0800) Subject: Implement ReverseIndexWheel X-Git-Url: http://challenge-bot.com/repos/?p=3501%2F2017steamworks;a=commitdiff_plain;h=21477e1d2cef725ba4a34edd75b77a5e0a898985 Implement ReverseIndexWheel --- diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/ReverseIndexWheel.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/ReverseIndexWheel.java new file mode 100644 index 0000000..4c74515 --- /dev/null +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/ReverseIndexWheel.java @@ -0,0 +1,63 @@ +package org.usfirst.frc.team3501.robot.commands.shooter; + +import org.usfirst.frc.team3501.robot.Robot; + +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.command.Command; + +/** + * This command reverses the index wheel at a given speed for given time in + * seconds. + * + * @author shivanighanta + */ + +public class ReverseIndexWheel extends Command { + Timer timer; + private double time; + private double 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 ReverseIndexWheel(double time, double motorVal) { + requires(Robot.getDriveTrain()); + timer = new Timer(); + this.time = time; + this.motorVal = motorVal; + } + + @Override + protected void initialize() { + timer.start(); + + } + + @Override + protected void execute() { + Robot.getShooter().setIndexWheelMotorVal(-motorVal); + + } + + @Override + protected boolean isFinished() { + return timer.get() >= time; + } + + @Override + protected void end() { + Robot.getShooter().stopIndexWheel(); + + } + + @Override + protected void interrupted() { + end(); + } +}