add method stub isBallInside to check and return presence of ball
[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.CounterBase.EncodingType;
7 import edu.wpi.first.wpilibj.DoubleSolenoid;
8 import edu.wpi.first.wpilibj.Encoder;
9 import edu.wpi.first.wpilibj.command.Subsystem;
10
11 public class Shooter extends Subsystem {
12 private CANTalon shooter;
13 private CANTalon angleAdjuster;
14 private DoubleSolenoid punch;
15 private Encoder encoder;
16
17 public Shooter() {
18 shooter = new CANTalon(Constants.Shooter.PORT);
19 angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT);
20 punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT,
21 Constants.Shooter.PUNCH_REVERSE_PORT);
22
23 encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
24 Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
25 }
26
27 public double getCurrentSetPoint() {
28 return shooter.get();
29 }
30
31 /***
32 * This method checks to see if the ball has successfully passed through the
33 * intake rollers and is inside.
34 *
35 * @return whether the presence of the ball is true or false and returns the
36 * state of the condition (true or false).
37 */
38
39 public boolean isBallInside() {
40 return true;
41 }
42
43 public void setSpeed(double speed) {
44 if (speed > 1.0)
45 shooter.set(1.0);
46 else if (speed < -1.0)
47 shooter.set(-1.0);
48 else
49 shooter.set(speed);
50 }
51
52 public void stop() {
53 this.setSpeed(0.0);
54 }
55
56 public double getSpeed() {
57 return encoder.getRate();
58 }
59
60 // Use negative # for decrement. Positive for increment.
61 public void changeSpeed(double change) {
62 double newSpeed = getCurrentSetPoint() + change;
63 if (newSpeed > 1.0)
64 shooter.set(1.0);
65 else if (newSpeed < -1.0)
66 shooter.set(-1.0);
67 else {
68 setSpeed(newSpeed);
69 }
70 }
71
72 // Punch Commands
73 public void punch() {
74 punch.set(Constants.Shooter.punch);
75 }
76
77 public void resetPunch() {
78 punch.set(Constants.Shooter.retract);
79 }
80
81 @Override
82 protected void initDefaultCommand() {
83 }
84 }