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