add class level comment for Shooter class- describe mechanism
[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 /***
12 * The Shooter consists of a platform and wheel, each controlled by
13 * separate motors. The motor controlling the platform pushes the ball onto the
14 * wheel. The wheel is controlled by a motor, which runs once the ball is pushed
15 * onto the wheel. The spinning wheel propels the ball.
16 *
17 * @author superuser
18 *
19 */
20
21 public class Shooter extends Subsystem {
22 private CANTalon shooter;
23 private CANTalon angleAdjuster;
24 private DoubleSolenoid punch;
25 private Encoder encoder;
26
27 public Shooter() {
28 shooter = new CANTalon(Constants.Shooter.PORT);
29 angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT);
30 punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT,
31 Constants.Shooter.PUNCH_REVERSE_PORT);
32
33 encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
34 Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
35 }
36
37 public double getCurrentSetPoint() {
38 return shooter.get();
39 }
40
41 /***
42 * This method checks to see if the ball has successfully passed through the
43 * intake rollers and is inside.
44 *
45 * @return whether the presence of the ball is true or false and returns the
46 * state of the condition (true or false).
47 */
48
49 public boolean isBallInside() {
50 return true;
51 }
52
53 public void setSpeed(double speed) {
54 if (speed > 1.0)
55 shooter.set(1.0);
56 else if (speed < -1.0)
57 shooter.set(-1.0);
58 else
59 shooter.set(speed);
60 }
61
62 public void stop() {
63 this.setSpeed(0.0);
64 }
65
66 public double getSpeed() {
67 return encoder.getRate();
68 }
69
70 // Use negative # for decrement. Positive for increment.
71
72 public void changeSpeed(double change) {
73 double newSpeed = getCurrentSetPoint() + change;
74 if (newSpeed > 1.0)
75 shooter.set(1.0);
76 else if (newSpeed < -1.0)
77 shooter.set(-1.0);
78 else {
79 setSpeed(newSpeed);
80 }
81 }
82
83 // Punch Commands
84 public void punch() {
85 punch.set(Constants.Shooter.punch);
86 }
87
88 public void resetPunch() {
89 punch.set(Constants.Shooter.retract);
90 }
91
92 @Override
93 protected void initDefaultCommand() {
94 }
95 }