Remove useless variables and commented stuff in Robot.java
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
1 package org.usfirst.frc.team3501.robot;
2
3 import org.usfirst.frc.team3501.robot.AnotherGyroClass.Rotation;
4 import org.usfirst.frc.team3501.robot.Constants.Defense;
5 import org.usfirst.frc.team3501.robot.GyroLib.Rotation;
6 import org.usfirst.frc.team3501.robot.subsystems.DefenseArm;
7 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
8 import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
9 import org.usfirst.frc.team3501.robot.subsystems.Scaler;
10 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
11
12 import edu.wpi.first.wpilibj.I2C;
13 import edu.wpi.first.wpilibj.IterativeRobot;
14 import edu.wpi.first.wpilibj.command.Scheduler;
15 import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
16 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
17
18 public class Robot extends IterativeRobot {
19 public static OI oi;
20 public static DriveTrain driveTrain;
21 public static Shooter shooter;
22
23 public static Scaler scaler;
24 double then;
25
26 public static IntakeArm intakeArm;
27 public static DefenseArm defenseArm;
28
29 // Sendable Choosers send a drop down menu to the Smart Dashboard.
30 SendableChooser positionChooser;
31 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
32 positionFourDefense, positionFiveDefense;
33
34 // Gyro stuff
35 short rawValue;
36 public GyroLib gyro;
37
38 double now;
39 double degreesIncreased;
40 double degrees;
41
42 Rotation rotation;
43
44 @Override
45 public void robotInit() {
46 // driveTrain = new DriveTrain();
47 gyro = new GyroLib(I2C.Port.kOnboard, false);
48 // oi = new OI();
49
50 shooter = new Shooter();
51 scaler = new Scaler();
52 intakeArm = new IntakeArm();
53
54 // Sendable Choosers allows the driver to select the position of the
55 // robot
56 // and the positions of the defenses from a drop-down menu on the Smart
57 // Dashboard
58 // make the Sendable Choosers
59 // initializeSendableChoosers();
60 // addPositionChooserOptions();
61 // addDefensesToAllDefenseSendableChooosers();
62 // sendSendableChoosersToSmartDashboard();
63
64 }
65
66 private void initializeSendableChoosers() {
67 positionChooser = new SendableChooser();
68 positionOneDefense = new SendableChooser();
69 positionTwoDefense = new SendableChooser();
70 positionThreeDefense = new SendableChooser();
71 positionFourDefense = new SendableChooser();
72 positionFiveDefense = new SendableChooser();
73 }
74
75 private void addPositionChooserOptions() {
76 positionChooser.addDefault("Position 1", 1);
77 positionChooser.addObject("Position 2", 2);
78 positionChooser.addObject("Position 3", 3);
79 positionChooser.addObject("Position 4", 4);
80 positionChooser.addObject("Position 5", 5);
81 }
82
83 private void addDefensesToAllDefenseSendableChooosers() {
84 addDefenseOptions(positionOneDefense);
85 addDefenseOptions(positionTwoDefense);
86 addDefenseOptions(positionThreeDefense);
87 addDefenseOptions(positionFourDefense);
88 addDefenseOptions(positionFiveDefense);
89 }
90
91 private void addDefenseOptions(SendableChooser chooser) {
92 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
93 chooser.addObject("Sally Port", Defense.SALLY_PORT);
94 chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN);
95 chooser.addObject("Low Bar", Defense.LOW_BAR);
96 chooser.addObject("Cheval De Frise", Defense.CHEVAL_DE_FRISE);
97 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
98 chooser.addObject("Moat", Defense.MOAT);
99 chooser.addObject("Rock Wall", Defense.ROCK_WALL);
100 }
101
102 private void sendSendableChoosersToSmartDashboard() {
103 SmartDashboard.putData("PositionChooser", positionChooser);
104 SmartDashboard.putData("Position One Defense Chooser", positionOneDefense);
105 SmartDashboard.putData("Position Two Defense Chooser", positionTwoDefense);
106 SmartDashboard.putData("Position Three Defense Chooser",
107 positionThreeDefense);
108 SmartDashboard.putData("Position Four Defense Chooser",
109 positionFourDefense);
110 SmartDashboard.putData("Position Five Defense Chooser",
111 positionFiveDefense);
112
113 SmartDashboard.putData("Position Four Defense Chooser",
114 positionFourDefense);
115 SmartDashboard.putData("Position Five Defense Chooser",
116 positionFiveDefense);
117
118 shooter = new Shooter();
119
120 }
121
122 @Override
123 public void autonomousInit() {
124 Scheduler.getInstance().run();
125
126 // get options chosen from drop down menu
127 Integer chosenPosition = (Integer) positionChooser.getSelected();
128 Integer chosenDefense = 0;
129
130 switch (chosenPosition) {
131 case 1:
132 chosenDefense = (Integer) positionOneDefense.getSelected();
133 case 2:
134 chosenDefense = (Integer) positionTwoDefense.getSelected();
135 case 3:
136 chosenDefense = (Integer) positionThreeDefense.getSelected();
137 case 4:
138 chosenDefense = (Integer) positionFourDefense.getSelected();
139 case 5:
140 chosenDefense = (Integer) positionFiveDefense.getSelected();
141 }
142
143 System.out.println("Chosen Position: " + chosenPosition);
144 System.out.println("Chosen Defense: " + chosenDefense);
145 }
146
147 @Override
148 public void autonomousPeriodic() {
149 Scheduler.getInstance().run();
150 }
151
152 @Override
153 public void teleopInit() {
154
155 gyro.start();
156
157 }
158
159 @Override
160 public void teleopPeriodic() {
161 Scheduler.getInstance().run();
162
163 System.out.println("Degrees: " + gyro.getRotationZ().getAngle());
164
165 }
166
167 }