instantiate cheval de frise and angle adjuster motors
[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 CANTalon angleAdjuster;
12 private DoubleSolenoid punch;
13
14 public Shooter() {
15 shooter = new CANTalon(Constants.Shooter.PORT);
16 angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT);
17 punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT,
18 Constants.Shooter.PUNCH_REVERSE_PORT);
19 }
20
21 public double getCurrentSetPoint() {
22 return shooter.get();
23 }
24
25 public void setSpeed(double speed) {
26 if (speed > 1.0)
27 shooter.set(1.0);
28 else if (speed < -1.0)
29 shooter.set(-1.0);
30 else
31 shooter.set(speed);
32 }
33
34 public void stop() {
35 this.setSpeed(0.0);
36 }
37
38 // Use negative # for decrement. Positive for increment.
39 public void changeSpeed(double change) {
40 double newSpeed = getCurrentSetPoint() + change;
41 if (newSpeed > 1.0)
42 shooter.set(1.0);
43 else if (newSpeed < -1.0)
44 shooter.set(-1.0);
45 else {
46 setSpeed(newSpeed);
47 }
48 }
49
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
59 @Override
60 protected void initDefaultCommand() {
61 }
62 }