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