Adding command ClampBar
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
CommitLineData
a0c3ca74
KZ
1package org.usfirst.frc.team3501.robot.subsystems;
2
3import org.usfirst.frc.team3501.robot.Constants;
a0c3ca74
KZ
4
5import edu.wpi.first.wpilibj.CANTalon;
9b10474d 6import edu.wpi.first.wpilibj.DoubleSolenoid;
a0c3ca74
KZ
7import edu.wpi.first.wpilibj.command.Subsystem;
8
9public class Shooter extends Subsystem {
a0c3ca74 10 private CANTalon shooter;
4f516a69 11 private CANTalon angleAdjuster;
9b10474d 12 private DoubleSolenoid punch;
a0c3ca74
KZ
13
14 public Shooter() {
15 shooter = new CANTalon(Constants.Shooter.PORT);
ee92234b
GK
16 angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT);
17 punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT,
18 Constants.Shooter.PUNCH_REVERSE_PORT);
a0c3ca74
KZ
19 }
20
21 public double getCurrentSetPoint() {
22 return shooter.get();
23 }
24
25 public void setSpeed(double speed) {
913142de 26 if (speed > 1.0)
a0c3ca74 27 shooter.set(1.0);
913142de 28 else if (speed < -1.0)
a0c3ca74
KZ
29 shooter.set(-1.0);
30 else
31 shooter.set(speed);
32 }
33
34 public void stop() {
35 this.setSpeed(0.0);
36 }
37
a0c3ca74
KZ
38 // Use negative # for decrement. Positive for increment.
39 public void changeSpeed(double change) {
913142de
KZ
40 double newSpeed = getCurrentSetPoint() + change;
41 if (newSpeed > 1.0)
a0c3ca74 42 shooter.set(1.0);
07ceaad8 43 else if (newSpeed < -1.0)
a0c3ca74
KZ
44 shooter.set(-1.0);
45 else {
a0c3ca74
KZ
46 setSpeed(newSpeed);
47 }
48 }
49
9b10474d
GK
50 // Punch Commands
51 public void punch() {
52 punch.set(Constants.Shooter.punch);
53 }
54
55 public void resetPunch() {
56 punch.set(Constants.Shooter.retract);
57 }
58
a0c3ca74
KZ
59 @Override
60 protected void initDefaultCommand() {
61 }
62}