add indentical classes of Intakearm package commands to this package
authorEvanYap <evanyap.14@gmail.com>
Tue, 16 Feb 2016 02:00:43 +0000 (18:00 -0800)
committerEvanYap <evanyap.14@gmail.com>
Tue, 16 Feb 2016 02:00:43 +0000 (18:00 -0800)
src/org/usfirst/frc/team3501/robot/commands/defensearm/MoveIntakeArmToAngle.java [new file with mode: 0644]
src/org/usfirst/frc/team3501/robot/commands/defensearm/MoveIntakeArmUp.java [new file with mode: 0644]

diff --git a/src/org/usfirst/frc/team3501/robot/commands/defensearm/MoveIntakeArmToAngle.java b/src/org/usfirst/frc/team3501/robot/commands/defensearm/MoveIntakeArmToAngle.java
new file mode 100644 (file)
index 0000000..77023dd
--- /dev/null
@@ -0,0 +1,59 @@
+package org.usfirst.frc.team3501.robot.commands.defensearm;
+
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+public class MoveIntakeArmToAngle extends Command {
+       private double currentAngle;
+       private double targetAngle;
+       private double targetSpeed;
+       private double SENSITIVITY_THRESHOLD = 0.1;
+       private boolean isDecreasing = false;
+
+       public MoveIntakeArmToAngle(double angle, double speed) {
+               requires(Robot.intakeArm);
+               targetAngle = angle;
+               targetSpeed = speed;
+
+       }
+
+       @Override
+       protected void initialize() {
+               currentAngle = Robot.intakeArm.getArmAngle();
+               double difference = targetAngle - currentAngle;
+               if (difference > 0) {
+                       Robot.intakeArm.setArmSpeed(targetSpeed);
+                       isDecreasing = true;
+               } else {
+                       Robot.intakeArm.setArmSpeed(-targetSpeed);
+                       isDecreasing = false;
+               }
+       }
+
+       @Override
+       protected void execute() {
+
+       }
+
+       @Override
+       protected boolean isFinished() {
+               currentAngle = Robot.intakeArm.getArmAngle();
+
+               if (isDecreasing == true) {
+                       return (currentAngle <= targetAngle + SENSITIVITY_THRESHOLD);
+               } else {
+                       return (currentAngle >= targetAngle + SENSITIVITY_THRESHOLD);
+               }
+       }
+
+       @Override
+       protected void end() {
+               Robot.intakeArm.stop();
+       }
+
+       @Override
+       protected void interrupted() {
+       }
+
+}
diff --git a/src/org/usfirst/frc/team3501/robot/commands/defensearm/MoveIntakeArmUp.java b/src/org/usfirst/frc/team3501/robot/commands/defensearm/MoveIntakeArmUp.java
new file mode 100644 (file)
index 0000000..437d04b
--- /dev/null
@@ -0,0 +1,30 @@
+package org.usfirst.frc.team3501.robot.commands.defensearm;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+public class MoveIntakeArmUp extends Command {
+
+  public MoveIntakeArmUp() {
+  }
+
+  @Override
+  protected void initialize() {
+  }
+
+  @Override
+  protected void execute() {
+  }
+
+  @Override
+  protected boolean isFinished() {
+    return false;
+  }
+
+  @Override
+  protected void end() {
+  }
+
+  @Override
+  protected void interrupted() {
+  }
+}