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