Add Intake subsystem, filled in methods for Intake commands
authorArunima DIvya <adivya822@student.fuhsd.org>
Sat, 21 Jan 2017 05:10:31 +0000 (21:10 -0800)
committerArunima DIvya <adivya822@student.fuhsd.org>
Thu, 26 Jan 2017 04:10:21 +0000 (20:10 -0800)
src/org/usfirst/frc/team3501/robot/commands/intake/RunContinuous.java
src/org/usfirst/frc/team3501/robot/commands/intake/RunIntake.java
src/org/usfirst/frc/team3501/robot/commands/intake/StopIntake.java
src/org/usfirst/frc/team3501/robot/subsystems/Intake.java

index 632c543f1177e1403a0e358949422f21d361a15b..d6a4bd0228aae70bce0a0491808f372cb4ec8e3f 100644 (file)
@@ -1,5 +1,7 @@
 package org.usfirst.frc.team3501.robot.commands.intake;
 
+import org.usfirst.frc.team3501.robot.subsystems.Intake;
+
 import edu.wpi.first.wpilibj.command.Command;
 
 /***
@@ -10,6 +12,8 @@ import edu.wpi.first.wpilibj.command.Command;
  *
  */
 public class RunContinuous extends Command {
+  // create setter method for speed, use setSpeed method to do end() by setting
+  // speed to 0
 
   public RunContinuous() {
 
@@ -18,28 +22,32 @@ public class RunContinuous extends Command {
   @Override
   protected boolean isFinished() {
     // TODO Auto-generated method stub
-    return false;
+    return true;
   }
 
   // Called just before this Command runs the first time
   @Override
   protected void initialize() {
+
   }
 
   // Called repeatedly when this Command is scheduled to run
   @Override
   protected void execute() {
+
   }
 
   // Called once after isFinished returns true
   @Override
   protected void end() {
+    Intake.intake.setSpeed(0);
   }
 
   // Called when another command which requires one or more of the same
   // subsystems is scheduled to run
   @Override
   protected void interrupted() {
+    end();
   }
 
 }
index ca74e1c60c2e93892277c9d4b7d5529b07a4771b..82bb55001b9c45043fbb42d1d772378e32d4ba01 100644 (file)
@@ -1,5 +1,8 @@
 package org.usfirst.frc.team3501.robot.commands.intake;
 
+import org.usfirst.frc.team3501.robot.subsystems.Intake;
+
+import edu.wpi.first.wpilibj.Timer;
 import edu.wpi.first.wpilibj.command.Command;
 
 /**
@@ -10,15 +13,16 @@ import edu.wpi.first.wpilibj.command.Command;
  */
 public class RunIntake extends Command {
   private double timeToMove;
+  public Timer timer;
 
   public RunIntake(double timeToMove) {
+    timer = new Timer();
     this.timeToMove = timeToMove;
   }
 
   @Override
   protected boolean isFinished() {
-    // TODO Auto-generated method stub
-    return false;
+    return timer.get() >= timeToMove;
   }
 
   // Called just before this Command runs the first time
@@ -34,11 +38,13 @@ public class RunIntake extends Command {
   // Called once after isFinished returns true
   @Override
   protected void end() {
+    Intake.intake.setSpeed(0);
   }
 
   // Called when another command which requires one or more of the same
   // subsystems is scheduled to run
   @Override
   protected void interrupted() {
+    end();
   }
 }
index 6a2cc26c9821ec478b0517b62f8b2cb4c6a80ebd..54e8a603b5aff28bb1b23e8871f921d3b62a0c6d 100644 (file)
@@ -1,5 +1,7 @@
 package org.usfirst.frc.team3501.robot.commands.intake;
 
+import org.usfirst.frc.team3501.robot.subsystems.Intake;
+
 import edu.wpi.first.wpilibj.command.Command;
 
 /**
@@ -26,12 +28,14 @@ public class StopIntake extends Command {
   // Called once after isFinished returns true
   @Override
   protected void end() {
+    Intake.intake.setSpeed(0);
   }
 
   // Called when another command which requires one or more of the same
   // subsystems is scheduled to run
   @Override
   protected void interrupted() {
+    end();
   }
 
   @Override
index 1c891d4837c2709b94335327784e0963cf51107b..f849203d561093a0f5c348e96fcd34a68bdae241 100644 (file)
@@ -1,47 +1,36 @@
 package org.usfirst.frc.team3501.robot.subsystems;
 
+import com.ctre.CANTalon;
+
 import edu.wpi.first.wpilibj.command.Subsystem;
 
-/***
- *
- *
+/**
  * @author Meeta
- *
  */
 public class Intake extends Subsystem {
-  public Intake() {
-
-  }
-
-  /**
-   * Runs the intake continuously
-   */
-  public void RunContinous() {
+  public static Intake intake = null;
+  protected double speed = 0;
+  private CANTalon intakeWheel;
 
-  }
-
-  /**
-   * Starts running the intake for a specific period of time that the user
-   * inputs.
-   *
-   * @param timeToMove
-   *          in seconds
-   */
-  public void RunIntake(double timeToMove) {
+  // create speed of intake whee
+  public Intake() {
 
   }
 
-  /**
-   * Stops the intake
-   */
-  public void StopIntake() {
-
+  public static Intake getIntake() {
+    if (intake == null) {
+      intake = new Intake();
+    }
+    return intake;
   }
 
   @Override
   protected void initDefaultCommand() {
-    // TODO Auto-generated method stub
 
   }
 
+  public void setSpeed(double speed) {
+    this.speed = speed;
+  }
+
 }