d91b234192218906cb44e1847f22666af90b913b
1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.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 CANTalon angleAdjuster
;
25 private DoubleSolenoid hood
, punch
;
26 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
,
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();
68 public double getShooterSpeed() {
69 double distanceToGoal
= lidar
.getDistance();
70 double shooterSpeed
= distanceToGoal
; // Function to be determined
74 // Use negative # for decrement. Positive for increment.
76 public void changeSpeed(double change
) {
77 double newSpeed
= getSpeed() + change
;
82 public void extendPunch() {
83 punch
.set(Constants
.Shooter
.punch
);
86 public void retractPunch() {
87 punch
.set(Constants
.Shooter
.retract
);
91 protected void initDefaultCommand() {