Add buttons to move intake arm.
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / intakearm / RunIntakeMotor.java
diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntakeMotor.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntakeMotor.java
new file mode 100644 (file)
index 0000000..6d95b99
--- /dev/null
@@ -0,0 +1,57 @@
+package org.usfirst.frc.team3501.robot.commands.intakearm;
+
+import org.usfirst.frc.team3501.robot.Constants;
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.CANTalon;
+import edu.wpi.first.wpilibj.command.Command;
+
+/***
+ * This command runs the given motor (intended to be an intake arm motor) at the
+ * given speed momentarily.
+ *
+ * @author harel, garima
+ *
+ */
+
+public class RunIntakeMotor extends Command {
+  CANTalon intakeMotor;
+  double motorSpeed;
+
+  /***
+   * @param intakeMotor
+   *          Motor to run.
+   * @param motorSpeed
+   *          Speed at which to run motor. Range is [-1,1]
+   */
+  public RunIntakeMotor(CANTalon intakeMotor, double motorSpeed) {
+    requires(Robot.intakeArm);
+    this.intakeMotor = intakeMotor;
+    this.motorSpeed = motorSpeed;
+  }
+
+  @Override
+  protected void initialize() {
+    intakeMotor.set(motorSpeed);
+  }
+
+  @Override
+  protected void execute() {
+
+  }
+
+  @Override
+  protected boolean isFinished() {
+    return true;
+  }
+
+  @Override
+  protected void end() {
+    intakeMotor.set(Constants.IntakeArm.STOP_INTAKE_ARM_SPEED);
+  }
+
+  @Override
+  protected void interrupted() {
+    end();
+  }
+}