Add the piston solenoid object to shooter and add punch methods/constants
[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.DoubleSolenoid;
7 import edu.wpi.first.wpilibj.command.Subsystem;
8
9 public class Shooter extends Subsystem {
10 private CANTalon shooter;
11 private DoubleSolenoid punch;
12
13 public Shooter() {
14 shooter = new CANTalon(Constants.Shooter.PORT);
15 punch = new DoubleSolenoid(Constants.Shooter.FORWARD_PORT,
16 Constants.Shooter.REVERSE_PORT);
17 }
18
19 public double getCurrentSetPoint() {
20 return shooter.get();
21 }
22
23 public void setSpeed(double speed) {
24 if (speed > 1.0)
25 shooter.set(1.0);
26 else if (speed < -1.0)
27 shooter.set(-1.0);
28 else
29 shooter.set(speed);
30 }
31
32 public void stop() {
33 this.setSpeed(0.0);
34 }
35
36 // Use negative # for decrement. Positive for increment.
37 public void changeSpeed(double change) {
38 double newSpeed = getCurrentSetPoint() + change;
39 if (newSpeed > 1.0)
40 shooter.set(1.0);
41 else if (newSpeed < -1.0)
42 shooter.set(-1.0);
43 else {
44 setSpeed(newSpeed);
45 }
46 }
47
48 // Punch Commands
49 public void punch() {
50 punch.set(Constants.Shooter.punch);
51 }
52
53 public void resetPunch() {
54 punch.set(Constants.Shooter.retract);
55 }
56
57 @Override
58 protected void initDefaultCommand() {
59 }
60 }