add comments explaining the Sendable Choosers
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
3import org.usfirst.frc.team3501.robot.Constants.DriveTrain;
40348cab
E
4import org.usfirst.frc.team3501.robot.subsystems.Shooter;
5
38a404b3
KZ
6import edu.wpi.first.wpilibj.IterativeRobot;
7import edu.wpi.first.wpilibj.command.Scheduler;
3366a59a
ME
8import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
9import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
38a404b3
KZ
10
11public class Robot extends IterativeRobot {
12 public static OI oi;
13 public static DriveTrain driveTrain;
40348cab 14 public static Shooter shooter;
38a404b3 15
3366a59a
ME
16 enum Defense {
17 PORTCULLIS, SALLY_PORT, ROUGH_TERRAIN, LOW_BAR, CHEVAL_DE_FRISE, DRAWBRIDGE, MOAT, ROCK_WALL
18 };
19
88e66b4e 20 // Sendable Choosers send a drop down menu to the Smart Dashboard.
3366a59a
ME
21 SendableChooser positionOneDefense;
22 SendableChooser positionTwoDefense;
23 SendableChooser positionThreeDefense;
24 SendableChooser positionFourDefense;
25 SendableChooser positionFiveDefense;
26 SendableChooser positionChooser;
27
38a404b3
KZ
28 @Override
29 public void robotInit() {
30 driveTrain = new DriveTrain();
31 oi = new OI();
40348cab 32 shooter = new Shooter();
3366a59a
ME
33
34 // intialize 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
e13d2293 56 // send the Sendable Choosers to the Smart Dashboard
88e66b4e
ME
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
e13d2293
A
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);
3366a59a
ME
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);
38a404b3
KZ
80 }
81
82 @Override
83 public void autonomousInit() {
3366a59a
ME
84 Scheduler.getInstance().run();
85
86 // get options chosen from drop down menu
87 Integer chosenPosition = (Integer) positionChooser.getSelected();
e13d2293 88 Integer chosenDefense = 0;
3366a59a
ME
89
90 if (chosenPosition == 1)
91 chosenDefense = (Integer) positionOneDefense.getSelected();
92 if (chosenPosition == 2)
93 chosenDefense = (Integer) positionTwoDefense.getSelected();
94 if (chosenPosition == 3)
95 chosenDefense = (Integer) positionThreeDefense.getSelected();
96 if (chosenPosition == 4)
97 chosenDefense = (Integer) positionFourDefense.getSelected();
98 if (chosenPosition == 5)
99 chosenDefense = (Integer) positionFiveDefense.getSelected();
100
101 System.out.println("Chosen Position: " + chosenPosition);
102 System.out.println("Chosen Defense: " + chosenDefense);
38a404b3
KZ
103 }
104
105 @Override
106 public void autonomousPeriodic() {
107 Scheduler.getInstance().run();
38a404b3
KZ
108 }
109
110 @Override
111 public void teleopInit() {
3366a59a 112 System.out.println("running teleopInit");
38a404b3
KZ
113 }
114
115 @Override
116 public void teleopPeriodic() {
117 Scheduler.getInstance().run();
118
119 }
3366a59a
ME
120
121 public void operate() {
122
123 }
124
38a404b3 125}