Creates methods for setting speed, adding to speed, and subtracting from speed along...
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.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.CANTalon;
6 import edu.wpi.first.wpilibj.command.Subsystem;
7
8 public class Shooter extends Subsystem {
9 CANTalon wheel;
10
11 public Shooter() {
12 wheel = new CANTalon(Constants.Shooter.SHOOTER_WHEEL_PORT);
13 }
14
15 public double getCurrentSpeed() {
16 return wheel.get();
17 }
18
19 public void setSpeed(double speed) {
20 wheel.set(speed);
21 }
22
23 public void setIncrementSpeed(double increment) {
24 double newSpeed = getCurrentSpeed() + increment;
25
26 if (getCurrentSpeed() >= 1.0) {
27 wheel.set(1.0);
28 } else if (getCurrentSpeed() <= -1.0) {
29 wheel.set(-1.0);
30 }
31
32 wheel.set(newSpeed);
33 }
34
35 // THIS DECREMENT METHOD TAKES ONLY POSITIVE VALUES SINCE IT ACCOUNTS FOR
36 // SUBTRACTING THE CURRENT MOTOR SPEED!
37 public void setDecrementSpeed(double decrement) {
38 double newSpeed = getCurrentSpeed() - decrement;
39
40 if (getCurrentSpeed() >= 1.0) {
41 wheel.set(1.0);
42 } else if (getCurrentSpeed() <= -1.0) {
43 wheel.set(-1.0);
44 }
45
46 wheel.set(newSpeed);
47 }
48
49 @Override
50 protected void initDefaultCommand() {
51
52 }
53 }