40a227ce1cb205bd192d4e4731e546e2cda17bfa
1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
5 import edu
.wpi
.first
.wpilibj
.AnalogPotentiometer
;
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 separate
14 * motors. The piston controlling the platform pushes the ball onto the wheel.
15 * The wheel is controlled by a motor, which is running before the ball is
16 * pushed 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 leftLidar
= new AnalogPotentiometer(0);
30 rightLidar
= new AnalogPotentiometer(0);
31 shooter
= new CANTalon(Constants
.Shooter
.PORT
);
32 hood
= new DoubleSolenoid(Constants
.Shooter
.HOOD_FORWARD
,
33 Constants
.Shooter
.HOOD_REVERSE
);
34 punch
= new DoubleSolenoid(Constants
.Shooter
.PUNCH_FORWARD
,
35 Constants
.Shooter
.PUNCH_REVERSE
);
37 encoder
= new Encoder(Constants
.Shooter
.ENCODER_PORT_A
,
38 Constants
.Shooter
.ENCODER_PORT_B
, false, EncodingType
.k4X
);
40 lidar
= new Lidar(Constants
.Shooter
.LIDAR_I2C_PORT
);
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() {
55 public void setSpeed(double speed
) {
58 else if (speed
< -1.0)
68 public double getSpeed() {
69 return encoder
.getRate();
72 // Use negative # for decrement. Positive for increment.
74 public void changeSpeed(double change
) {
75 double newSpeed
= getSpeed() + change
;
80 public void extendPunch() {
81 punch
.set(Constants
.Shooter
.punch
);
84 public void retractPunch() {
85 punch
.set(Constants
.Shooter
.retract
);
89 protected void initDefaultCommand() {
92 public void openHood() {
93 hood
.set(Constants
.Shooter
.open
);
96 public void closeHood() {
97 hood
.set(Constants
.Shooter
.closed
);
101 protected void initDefaultCommand() {