X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fcommands%2Fclimber%2FRunWinch.java;h=5a76b5c182b377c6892b64c75572ca0857fa44ec;hb=150f450f2b4f9e6094d71007507a7b877e05328a;hp=99fb0f12ab087313d8afa14e0e83ce248b609819;hpb=dbf2ff8fd7ae4dc5a1e3a490c47e12380500e8ff;p=3501%2F2017steamworks diff --git a/src/org/usfirst/frc/team3501/robot/commands/climber/RunWinch.java b/src/org/usfirst/frc/team3501/robot/commands/climber/RunWinch.java index 99fb0f1..5a76b5c 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/climber/RunWinch.java +++ b/src/org/usfirst/frc/team3501/robot/commands/climber/RunWinch.java @@ -1,18 +1,44 @@ package org.usfirst.frc.team3501.robot.commands.climber; +import org.usfirst.frc.team3501.robot.Robot; +import org.usfirst.frc.team3501.robot.subsystems.Climber; + import edu.wpi.first.wpilibj.command.Command; /** - * Runs the winch for a given time and motor value + * This command runs the winch at a specified speed and time in seconds when the + * button triggering it is pressed. This command also makes the drive train + * motors run because the winch is controlled by the drive train. + * + * pre-condition: This command is run by a button in OI. The robot must be + * attached to the rope. * + * post-condition: Winch motor set to a specified speed for a specified time. + * + * @param motorVal + * value range is from -1 to 1 + * @param time + * in seconds * @author shivanighanta * */ + public class RunWinch extends Command { + Climber climber = Robot.getClimber(); + private double time; private double motorVal; + /** + * See JavaDoc comment in class for details + * + * @param time + * time in seconds to run the winch + * @param motorVal + * value range is from -1 to 1 + */ public RunWinch(double time, double motorVal) { + requires(climber); this.time = time; this.motorVal = motorVal; } @@ -23,20 +49,21 @@ public class RunWinch extends Command { @Override protected void execute() { - + climber.setMotorValues(motorVal); } @Override protected boolean isFinished() { - return false; + return timeSinceInitialized() >= time; } @Override protected void end() { - + climber.stop(); } @Override protected void interrupted() { + end(); } }