Use constant port for instantiated lidar object in Shooter class
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
CommitLineData
a0c3ca74
KZ
1package org.usfirst.frc.team3501.robot.subsystems;
2
3import org.usfirst.frc.team3501.robot.Constants;
06fda04b 4import org.usfirst.frc.team3501.robot.Lidar;
4b94da2f 5import org.usfirst.frc.team3501.robot.MathLib;
a0c3ca74
KZ
6
7import edu.wpi.first.wpilibj.CANTalon;
2c52cb6e 8import edu.wpi.first.wpilibj.CounterBase.EncodingType;
9b10474d 9import edu.wpi.first.wpilibj.DoubleSolenoid;
2c52cb6e 10import edu.wpi.first.wpilibj.Encoder;
a0c3ca74
KZ
11import edu.wpi.first.wpilibj.command.Subsystem;
12
27fac8ed 13/***
06fda04b
E
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.
27fac8ed
YA
18 *
19 * @author superuser
20 *
21 */
22
a0c3ca74 23public class Shooter extends Subsystem {
a0c3ca74 24 private CANTalon shooter;
071ab315 25 private DoubleSolenoid hood, punch;
2c52cb6e 26 private Encoder encoder;
06fda04b 27 private Lidar lidar;
a0c3ca74
KZ
28
29 public Shooter() {
30 shooter = new CANTalon(Constants.Shooter.PORT);
071ab315
KZ
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);
2c52cb6e
K
35
36 encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
37 Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
06fda04b 38
77c791b9 39 lidar = new Lidar(Constants.Shooter.LIDAR_I2C_PORT);
a0c3ca74
KZ
40 }
41
64055177 42 /***
f08a2eef
YA
43 * This method checks to see if the ball has successfully passed through the
44 * intake rollers and is inside.
45 *
46 * @return whether the presence of the ball is true or false and returns the
47 * state of the condition (true or false).
48 */
49
50 public boolean isBallInside() {
51 return true;
52 }
53
a0c3ca74 54 public void setSpeed(double speed) {
4b94da2f
KZ
55 speed = MathLib.constrain(speed, -1, 1);
56 shooter.set(speed);
a0c3ca74
KZ
57 }
58
59 public void stop() {
60 this.setSpeed(0.0);
61 }
62
2c52cb6e
K
63 public double getSpeed() {
64 return encoder.getRate();
65 }
66
a0c3ca74 67 // Use negative # for decrement. Positive for increment.
27fac8ed 68
a0c3ca74 69 public void changeSpeed(double change) {
92d4c21a 70 double newSpeed = getSpeed() + change;
64055177 71 setSpeed(newSpeed);
a0c3ca74
KZ
72 }
73
9b10474d 74 // Punch Commands
4b94da2f 75 public void punch() {
9b10474d
GK
76 punch.set(Constants.Shooter.punch);
77 }
78
c8c4e6d9 79 public void retractPunch() {
9b10474d
GK
80 punch.set(Constants.Shooter.retract);
81 }
82
071ab315
KZ
83 public boolean isHoodOpen() {
84 return hood.get() == Constants.Shooter.open;
85 }
86
87 public void openHood() {
88 hood.set(Constants.Shooter.open);
89 }
90
91 public void closeHood() {
92 hood.set(Constants.Shooter.closed);
93 }
94
a0c3ca74
KZ
95 @Override
96 protected void initDefaultCommand() {
97 }
98}