1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.MathLib
;
6 import edu
.wpi
.first
.wpilibj
.CANTalon
;
7 import edu
.wpi
.first
.wpilibj
.CounterBase
.EncodingType
;
8 import edu
.wpi
.first
.wpilibj
.DoubleSolenoid
;
9 import edu
.wpi
.first
.wpilibj
.Encoder
;
10 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
13 * The Shooter consists of a platform and wheel, each controlled by
14 * separate motors. The piston controlling the platform pushes the ball onto the
15 * wheel. The wheel is controlled by a motor, which is running before the ball
17 * onto the wheel. The spinning wheel propels the ball.
23 public class Shooter
extends Subsystem
{
24 private CANTalon shooter
;
25 private DoubleSolenoid hood
, punch
;
26 private Encoder encoder
;
29 shooter
= new CANTalon(Constants
.Shooter
.PORT
);
30 hood
= new DoubleSolenoid(Constants
.Shooter
.HOOD_FORWARD
,
31 Constants
.Shooter
.HOOD_REVERSE
);
32 punch
= new DoubleSolenoid(Constants
.Shooter
.PUNCH_FORWARD
,
33 Constants
.Shooter
.PUNCH_REVERSE
);
35 encoder
= new Encoder(Constants
.Shooter
.ENCODER_PORT_A
,
36 Constants
.Shooter
.ENCODER_PORT_B
, false, EncodingType
.k4X
);
40 * This method checks to see if the ball has successfully passed through the
41 * intake rollers and is inside.
43 * @return whether the presence of the ball is true or false and returns the
44 * state of the condition (true or false).
47 public boolean isBallInside() {
51 public void setSpeed(double speed
) {
52 speed
= MathLib
.constrain(speed
, -1, 1);
60 public double getSpeed() {
61 return encoder
.getRate();
64 // Use negative # for decrement. Positive for increment.
66 public void changeSpeed(double change
) {
67 double newSpeed
= getSpeed() + change
;
73 punch
.set(Constants
.Shooter
.punch
);
76 public void retractPunch() {
77 punch
.set(Constants
.Shooter
.retract
);
80 public boolean isHoodOpen() {
81 return hood
.get() == Constants
.Shooter
.open
;
84 public void openHood() {
85 hood
.set(Constants
.Shooter
.open
);
88 public void closeHood() {
89 hood
.set(Constants
.Shooter
.closed
);
93 protected void initDefaultCommand() {