1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.sensors
.Lidar
;
5 import org
.usfirst
.frc
.team3501
.robot
.sensors
.Photogate
;
7 import edu
.wpi
.first
.wpilibj
.CANTalon
;
8 import edu
.wpi
.first
.wpilibj
.CounterBase
.EncodingType
;
9 import edu
.wpi
.first
.wpilibj
.DoubleSolenoid
;
10 import edu
.wpi
.first
.wpilibj
.Encoder
;
11 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
14 * The Shooter consists of a platform and wheel, each controlled by separate
15 * motors. The piston controlling the platform pushes the ball onto the wheel.
16 * The wheel is controlled by a motor, which is running before the ball is
17 * pushed onto the wheel. The spinning wheel propels the ball.
23 public class Shooter
extends Subsystem
{
24 private CANTalon shooter
;
25 private DoubleSolenoid hood1
, hood2
, punch
;
26 private Encoder encoder
;
28 private Photogate photogate
;
29 private boolean usePhotoGate
;
32 shooter
= new CANTalon(Constants
.Shooter
.PORT
);
33 hood1
= new DoubleSolenoid(Constants
.Shooter
.HOOD_FORWARD
,
34 Constants
.Shooter
.HOOD_REVERSE
);
35 hood2
= new DoubleSolenoid(Constants
.Shooter
.HOOD_FORWARD
,
36 Constants
.Shooter
.HOOD_REVERSE
);
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
);
46 * This method checks to see if the ball has successfully passed through the
47 * intake rollers and is inside.
49 * @return whether the presence of the ball is true or false and returns the
50 * state of the condition (true or false).
53 public boolean isBallInside() {
56 return photogate
.isBallPresent();
62 public void setSpeed(double speed
) {
65 else if (speed
< -1.0)
75 public double getSpeed() {
76 return encoder
.getRate();
80 * We are going to map a lidar distance to a shooter speed that will be set to
81 * the shooter. This function does not yet exist so we will just use y=x but
82 * when testing commences we shall create the function
84 public double getShooterSpeed() {
85 double distanceToGoal
= lidar
.getDistance();
86 double shooterSpeed
= distanceToGoal
; // Function to be determined
90 // Use negative # for decrement. Positive for increment.
92 public void changeSpeed(double change
) {
93 double newSpeed
= getSpeed() + change
;
98 public void extendPunch() {
99 punch
.set(Constants
.Shooter
.punch
);
102 public void retractPunch() {
103 punch
.set(Constants
.Shooter
.retract
);
106 public void raiseHood() {
107 hood1
.set(Constants
.Shooter
.open
);
108 hood2
.set(Constants
.Shooter
.open
);
111 public void lowerHood() {
112 hood1
.set(Constants
.Shooter
.closed
);
113 hood2
.set(Constants
.Shooter
.closed
);
116 public boolean isHoodDown() {
117 if (hood1
.get() == Constants
.Shooter
.open
118 && hood2
.get() == Constants
.Shooter
.open
)
123 public boolean usePhotogate() {
124 return this.usePhotoGate
;
127 public void togglePhotoGate() {
128 this.usePhotoGate
= !this.usePhotoGate
;
132 protected void initDefaultCommand() {