get rid of lidar variables and code that conflicted with lidar variables already...
[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;
d8c01920
E
4import org.usfirst.frc.team3501.robot.Lidar;
5import org.usfirst.frc.team3501.robot.MathLib;
a0c3ca74 6
0b403e60 7import edu.wpi.first.wpilibj.AnalogPotentiometer;
a0c3ca74 8import edu.wpi.first.wpilibj.CANTalon;
2c52cb6e 9import edu.wpi.first.wpilibj.CounterBase.EncodingType;
9b10474d 10import edu.wpi.first.wpilibj.DoubleSolenoid;
2c52cb6e 11import edu.wpi.first.wpilibj.Encoder;
a0c3ca74
KZ
12import edu.wpi.first.wpilibj.command.Subsystem;
13
27fac8ed 14/***
3b2038bb
ME
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.
27fac8ed
YA
19 *
20 * @author superuser
21 *
22 */
23
a0c3ca74 24public class Shooter extends Subsystem {
a0c3ca74 25 private CANTalon shooter;
0b403e60 26 private CANTalon angleAdjuster;
071ab315 27 private DoubleSolenoid hood, punch;
2c52cb6e 28 private Encoder encoder;
06fda04b 29 private Lidar lidar;
a0c3ca74
KZ
30
31 public Shooter() {
3b2038bb
ME
32 leftLidar = new AnalogPotentiometer(0);
33 rightLidar = new AnalogPotentiometer(0);
a0c3ca74 34 shooter = new CANTalon(Constants.Shooter.PORT);
3b2038bb
ME
35 angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT);
36 punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT,
37 Constants.Shooter.PUNCH_REVERSE_PORT);
2c52cb6e
K
38
39 encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
40 Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
a0c3ca74
KZ
41 }
42
64055177 43 /***
f08a2eef
YA
44 * This method checks to see if the ball has successfully passed through the
45 * intake rollers and is inside.
46 *
47 * @return whether the presence of the ball is true or false and returns the
48 * state of the condition (true or false).
49 */
50
51 public boolean isBallInside() {
52 return true;
53 }
54
a0c3ca74 55 public void setSpeed(double speed) {
0b403e60
ME
56 if (speed > 1.0)
57 shooter.set(1.0);
58 else if (speed < -1.0)
59 shooter.set(-1.0);
60 else
61 shooter.set(speed);
4b29730e
E
62 }
63
a0c3ca74
KZ
64 public void stop() {
65 this.setSpeed(0.0);
66 }
67
2c52cb6e
K
68 public double getSpeed() {
69 return encoder.getRate();
70 }
71
a0c3ca74 72 // Use negative # for decrement. Positive for increment.
27fac8ed 73
a0c3ca74 74 public void changeSpeed(double change) {
92d4c21a 75 double newSpeed = getSpeed() + change;
64055177 76 setSpeed(newSpeed);
a0c3ca74
KZ
77 }
78
9b10474d 79 // Punch Commands
0b403e60 80 public void extendPunch() {
9b10474d
GK
81 punch.set(Constants.Shooter.punch);
82 }
83
c8c4e6d9 84 public void retractPunch() {
9b10474d
GK
85 punch.set(Constants.Shooter.retract);
86 }
87
3b2038bb
ME
88 @Override
89 protected void initDefaultCommand() {
071ab315
KZ
90 }
91
3b2038bb
ME
92 public double getLeftDistanceToTower() {
93 // TODO: find the method that actually gets distance
94 return leftLidar.get();
071ab315
KZ
95 }
96
3b2038bb
ME
97 public double getRightDistanceToTower() {
98 return rightLidar.get();
a0c3ca74
KZ
99 }
100}