Created get arm angle method inside Arm class
[3501/2015-FRC-Spark] / src / org / usfirst / frc3501 / RiceCatRobot / subsystems / Arm.java
1 package org.usfirst.frc3501.RiceCatRobot.subsystems;
2
3 import org.usfirst.frc3501.RiceCatRobot.RobotMap;
4
5 import edu.wpi.first.wpilibj.AnalogInput;
6 import edu.wpi.first.wpilibj.AnalogPotentiometer;
7 import edu.wpi.first.wpilibj.CANJaguar;
8 import edu.wpi.first.wpilibj.command.Subsystem;
9
10 public class Arm extends Subsystem {
11 private CANJaguar left, right;
12 public AnalogPotentiometer analogPotentiometer;
13 static final double ANGLE_RANGE = 360;
14 static final double INITIAL_ANGLE = 30;
15
16 public Arm() {
17 left = new CANJaguar(RobotMap.ARM_LEFT);
18 right = new CANJaguar(RobotMap.ARM_RIGHT);
19 AnalogInput analogInput = new AnalogInput(1);
20 analogPotentiometer = new AnalogPotentiometer(analogInput, ANGLE_RANGE, INITIAL_ANGLE);
21 }
22
23 public double getArmAngle() {
24 return analogPotentiometer.get();
25 }
26
27 public void initDefaultCommand() {
28 }
29
30 public void fineTuneControl(double d) {
31 if (Math.abs(d) < 0.05) {
32 d = 0;
33 } else if (d > 0) {
34 d *= d;
35 } else {
36 d *= -d;
37 }
38 setArmSpeeds(d);
39 }
40
41 public void setLeft(double speed) {
42 left.set(-speed);
43 }
44
45 public void setRight(double speed) {
46 right.set(-speed);
47 }
48
49 public void setArmSpeeds(double speed) {
50 setLeft(speed);
51 setRight(speed);
52 }
53
54 public void stop() {
55 left.set(0);
56 right.set(0);
57 }
58
59 }