Fix a spelling error :(
[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.DriveTrain;
4 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
5
6 import edu.wpi.first.wpilibj.IterativeRobot;
7 import edu.wpi.first.wpilibj.command.Scheduler;
8 import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
9 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
10
11 public class Robot extends IterativeRobot {
12 public static OI oi;
13 public static DriveTrain driveTrain;
14 public static Shooter shooter;
15
16 enum Defense {
17 PORTCULLIS, SALLY_PORT, ROUGH_TERRAIN, LOW_BAR, CHEVAL_DE_FRISE, DRAWBRIDGE, MOAT, ROCK_WALL
18 };
19
20 // Sendable Choosers send a drop down menu to the Smart Dashboard.
21 SendableChooser positionOneDefense;
22 SendableChooser positionTwoDefense;
23 SendableChooser positionThreeDefense;
24 SendableChooser positionFourDefense;
25 SendableChooser positionFiveDefense;
26 SendableChooser positionChooser;
27
28 @Override
29 public void robotInit() {
30 driveTrain = new DriveTrain();
31 oi = new OI();
32 shooter = new Shooter();
33
34 // initialize all the Sendable Choosers
35 positionChooser = new SendableChooser();
36 positionOneDefense = new SendableChooser();
37 positionTwoDefense = new SendableChooser();
38 positionThreeDefense = new SendableChooser();
39 positionFourDefense = new SendableChooser();
40 positionFiveDefense = new SendableChooser();
41
42 // add options for positions to the positionChooser
43 positionChooser.addDefault("Position 1", 1);
44 positionChooser.addObject("Position 2", 2);
45 positionChooser.addObject("Position 3", 3);
46 positionChooser.addObject("Position 4", 4);
47 positionChooser.addObject("Position 5", 5);
48
49 // add options for defenses into each defense chooser (5)
50 addDefense(positionOneDefense);
51 addDefense(positionTwoDefense);
52 addDefense(positionThreeDefense);
53 addDefense(positionFourDefense);
54 addDefense(positionFiveDefense);
55
56 // send the Sendable Choosers to the Smart Dashboard
57 // Sendable Choosers allows the driver to select the position of the robot
58 // and the positions of the defenses from a drop-down menu on the Smart
59 // Dashboard
60 SmartDashboard.putData("PositionChooser", positionChooser);
61 SmartDashboard.putData("Position One Defense Chooser", positionOneDefense);
62 SmartDashboard.putData("Position Two Defense Chooser", positionTwoDefense);
63 SmartDashboard.putData("Position Three Defense Chooser",
64 positionThreeDefense);
65 SmartDashboard.putData("Position Four Defense Chooser",
66 positionFourDefense);
67 SmartDashboard.putData("Position Five Defense Chooser",
68 positionFiveDefense);
69 }
70
71 private void addDefense(SendableChooser chooser) {
72 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
73 chooser.addObject("Sally Port", Defense.SALLY_PORT);
74 chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN);
75 chooser.addObject("Low Bar", Defense.LOW_BAR);
76 chooser.addObject("Cheval De Frise", Defense.CHEVAL_DE_FRISE);
77 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
78 chooser.addObject("Moat", Defense.MOAT);
79 chooser.addObject("Rock Wall", Defense.ROCK_WALL);
80 }
81
82 @Override
83 public void autonomousInit() {
84 Scheduler.getInstance().run();
85
86 // get options chosen from drop down menu
87 Integer chosenPosition = (Integer) positionChooser.getSelected();
88 Integer chosenDefense = 0;
89
90 switch (chosenPosition) {
91 case 1:
92 chosenDefense = (Integer) positionOneDefense.getSelected();
93 case 2:
94 chosenDefense = (Integer) positionTwoDefense.getSelected();
95 case 3:
96 chosenDefense = (Integer) positionThreeDefense.getSelected();
97 case 4:
98 chosenDefense = (Integer) positionFourDefense.getSelected();
99 case 5:
100 chosenDefense = (Integer) positionFiveDefense.getSelected();
101 }
102
103 System.out.println("Chosen Position: " + chosenPosition);
104 System.out.println("Chosen Defense: " + chosenDefense);
105 }
106
107 @Override
108 public void autonomousPeriodic() {
109 Scheduler.getInstance().run();
110 }
111
112 @Override
113 public void teleopInit() {
114 }
115
116 @Override
117 public void teleopPeriodic() {
118 Scheduler.getInstance().run();
119
120 }
121 }