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 CANTalon angleAdjuster
;
26 private DoubleSolenoid hood
, punch
;
27 private Encoder encoder
;
29 private Photogate photogate
;
32 shooter
= new CANTalon(Constants
.Shooter
.PORT
);
33 angleAdjuster
= new CANTalon(Constants
.Shooter
.ANGLE_ADJUSTER_PORT
);
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
);
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() {
50 return photogate
.isBallPresent();
53 public void setSpeed(double speed
) {
56 else if (speed
< -1.0)
66 public double getSpeed() {
67 return encoder
.getRate();
71 * We are going to map a lidar distance to a shooter speed that will be set to
72 * the shooter. This function does not yet exist so we will just use y=x but
73 * when testing commences we shall create the function
75 public double getShooterSpeed() {
76 double distanceToGoal
= lidar
.getDistance();
77 double shooterSpeed
= distanceToGoal
; // Function to be determined
81 // Use negative # for decrement. Positive for increment.
83 public void changeSpeed(double change
) {
84 double newSpeed
= getSpeed() + change
;
89 public void extendPunch() {
90 punch
.set(Constants
.Shooter
.punch
);
93 public void retractPunch() {
94 punch
.set(Constants
.Shooter
.retract
);
98 protected void initDefaultCommand() {