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