f42de1dfa0670af331e3521b4d5574f4c53efdf5
[3501/3501-spark-go] / src / org / usfirst / frc / team3501 / robot / subsystems / Arm.java
1 package org.usfirst.frc.team3501.robot.subsystems;
2
3 import org.usfirst.frc.team3501.robot.RobotMap;
4 import org.usfirst.frc.team3501.robot.commands.MoveArm;
5
6 import edu.wpi.first.wpilibj.CANJaguar;
7 import edu.wpi.first.wpilibj.command.Subsystem;
8
9 public class Arm extends Subsystem {
10
11 private CANJaguar left, right;
12
13 public Arm() {
14 left = new CANJaguar(RobotMap.LEFT_WINCH_ADDRESS);
15 right = new CANJaguar(RobotMap.RIGHT_WINCH_ADDRESS);
16 }
17
18 public void set(double speed) {
19 left.set(-speed);
20 right.set(speed);
21 }
22
23 public void setFromJoystick(double speed) {
24 set(getSpeedFromJoystick(speed));
25 }
26
27 public void moveLeft(double speed) {
28 left.set(speed);
29 right.set(0);
30 }
31
32 public void moveRight(double speed) {
33 right.set(speed);
34 left.set(0);
35 }
36
37 public double getSpeedFromJoystick(double speed) {
38 if (Math.abs(speed) < RobotMap.MIN_ARM_JOYSTICK_INPUT)
39 speed = 0;
40
41 return speed;
42 }
43
44 public void initDefaultCommand() {
45 setDefaultCommand(new MoveArm());
46 }
47 }