move setmotorvalues to execute and set wheels to constant speeds
authorCindy Zhang <cindyzyx9@gmail.com>
Sat, 4 Feb 2017 19:01:04 +0000 (11:01 -0800)
committerCindy Zhang <cindyzyx9@gmail.com>
Sat, 4 Feb 2017 19:02:25 +0000 (11:02 -0800)
src/org/usfirst/frc/team3501/robot/commands/shooter/RunFlyWheel.java
src/org/usfirst/frc/team3501/robot/commands/shooter/RunFlyWheelContinuous.java
src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheel.java
src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java
src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java

index 78506882140bd14c817d8f05014baa11018afb30..6ac5d69f3e1934c557adde63add9c5a72d4c5982 100644 (file)
@@ -3,7 +3,6 @@ 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.Timer;
 import edu.wpi.first.wpilibj.command.Command;
 
 /**
@@ -14,7 +13,6 @@ import edu.wpi.first.wpilibj.command.Command;
  */
 public class RunFlyWheel extends Command {
   private Shooter shooter = Robot.getShooter();
-  Timer timer;
   private double time;
 
   /**
@@ -27,21 +25,18 @@ public class RunFlyWheel extends Command {
    */
   public RunFlyWheel(double time) {
     requires(shooter);
-
-    timer = new Timer();
     this.time = time;
   }
 
   // Called just before this Command runs the first time
   @Override
   protected void initialize() {
-    timer.start();
-    shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
   }
 
   // Called repeatedly when this Command is scheduled to run
   @Override
   protected void execute() {
+    shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
   }
 
   // Called once after isFinished returns true
@@ -59,7 +54,7 @@ public class RunFlyWheel extends Command {
 
   @Override
   protected boolean isFinished() {
-    return timer.get() >= time;
+    return timeSinceInitialized() >= time;
   }
 
 }
index cc07893019111c9e88f0115784de98d079981862..af77483c85939ffa7205610078a4ee2630275805 100644 (file)
@@ -1,6 +1,7 @@
 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;
 
@@ -17,7 +18,7 @@ import edu.wpi.first.wpilibj.command.Command;
  * @author Shaina
  */
 public class RunFlyWheelContinuous extends Command {
-  private double motorVal;
+  private Shooter shooter = Robot.getShooter();
 
   /**
    * See JavaDoc comment in class for details
@@ -25,19 +26,19 @@ public class RunFlyWheelContinuous extends Command {
    * @param motorVal
    *          value range from -1 to 1
    */
-  public RunFlyWheelContinuous(double motorVal) {
-    this.motorVal = motorVal;
+  public RunFlyWheelContinuous() {
+    requires(shooter);
   }
 
   // Called just before this Command runs the first time
   @Override
   protected void initialize() {
-    Robot.getShooter().setFlyWheelMotorVal(motorVal);
   }
 
   // Called repeatedly when this Command is scheduled to run
   @Override
   protected void execute() {
+    shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
   }
 
   // Called once after isFinished returns true
index 4c8cd54d102573329a4ee36dc4ca10288249ff20..68383544bf95779ff7b7b79f887703b9a8942a83 100644 (file)
@@ -1,8 +1,8 @@
 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.Timer;
 import edu.wpi.first.wpilibj.command.Command;
 
 /**
@@ -14,9 +14,8 @@ import edu.wpi.first.wpilibj.command.Command;
  * @author Shaina
  */
 public class RunIndexWheel extends Command {
-  Timer timer;
+  private Shooter shooter = Robot.getShooter();
   private double time;
-  private double motorVal;
 
   /**
    * See JavaDoc comment in class for details
@@ -26,30 +25,26 @@ public class RunIndexWheel extends Command {
    * @param time
    *          in seconds, amount of time to run index wheel motor
    */
-  public RunIndexWheel(double motorVal, double time) {
-    requires(Robot.getShooter());
-
-    timer = new Timer();
-    this.motorVal = motorVal;
+  public RunIndexWheel(double time) {
+    requires(shooter);
     this.time = time;
   }
 
   // Called just before this Command runs the first time
   @Override
   protected void initialize() {
-    timer.start();
-    Robot.getShooter().setIndexWheelMotorVal(motorVal);
   }
 
   // Called repeatedly when this Command is scheduled to run
   @Override
   protected void execute() {
+    shooter.setIndexWheelMotorVal(shooter.DEFAULT_INDEXING_SPEED);
   }
 
   // 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
@@ -61,7 +56,7 @@ public class RunIndexWheel extends Command {
 
   @Override
   protected boolean isFinished() {
-    return timer.get() >= time;
+    return timeSinceInitialized() >= time;
   }
 
 }
index 1bf1c6f0c4941cba314eeff63030e066f345e557..bf9af68ad85b3c0617672edba540c37aeb7d2989 100644 (file)
@@ -27,18 +27,18 @@ public class RunIndexWheelContinuous extends Command {
    *          value range from -1 to 1
    */
   public RunIndexWheelContinuous() {
-
+    requires(shooter);
   }
 
   // Called just before this Command runs the first time
   @Override
   protected void initialize() {
-    shooter.setIndexWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
   }
 
   // Called repeatedly when this Command is scheduled to run
   @Override
   protected void execute() {
+    shooter.setIndexWheelMotorVal(shooter.DEFAULT_INDEXING_SPEED);
   }
 
   // Called once after isFinished returns true
index 73c1b23282356686b7475b9ba8b21692c0753504..ba0f51cefbf86e775efeb159feab757f2439eb78 100644 (file)
@@ -10,6 +10,7 @@ public class Shooter extends Subsystem {
   private static Shooter shooter;
   private final CANTalon flyWheel, indexWheel;
 
+  public static final double DEFAULT_INDEXING_SPEED = 0;
   public static final double DEFAULT_SHOOTING_SPEED = 0;
   public static double CURRENT_SHOOTING_SPEED;