1 package org
.usfirst
.frc3501
.RiceCatRobot
.subsystems
;
3 import java
.util
.ArrayList
;
5 import org
.usfirst
.frc3501
.RiceCatRobot
.RobotMap
;
7 import edu
.wpi
.first
.wpilibj
.CANJaguar
;
8 import edu
.wpi
.first
.wpilibj
.DigitalInput
;
9 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
11 public class Arm
extends Subsystem
{
12 private CANJaguar left
, right
;
13 private ArrayList
<DigitalInput
> limitSwitches
;
14 //channel index numbers correspond to limit switches
15 private int[] channels
;
16 private int currentLevel
;
17 private final int NUM_OF_SWITCHES
= 4;
20 left
= new CANJaguar(RobotMap
.ARM_LEFT
);
21 right
= new CANJaguar(RobotMap
.ARM_RIGHT
);
23 //channels are not known, these are random numbers
24 channels
= new int[]{0, 1, 2, 3};
26 limitSwitches
= new ArrayList
<DigitalInput
>();
28 for(int i
= 0; i
< NUM_OF_SWITCHES
; i
++){
29 DigitalInput d
= limitSwitches
.get(i
);
30 d
= new DigitalInput(channels
[i
]);
35 channels
= new int[NUM_OF_SWITCHES
];
40 public void initDefaultCommand() {
43 public void fineTuneControl(double d
) {
44 if (Math
.abs(d
) < 0.05) {
54 public void setLeft(double speed
) {
58 public void setRight(double speed
) {
62 public void setArmSpeeds(double speed
) {
72 //should run in robot.java teleop periodic (autonomous periodic too maybe?)
73 public void updateLimitSwitches(){
74 for(int i
= 0; i
< NUM_OF_SWITCHES
; i
++){
75 DigitalInput d
= limitSwitches
.get(i
);
82 public int getLevel(){
83 //return last past switch