e54ca7269297423eaa89db06463b8c4118298b21
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
.DoubleSolenoid
.Value
;
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 DoubleSolenoid hood
, punch
;
26 private Encoder encoder
;
30 shooter
= new CANTalon(Constants
.Shooter
.PORT
);
31 hood
= new DoubleSolenoid(Constants
.Shooter
.HOOD_FORWARD
,
32 Constants
.Shooter
.HOOD_REVERSE
);
33 punch
= new DoubleSolenoid(Constants
.Shooter
.PUNCH_FORWARD
,
34 Constants
.Shooter
.PUNCH_REVERSE
);
36 encoder
= new Encoder(Constants
.Shooter
.ENCODER_PORT_A
,
37 Constants
.Shooter
.ENCODER_PORT_B
, false, EncodingType
.k4X
);
41 * This method checks to see if the ball has successfully passed through the
42 * intake rollers and is inside.
44 * @return whether the presence of the ball is true or false and returns the
45 * state of the condition (true or false).
48 public boolean isBallInside() {
52 public void setSpeed(double speed
) {
55 else if (speed
< -1.0)
65 public double getSpeed() {
66 return encoder
.getRate();
70 * We are going to map a lidar distance to a shooter speed that will be set to
71 * the shooter. This function does not yet exist so we will just use y=x but
72 * when testing commences we shall create the function
74 public double getShooterSpeed() {
75 double distanceToGoal
= lidar
.getDistance();
76 double shooterSpeed
= distanceToGoal
; // Function to be determined
80 // Use negative # for decrement. Positive for increment.
82 public void changeSpeed(double change
) {
83 double newSpeed
= getSpeed() + change
;
88 public void extendPunch() {
89 punch
.set(Constants
.Shooter
.punch
);
92 public void retractPunch() {
93 punch
.set(Constants
.Shooter
.retract
);
96 public void raiseHood() {
97 hood
.set(Constants
.Shooter
.open
);
100 public void lowerHood() {
101 hood
.set(Constants
.Shooter
.closed
);
104 public boolean isHoodDown() {
105 if (hood
.get() == Value
.kReverse
)
111 protected void initDefaultCommand() {