Add MoveIntakeArmToBallIntakeHeight
authorShivani Oghanta <shivani.oghanta@gmail.com>
Sun, 7 Feb 2016 04:14:43 +0000 (20:14 -0800)
committerShivani Oghanta <shivani.oghanta@gmail.com>
Fri, 12 Feb 2016 04:31:31 +0000 (20:31 -0800)
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/commands/MoveIntakeArmToBallIntakeHeight.java
src/org/usfirst/frc/team3501/robot/commands/MoveIntakeArmToHeight.java [new file with mode: 0644]

index 216d816d57c721dfb2550ee433b72f088e0d2a6f..566449b8286b1c0072eaaff849a1784bdec48086 100644 (file)
@@ -79,6 +79,7 @@ public class Constants {
                public final static double OFFSET = -135.0; // in degrees
                public final static double ZERO_ANGLE = 180; // in degrees
                public final static double ARM_LENGTH = 15; // in inches
+               public final static double BALL_INTAKE_HEIGHT = 5; // random value
        }
 
        public static class DefenseArm {
index c33ee62da294c130a85f54d78631d8c1e8107525..35f97f7fc3cf21f86f9b20e63f3dc7fcc803ec62 100644 (file)
@@ -1,56 +1,13 @@
 package org.usfirst.frc.team3501.robot.commands;
 
-import org.usfirst.frc.team3501.robot.Robot;
+import org.usfirst.frc.team3501.robot.Constants;
 
-import edu.wpi.first.wpilibj.command.Command;
+import edu.wpi.first.wpilibj.command.CommandGroup;
 
-public class MoveIntakeArmToBallIntakeHeight extends Command {
-       private double targetHeight;
-       private double currentHeight;
-       private double targetSpeed;
-       private double SENSITIVITY_THRESHOLD = 0.1;
-       private double NO_MOVEMENT_SPEED = 0;
+public class MoveIntakeArmToBallIntakeHeight extends CommandGroup {
+       private static final double SPEED = 0.6;
 
-       public MoveIntakeArmToBallIntakeHeight(double height, double speed) {
-               requires(Robot.intakeArm);
-               targetHeight = height;
-               targetSpeed = speed;
-       }
-
-       @Override
-       protected void initialize() {
-               currentHeight = Robot.intakeArm.getArmHeight();
-               double difference = targetHeight - currentHeight;
-               if (difference > 0) {
-                       Robot.intakeArm.setArmVoltage(targetSpeed);
-               } else {
-                       Robot.intakeArm.setArmVoltage(-targetSpeed);
-               }
-       }
-
-       @Override
-       protected void execute() {
-
-       }
-
-       @Override
-       protected boolean isFinished() {
-               currentHeight = Robot.intakeArm.getArmHeight();
-               double distance = Math.abs(currentHeight - targetHeight);
-               if (distance <= SENSITIVITY_THRESHOLD) {
-                       return true;
-               } else {
-                       return false;
-               }
-
-       }
-
-       @Override
-       protected void end() {
-               Robot.intakeArm.setArmVoltage(NO_MOVEMENT_SPEED);
-       }
-
-       @Override
-       protected void interrupted() {
+       public MoveIntakeArmToBallIntakeHeight() {
+               addSequential(new MoveIntakeArmToHeight(Constants.IntakeArm.BALL_INTAKE_HEIGHT, SPEED));
        }
 }
diff --git a/src/org/usfirst/frc/team3501/robot/commands/MoveIntakeArmToHeight.java b/src/org/usfirst/frc/team3501/robot/commands/MoveIntakeArmToHeight.java
new file mode 100644 (file)
index 0000000..e4032c4
--- /dev/null
@@ -0,0 +1,56 @@
+package org.usfirst.frc.team3501.robot.commands;
+
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+public class MoveIntakeArmToHeight extends Command {
+       private double targetHeight;
+       private double currentHeight;
+       private double targetSpeed;
+       private double SENSITIVITY_THRESHOLD = 0.1;
+       private double NO_MOVEMENT_SPEED = 0;
+
+       public MoveIntakeArmToHeight(double height, double speed) {
+               requires(Robot.intakeArm);
+               targetHeight = height;
+               targetSpeed = speed;
+       }
+
+       @Override
+       protected void initialize() {
+               currentHeight = Robot.intakeArm.getArmHeight();
+               double difference = targetHeight - currentHeight;
+               if (difference > 0) {
+                       Robot.intakeArm.setArmVoltage(targetSpeed);
+               } else {
+                       Robot.intakeArm.setArmVoltage(-targetSpeed);
+               }
+       }
+
+       @Override
+       protected void execute() {
+
+       }
+
+       @Override
+       protected boolean isFinished() {
+               currentHeight = Robot.intakeArm.getArmHeight();
+               double distance = Math.abs(currentHeight - targetHeight);
+               if (distance <= SENSITIVITY_THRESHOLD) {
+                       return true;
+               } else {
+                       return false;
+               }
+
+       }
+
+       @Override
+       protected void end() {
+               Robot.intakeArm.setArmVoltage(NO_MOVEMENT_SPEED);
+       }
+
+       @Override
+       protected void interrupted() {
+       }
+}