change array name from levelsToDegrees to armPotValues
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / DefenseArm.java
1 package org.usfirst.frc.team3501.robot.subsystems;
2
3 import org.usfirst.frc.team3501.robot.Constants;
4
5 import edu.wpi.first.wpilibj.AnalogPotentiometer;
6 import edu.wpi.first.wpilibj.CANTalon;
7 import edu.wpi.first.wpilibj.command.Subsystem;
8
9 public class DefenseArm extends Subsystem {
10 // Defense arm related objects
11 private AnalogPotentiometer potentiometer;
12 private CANTalon defenseArmMotor;
13
14 // Defense arm specific constants that relate to the degrees per pulse value
15 // for the potentiometers
16 private final static double PULSES_PER_ROTATION = 1; // in pulses
17 private final static double FULL_RANGE = 270.0; // in degrees
18 private final static double OFFSET = -135.0; // in degrees
19 private Double[] levelsToDegrees = { 0.0, 45.0, 90.0 }; // 3 level array;
20
21 // angles at 0,45,90
22 // degrees
23
24 public DefenseArm() {
25 potentiometer = new AnalogPotentiometer(Constants.DefenseArm.CHANNEL,
26 FULL_RANGE, OFFSET);
27 defenseArmMotor = new CANTalon(Constants.DefenseArm.PORT);
28 }
29
30 public double getLevel(int desiredArmLocation) {
31 return levelsToDegrees[desiredArmLocation];
32 }
33
34 public void moveArmTo(int levelsToDegrees) {
35
36 }
37
38 public void moveArmDown(int levelsToDegrees) {
39 // to move arm down levels
40 if (levelsToDegrees > 0 & levelsToDegrees < 45) {
41 levelsToDegrees = 0;
42 if (levelsToDegrees > 45 & levelsToDegrees < 90) {
43 levelsToDegrees = 45;
44
45 }
46 }
47 }
48
49 public void moveArmUp(int levelsToDegrees) {
50 // to move arm up levels
51 if (levelsToDegrees < 45 & levelsToDegrees > 0) {
52 levelsToDegrees = 45;
53 if (levelsToDegrees < 90 & levelsToDegrees > 45) {
54 levelsToDegrees = 90;
55
56 }
57
58 }
59 }
60
61 @Override
62 protected void initDefaultCommand() {
63 }
64 }