-package org.usfirst.frc.team3501.robot.subsystems;\r
-\r
-import org.usfirst.frc.team3501.robot.Constants;\r
-\r
-import edu.wpi.first.wpilibj.AnalogPotentiometer;\r
-import edu.wpi.first.wpilibj.CANTalon;\r
-import edu.wpi.first.wpilibj.command.Subsystem;\r
-\r
-public class DefenseArm extends Subsystem {\r
- // Defense arm related objects\r
- private AnalogPotentiometer defenseArmPotentiometer;\r
- private AnalogPotentiometer defenseHandPotentiometer;\r
- private CANTalon defenseArmMotor;\r
- private CANTalon defenseHandMotor;\r
- private double hookHeight;\r
- private double footHeight;\r
-\r
- // Defense arm specific constants that relate to the degrees per pulse value\r
- // for the potentiometers\r
- // private final static double PULSES_PER_ROTATION = 1; // in pulses\r
- public final static double FULL_RANGE = 270.0; // in degrees\r
- public final static double OFFSET = -135.0; // in degrees\r
- public final static double[] armPotValue = { 0.0, 45.0, 90.0 }; // 3 level\r
-\r
- // array;\r
-\r
- // do we want to use a hashmap??\r
- // angles at 0,45,90 (Potentiometer value readings)\r
- // degrees\r
-\r
- public DefenseArm() {\r
- defenseArmPotentiometer = new AnalogPotentiometer(\r
- Constants.DefenseArm.ARM_CHANNEL, FULL_RANGE, OFFSET);\r
-\r
- defenseArmMotor = new CANTalon(Constants.DefenseArm.ARM_PORT);\r
- defenseHandMotor = new CANTalon(Constants.DefenseArm.HAND_PORT);\r
- }\r
-\r
- /***\r
- * This method gets the height of the hook from the\r
- * ground. The hook is attached to the end of the hand, which is attached to\r
- * the arm.\r
- *\r
- * @return hookHeight gets height of hook from ground. The hook is attached to\r
- * the end of the hand, which is attached the arm. The height is in\r
- * inches.\r
- *\r
- */\r
-\r
- public double getHookHeight() {\r
-\r
- return 0;\r
- }\r
-\r
- /***\r
- * This method gets the height of the foot from the ground. The foot is\r
- * attached to the end of the hand, which is attached to the arm.\r
- *\r
- * @return footHeight gets height of foot from ground. The foot is attached to\r
- * the end of the hand, which is attached the arm. The height is in\r
- * inches.\r
- *\r
- */\r
-\r
- public double getFootHeight() {\r
- return 0;\r
- }\r
-\r
- /***\r
- * This method sets the voltage of the arm motor. The range is from [-1,1]. A\r
- * negative voltage makes the direction of the motor go backwards.\r
- *\r
- * @param speed\r
- * The voltage that you set the motor at. The range of the voltage of\r
- * the arm motor is from [-1,1]. A\r
- * negative voltage makes the direction of the motor go backwards.\r
- */\r
-\r
- public void setArmMotorSpeed(double speed) {\r
-\r
- }\r
-\r
- /***\r
- * This method sets the voltage of the hand motor. The range is from [-1,1]. A\r
- * negative voltage makes the direction of the motor go backwards.\r
- *\r
- * @param speed\r
- * The voltage that you set the motor at. The range of the voltage of\r
- * the hand motor is from [-1,1]. A\r
- * negative voltage makes the direction of the motor go backwards.\r
- */\r
-\r
- public void setHandMotorSpeed(double speed) {\r
- }\r
-\r
- @Override\r
- protected void initDefaultCommand() {\r
- }\r
-}\r
+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;
+
+public class DefenseArm extends Subsystem {
+ // Defense arm related objects
+ private AnalogPotentiometer defenseArmPotentiometer;
+ private AnalogPotentiometer defenseHandPotentiometer;
+ private CANTalon defenseArm;
+ private CANTalon defenseHand;
+ private double hookHeight;
+ private double footHeight;
+ private Double[] potAngles;
+
+ public DefenseArm() {
+ defenseArmPotentiometer = new AnalogPotentiometer(
+ Constants.DefenseArm.ARM_CHANNEL,
+ Constants.DefenseArm.FULL_RANGE,
+ Constants.DefenseArm.OFFSET);
+
+ defenseArm = new CANTalon(Constants.DefenseArm.ARM_PORT);
+ defenseHand = new CANTalon(Constants.DefenseArm.HAND_PORT);
+ }
+
+ public double getArmPotAngle() {
+ return defenseArmPotentiometer.get();
+ }
+
+ public double getHandPotAngle() {
+ return defenseHandPotentiometer.get();
+ }
+
+ public double getDistance(int desiredArmLocation) {
+ return potAngles[desiredArmLocation];
+ }
+
+ public Double[] putInValues() {
+ for (int i = 0; i < 3; i++) {
+ potAngles[i] = (double) (45 * i);
+ }
+ return potAngles;
+ }
+
+ /***
+ * 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 speed
+ * 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 speed) {
+ if (speed > 1)
+ speed = 1;
+ else if (speed < -1)
+ speed = -1;
+
+ defenseArm.set(speed);
+ }
+
+ /***
+ * This method sets the voltage of the hand motor. The range is from [-1,1]. A
+ * negative voltage makes the direction of the motor go backwards.
+ *
+ * @param speed
+ * The voltage that you set the motor at. The range of the voltage of
+ * the hand motor is from [-1,1]. A
+ * negative voltage makes the direction of the motor go backwards.
+ */
+
+ public void setHandSpeed(double speed) {
+ if (speed > 1)
+ speed = 1;
+ else if (speed < -1)
+ speed = -1;
+
+ defenseHand.set(speed);
+ }
+
+ @Override
+ protected void initDefaultCommand() {
+ }
+}