Create identical copy of IntakeArm subsystem but with slight modifications to remove... evan/update-defense-arm
authorEvanYap <evanyap.14@gmail.com>
Tue, 16 Feb 2016 02:09:29 +0000 (18:09 -0800)
committerEvanYap <evanyap.14@gmail.com>
Tue, 16 Feb 2016 02:09:29 +0000 (18:09 -0800)
src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java [new file with mode: 0644]

diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java b/src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java
new file mode 100644 (file)
index 0000000..963c089
--- /dev/null
@@ -0,0 +1,89 @@
+package org.usfirst.frc.team3501.robot.subsystems;
+
+import org.usfirst.frc.team3501.robot.Constants;
+
+import edu.wpi.first.wpilibj.AnalogPotentiometer;
+import edu.wpi.first.wpilibj.CANTalon;
+import edu.wpi.first.wpilibj.command.Subsystem;
+
+/***
+ * The IntakeArm consists of two rollers that are controlled by one motor, with
+ * a potentiometer on it.
+ *
+ * The motor controls the rollers, making them roll forwards and backwards. The
+ * Intake rollers are on the back of the robot. As the rollers run, they intake
+ * the ball.
+ *
+ * @author superuser
+ *
+ */
+
+public class DefenseArm extends Subsystem {
+
+  private CANTalon defenseArm;
+  private AnalogPotentiometer defensePot;
+  public static double[] potAngles = { 0, 30, 45, 90 }; // TODO: correct angles
+  public static double moveIntakeArmSpeed = 0;
+
+  public DefenseArm() {
+    defenseArm = new CANTalon(Constants.IntakeArm.ARM_PORT);
+    defensePot = new AnalogPotentiometer(Constants.DefenseArm.POT_CHANNEL,
+        Constants.IntakeArm.FULL_RANGE, Constants.DefenseArm.OFFSET);
+  }
+
+  /***
+   * This method sets the voltage of the arm motor. The range is from [-1,1]. A
+   * negative voltage makes the direction of the motor go backwards.
+   *
+   * @param voltage
+   *          The voltage that you set the motor at. The range of the voltage of
+   *          the arm motor is from [-1,1]. A negative voltage makes the
+   *          direction of the motor go backwards.
+   */
+
+  public void setArmSpeed(double voltage) {
+    if (voltage > 1)
+      voltage = 1;
+    else if (voltage < -1)
+      voltage = -1;
+
+    defenseArm.set(voltage);
+  }
+
+  /***
+   * This method gets you the current voltage of the motor that controls the
+   * intake arm. The range of voltage is from [-1,1]. A negative voltage makes
+   * the motor run backwards.
+   *
+   * @return Returns the voltage of the motor that controls the arm. The range
+   *         of the voltage goes from [-1,1]. A negative voltage indicates that
+   *         the motor is running backwards.
+   */
+
+  public double getArmSpeed() {
+    return defenseArm.get();
+  }
+
+  /***
+   * This method gets the angle of the potentiometer on the Intake Arm.
+   *
+   * @return angle of potentiometer
+   */
+
+  public double getArmAngle() {
+    return defensePot.get() + Constants.IntakeArm.ZERO_ANGLE;
+  }
+
+  public void stop() {
+    setArmSpeed(0);
+  }
+
+  public double getAngleForLevel(double targetLevel) {
+    return potAngles[(int) (targetLevel - 1)];
+  }
+
+  @Override
+  protected void initDefaultCommand() {
+
+  }
+}