ee2742d2b0209e88c0cd18cd0b54fbebcd9c070b
1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.MathLib
;
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
14 * separate motors. The piston controlling the platform pushes the ball onto the
15 * wheel. The wheel is controlled by a motor, which is running before the ball
17 * onto the wheel. The spinning wheel propels the ball.
23 public class Shooter
extends Subsystem
{
24 private CANTalon shooter
;
25 private CANTalon angleAdjuster
;
26 private DoubleSolenoid punch
;
27 private Encoder encoder
;
30 shooter
= new CANTalon(Constants
.Shooter
.PORT
);
31 angleAdjuster
= new CANTalon(Constants
.Shooter
.ANGLE_ADJUSTER_PORT
);
32 punch
= new DoubleSolenoid(Constants
.Shooter
.PUNCH_FORWARD_PORT
,
33 Constants
.Shooter
.PUNCH_REVERSE_PORT
);
35 encoder
= new Encoder(Constants
.Shooter
.ENCODER_PORT_A
,
36 Constants
.Shooter
.ENCODER_PORT_B
, false, EncodingType
.k4X
);
40 * This method checks to see if the ball has successfully passed through the
41 * intake rollers and is inside.
43 * @return whether the presence of the ball is true or false and returns the
44 * state of the condition (true or false).
47 public boolean isBallInside() {
51 public void setSpeed(double speed
) {
52 speed
= MathLib
.constrain(speed
, -1, 1);
60 public double getSpeed() {
61 return encoder
.getRate();
64 // Use negative # for decrement. Positive for increment.
66 public void changeSpeed(double change
) {
67 double newSpeed
= getSpeed() + change
;
73 punch
.set(Constants
.Shooter
.punch
);
76 public void retractPunch() {
77 punch
.set(Constants
.Shooter
.retract
);
81 protected void initDefaultCommand() {