91793d8aebd2546c6733f1cd05f98302d72a6ae5
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
;
31 shooter
= new CANTalon(Constants
.Shooter
.PORT
);
32 hood1
= new DoubleSolenoid(Constants
.Shooter
.HOOD_FORWARD
,
33 Constants
.Shooter
.HOOD_REVERSE
);
34 hood2
= new DoubleSolenoid(Constants
.Shooter
.HOOD_FORWARD
,
35 Constants
.Shooter
.HOOD_REVERSE
);
36 punch
= new DoubleSolenoid(Constants
.Shooter
.PUNCH_FORWARD
,
37 Constants
.Shooter
.PUNCH_REVERSE
);
39 encoder
= new Encoder(Constants
.Shooter
.ENCODER_PORT_A
,
40 Constants
.Shooter
.ENCODER_PORT_B
, false, EncodingType
.k4X
);
44 * This method checks to see if the ball has successfully passed through the
45 * intake rollers and is inside.
47 * @return whether the presence of the ball is true or false and returns the
48 * state of the condition (true or false).
51 public boolean isBallInside() {
53 return photogate
.isBallPresent();
58 public void setSpeed(double speed
) {
61 else if (speed
< -1.0)
71 public double getSpeed() {
72 return encoder
.getRate();
76 * We are going to map a lidar distance to a shooter speed that will be set to
77 * the shooter. This function does not yet exist so we will just use y=x but
78 * when testing commences we shall create the function
80 public double getShooterSpeed() {
81 double distanceToGoal
= lidar
.getDistance();
82 double shooterSpeed
= distanceToGoal
; // Function to be determined
86 // Use negative # for decrement. Positive for increment.
88 public void changeSpeed(double change
) {
89 double newSpeed
= getSpeed() + change
;
94 public void extendPunch() {
95 punch
.set(Constants
.Shooter
.punch
);
98 public void retractPunch() {
99 punch
.set(Constants
.Shooter
.retract
);
102 public void raiseHood() {
103 hood1
.set(Constants
.Shooter
.open
);
104 hood2
.set(Constants
.Shooter
.open
);
107 public void lowerHood() {
108 hood1
.set(Constants
.Shooter
.closed
);
109 hood2
.set(Constants
.Shooter
.closed
);
112 public boolean isHoodDown() {
113 if (hood1
.get() == Constants
.Shooter
.open
114 && hood2
.get() == Constants
.Shooter
.open
)
119 public boolean usePhotogate() {
124 protected void initDefaultCommand() {