43aea8990254a242bdcc97d8b4f12d9c746005ca
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
;
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 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
);
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
) {
54 else if (speed
< -1.0)
64 public double getSpeed() {
65 return encoder
.getRate();
69 * We are going to map a lidar distance to a shooter speed that will be set to
70 * the shooter. This function does not yet exist so we will just use y=x but
71 * when testing commences we shall create the function
73 public double getShooterSpeed() {
74 double distanceToGoal
= lidar
.getDistance();
75 double shooterSpeed
= distanceToGoal
; // Function to be determined
79 // Use negative # for decrement. Positive for increment.
81 public void changeSpeed(double change
) {
82 double newSpeed
= getSpeed() + change
;
87 public void extendPunch() {
88 punch
.set(Constants
.Shooter
.punch
);
91 public void retractPunch() {
92 punch
.set(Constants
.Shooter
.retract
);
95 public void raiseHood() {
96 hood
.set(Constants
.Shooter
.open
);
99 public void lowerHood() {
100 hood
.set(Constants
.Shooter
.closed
);
103 public boolean isHoodDown() {
104 if (hood
.get() == Constants
.Shooter
.open
)
110 protected void initDefaultCommand() {