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