22239e49ee945c5bd0a9a163d9a9da7160233db2
1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.Lidar
;
5 import org
.usfirst
.frc
.team3501
.robot
.MathLib
;
7 import edu
.wpi
.first
.wpilibj
.AnalogPotentiometer
;
8 import edu
.wpi
.first
.wpilibj
.CANTalon
;
9 import edu
.wpi
.first
.wpilibj
.CounterBase
.EncodingType
;
10 import edu
.wpi
.first
.wpilibj
.DoubleSolenoid
;
11 import edu
.wpi
.first
.wpilibj
.Encoder
;
12 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
15 * The Shooter consists of a platform and wheel, each controlled by separate
16 * motors. The piston controlling the platform pushes the ball onto the wheel.
17 * The wheel is controlled by a motor, which is running before the ball is
18 * pushed onto the wheel. The spinning wheel propels the ball.
24 public class Shooter
extends Subsystem
{
25 private CANTalon shooter
;
26 private CANTalon angleAdjuster
;
27 private DoubleSolenoid hood
, punch
;
28 private Encoder encoder
;
32 leftLidar
= new AnalogPotentiometer(0);
33 rightLidar
= new AnalogPotentiometer(0);
34 shooter
= new CANTalon(Constants
.Shooter
.PORT
);
35 angleAdjuster
= new CANTalon(Constants
.Shooter
.ANGLE_ADJUSTER_PORT
);
36 punch
= new DoubleSolenoid(Constants
.Shooter
.PUNCH_FORWARD_PORT
,
37 Constants
.Shooter
.PUNCH_REVERSE_PORT
);
39 encoder
= new Encoder(Constants
.Shooter
.ENCODER_PORT_A
,
40 Constants
.Shooter
.ENCODER_PORT_B
, false, EncodingType
.k4X
);
44 * This method checks to see if the ball has successfully passed through the
45 * intake rollers and is inside.
47 * @return whether the presence of the ball is true or false and returns the
48 * state of the condition (true or false).
51 public boolean isBallInside() {
55 public void setSpeed(double speed
) {
58 else if (speed
< -1.0)
68 public double getSpeed() {
69 return encoder
.getRate();
72 // Use negative # for decrement. Positive for increment.
74 public void changeSpeed(double change
) {
75 double newSpeed
= getSpeed() + change
;
80 public void extendPunch() {
81 punch
.set(Constants
.Shooter
.punch
);
84 public void retractPunch() {
85 punch
.set(Constants
.Shooter
.retract
);
89 protected void initDefaultCommand() {
92 public double getLeftDistanceToTower() {
93 // TODO: find the method that actually gets distance
94 return leftLidar
.get();
97 public double getRightDistanceToTower() {
98 return rightLidar
.get();