Implement RunWinch
authorShivani Ghanta <shivani.oghanta@gmail.com>
Sat, 14 Jan 2017 23:26:14 +0000 (15:26 -0800)
committerShivani Ghanta <shivani.oghanta@gmail.com>
Sat, 21 Jan 2017 22:27:37 +0000 (14:27 -0800)
src/org/usfirst/frc/team3501/robot/Robot.java
src/org/usfirst/frc/team3501/robot/commands/climber/RunWinch.java

index 5fbfe4043d6b58bca46b2daffc35783c2ae74251..9d178dadd1796ec79f931ff99f7c02610d2bf2bc 100644 (file)
@@ -27,6 +27,10 @@ public class Robot extends IterativeRobot {
     return DriveTrain.getDriveTrain();
   }
 
+  public static Climber getClimber() {
+    return Climber.getClimber();
+  }
+
   public static OI getOI() {
     return OI.getOI();
   }
index 99fb0f12ab087313d8afa14e0e83ce248b609819..028e33a23a314fa3fc05329f432e6c30c8617d17 100644 (file)
@@ -1,5 +1,9 @@
 package org.usfirst.frc.team3501.robot.commands.climber;
 
+import org.usfirst.frc.team3501.robot.Robot;
+
+import com.sun.glass.ui.Timer;
+
 import edu.wpi.first.wpilibj.command.Command;
 
 /**
@@ -9,16 +13,20 @@ import edu.wpi.first.wpilibj.command.Command;
  *
  */
 public class RunWinch extends Command {
+  Timer timer;
   private double time;
   private double motorVal;
 
   public RunWinch(double time, double motorVal) {
+    requires(Robot.getClimber());
     this.time = time;
     this.motorVal = motorVal;
   }
 
   @Override
   protected void initialize() {
+    timer.start();
+    Robot.getClimber().setMotorValues(motorVal, motorVal);
   }
 
   @Override
@@ -28,15 +36,16 @@ public class RunWinch extends Command {
 
   @Override
   protected boolean isFinished() {
-    return false;
+    return timer.get() >= time;
   }
 
   @Override
   protected void end() {
-
+    Robot.getClimber().stop();
   }
 
   @Override
   protected void interrupted() {
+    end();
   }
 }