5c92506da9844c021fb770c3736209336df97183
1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.Lidar
;
5 import org
.usfirst
.frc
.team3501
.robot
.MathLib
;
7 import edu
.wpi
.first
.wpilibj
.AnalogPotentiometer
;
8 import edu
.wpi
.first
.wpilibj
.CANTalon
;
9 import edu
.wpi
.first
.wpilibj
.CounterBase
.EncodingType
;
10 import edu
.wpi
.first
.wpilibj
.DoubleSolenoid
;
11 import edu
.wpi
.first
.wpilibj
.Encoder
;
12 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
15 * The Shooter consists of a platform and wheel, each controlled by
16 * separate motors. The piston controlling the platform pushes the ball onto the
17 * wheel. The wheel is controlled by a motor, which is running before the ball
19 * onto the wheel. The spinning wheel propels the ball.
25 public class Shooter
extends Subsystem
{
26 private CANTalon shooter
;
27 private CANTalon angleAdjuster
;
28 private DoubleSolenoid hood
, punch
;
29 private Encoder encoder
;
33 shooter
= new CANTalon(Constants
.Shooter
.PORT
);
34 hood
= new DoubleSolenoid(Constants
.Shooter
.HOOD_FORWARD
,
35 Constants
.Shooter
.HOOD_REVERSE
);
36 angleAdjuster
= new CANTalon(Constants
.Shooter
.ANGLE_ADJUSTER_PORT
);
37 punch
= new DoubleSolenoid(Constants
.Shooter
.PUNCH_FORWARD
,
38 Constants
.Shooter
.PUNCH_REVERSE
);
40 encoder
= new Encoder(Constants
.Shooter
.ENCODER_PORT_A
,
41 Constants
.Shooter
.ENCODER_PORT_B
, false, EncodingType
.k4X
);
43 lidar
= new Lidar(Constants
.Shooter
.LIDAR_I2C_PORT
);
47 * This method checks to see if the ball has successfully passed through the
48 * intake rollers and is inside.
50 * @return whether the presence of the ball is true or false and returns the
51 * state of the condition (true or false).
54 public boolean isBallInside() {
58 public void setSpeed(double speed
) {
61 else if (speed
< -1.0)
71 public double getSpeed() {
72 return encoder
.getRate();
75 // Use negative # for decrement. Positive for increment.
77 public void changeSpeed(double change
) {
78 double newSpeed
= getSpeed() + change
;
83 public void extendPunch() {
84 punch
.set(Constants
.Shooter
.punch
);
87 public void retractPunch() {
88 punch
.set(Constants
.Shooter
.retract
);
91 public boolean isHoodOpen() {
92 return hood
.get() == Constants
.Shooter
.open
;
95 public void openHood() {
96 hood
.set(Constants
.Shooter
.open
);
99 public void closeHood() {
100 hood
.set(Constants
.Shooter
.closed
);
104 protected void initDefaultCommand() {