I wrote code for incrreasing and decreasing shooting speed and added necessary consta...
authorNadia Anees <n.anees655@gmail.com>
Tue, 31 Jan 2017 04:14:33 +0000 (20:14 -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/DecreaseShootingSpeed.java
src/org/usfirst/frc/team3501/robot/commands/shooter/IncreaseShootingSpeed.java
src/org/usfirst/frc/team3501/robot/commands/shooter/RunFlyWheel.java
src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java
src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java

index 23ac1a82d3f0fcabeb53e8d9305f06ce89e4f4a0..3bd4efd7490e7462306cbe05fb75ebff63c15516 100644 (file)
@@ -1,5 +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.command.Command;
 
 /**
@@ -10,35 +13,35 @@ import edu.wpi.first.wpilibj.command.Command;
  * flywheel is run, it will run at the decreased shooting speed
  */
 public class DecreaseShootingSpeed extends Command {
+  private Shooter shooter = Robot.getShooter();
+
   public DecreaseShootingSpeed() {
 
   }
 
-  // Called just before this Command runs the first time
   @Override
   protected void initialize() {
+    shooter.CURRENT_SHOOTING_SPEED -= shooter.SHOOTING_SPEED_INCREMENT;
+
   }
 
-  // Called repeatedly when this Command is scheduled to run
   @Override
   protected void execute() {
   }
 
-  // Called once after isFinished returns true
   @Override
   protected void end() {
   }
 
-  // Called when another command which requires one or more of the same
-  // subsystems is scheduled to run
   @Override
   protected void interrupted() {
+    end();
   }
 
   @Override
   protected boolean isFinished() {
-    // TODO Auto-generated method stub
-    return false;
+    return true;
+
   }
 
 }
index aeb74ec036beb37fd1f89af51bb0ec93c98e0eef..85bd3bd39dbedf9af5418853babcdb49edf7a4b4 100644 (file)
@@ -1,5 +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.command.Command;
 
 /**
@@ -10,35 +13,34 @@ import edu.wpi.first.wpilibj.command.Command;
  * flywheel is run, it will run at the increased shooting speed
  */
 public class IncreaseShootingSpeed extends Command {
+  private Shooter shooter = Robot.getShooter();
+
   public IncreaseShootingSpeed() {
 
   }
 
-  // Called just before this Command runs the first time
   @Override
   protected void initialize() {
+    shooter.CURRENT_SHOOTING_SPEED += shooter.SHOOTING_SPEED_INCREMENT;
   }
 
-  // Called repeatedly when this Command is scheduled to run
   @Override
   protected void execute() {
   }
 
-  // Called once after isFinished returns true
   @Override
   protected void end() {
   }
 
-  // Called when another command which requires one or more of the same
-  // subsystems is scheduled to run
   @Override
   protected void interrupted() {
+    end();
   }
 
   @Override
   protected boolean isFinished() {
-    // TODO Auto-generated method stub
-    return false;
+
+    return true;
   }
 
 }
index 203f9dce79a4eb3088eb1155e9e67dfa1fbac036..78506882140bd14c817d8f05014baa11018afb30 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.Timer;
 import edu.wpi.first.wpilibj.command.Command;
@@ -12,8 +13,8 @@ import edu.wpi.first.wpilibj.command.Command;
  * @author Shaina
  */
 public class RunFlyWheel extends Command {
+  private Shooter shooter = Robot.getShooter();
   Timer timer;
-  private double motorVal;
   private double time;
 
   /**
@@ -24,11 +25,10 @@ public class RunFlyWheel extends Command {
    * @param time
    *          in seconds, amount of time to run fly wheel motor
    */
-  public RunFlyWheel(double motorVal, double time) {
-    requires(Robot.getShooter());
+  public RunFlyWheel(double time) {
+    requires(shooter);
 
     timer = new Timer();
-    this.motorVal = motorVal;
     this.time = time;
   }
 
@@ -36,7 +36,7 @@ public class RunFlyWheel extends Command {
   @Override
   protected void initialize() {
     timer.start();
-    Robot.getShooter().setFlyWheelMotorVal(motorVal);
+    shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
   }
 
   // Called repeatedly when this Command is scheduled to run
@@ -47,7 +47,7 @@ public class RunFlyWheel extends Command {
   // Called once after isFinished returns true
   @Override
   protected void end() {
-    Robot.getShooter().stopFlyWheel();
+    shooter.stopFlyWheel();
   }
 
   // Called when another command which requires one or more of the same
index b4eed57abe0862ae574c3ad83a3279998f183745..1bf1c6f0c4941cba314eeff63030e066f345e557 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 RunIndexWheelContinuous extends Command {
-  private double motorVal;
+  private Shooter shooter = Robot.getShooter();
 
   /**
    * See JavaDoc comment in class for details
@@ -25,14 +26,14 @@ public class RunIndexWheelContinuous extends Command {
    * @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);
+    shooter.setIndexWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
   }
 
   // Called repeatedly when this Command is scheduled to run
index 06073a791795c2be6c7aeccb781042bbba045fce..73c1b23282356686b7475b9ba8b21692c0753504 100644 (file)
@@ -10,9 +10,15 @@ public class Shooter extends Subsystem {
   private static Shooter shooter;
   private final CANTalon flyWheel, indexWheel;
 
+  public static final double DEFAULT_SHOOTING_SPEED = 0;
+  public static double CURRENT_SHOOTING_SPEED;
+
+  public static final double SHOOTING_SPEED_INCREMENT = 0;
+
   private Shooter() {
     flyWheel = new CANTalon(Constants.Shooter.FLY_WHEEL);
     indexWheel = new CANTalon(Constants.Shooter.INDEX_WHEEL);
+
   }
 
   /**