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