98131673509e3089bb5bf861062225cfe807423d
1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
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
;
12 * The Shooter consists of a platform and wheel, each controlled by
13 * separate motors. The piston controlling the platform pushes the ball onto the
14 * wheel. The wheel is controlled by a motor, which is running before the ball
16 * onto the wheel. The spinning wheel propels the ball.
22 public class Shooter
extends Subsystem
{
23 private CANTalon shooter
;
24 private DoubleSolenoid hood
, punch
;
25 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
);
38 lidar
= new Lidar(Constants
.Shooter
.LIDAR_I2C_PORT
);
42 * This method checks to see if the ball has successfully passed through the
43 * intake rollers and is inside.
45 * @return whether the presence of the ball is true or false and returns the
46 * state of the condition (true or false).
49 public boolean isBallInside() {
53 public void setSpeed(double speed
) {
56 else if (speed
< -1.0)
66 public double getSpeed() {
67 return encoder
.getRate();
70 // Use negative # for decrement. Positive for increment.
72 public void changeSpeed(double change
) {
73 double newSpeed
= getSpeed() + change
;
78 public void extendPunch() {
79 punch
.set(Constants
.Shooter
.punch
);
82 public void retractPunch() {
83 punch
.set(Constants
.Shooter
.retract
);
86 public boolean isHoodOpen() {
87 return hood
.get() == Constants
.Shooter
.open
;
90 public void openHood() {
91 hood
.set(Constants
.Shooter
.open
);
94 public void closeHood() {
95 hood
.set(Constants
.Shooter
.closed
);
99 protected void initDefaultCommand() {