put defense Sendable Choosers on one line
[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;
c4764b9d 19 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense, positionFourDefense, positionFiveDefense;
3366a59a 20
38a404b3
KZ
21 @Override
22 public void robotInit() {
23 driveTrain = new DriveTrain();
24 oi = new OI();
40348cab 25 shooter = new Shooter();
3366a59a 26
a0ff09b3 27 // initialize all the Sendable Choosers
3366a59a
ME
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
e13d2293 49 // send the Sendable Choosers to the Smart Dashboard
88e66b4e
ME
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
e13d2293
A
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);
3366a59a
ME
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);
38a404b3
KZ
73 }
74
75 @Override
76 public void autonomousInit() {
3366a59a
ME
77 Scheduler.getInstance().run();
78
79 // get options chosen from drop down menu
80 Integer chosenPosition = (Integer) positionChooser.getSelected();
e13d2293 81 Integer chosenDefense = 0;
3366a59a 82
33981335
ME
83 switch (chosenPosition) {
84 case 1:
3366a59a 85 chosenDefense = (Integer) positionOneDefense.getSelected();
33981335 86 case 2:
3366a59a 87 chosenDefense = (Integer) positionTwoDefense.getSelected();
33981335 88 case 3:
3366a59a 89 chosenDefense = (Integer) positionThreeDefense.getSelected();
33981335 90 case 4:
3366a59a 91 chosenDefense = (Integer) positionFourDefense.getSelected();
33981335 92 case 5:
3366a59a 93 chosenDefense = (Integer) positionFiveDefense.getSelected();
33981335 94 }
3366a59a
ME
95
96 System.out.println("Chosen Position: " + chosenPosition);
97 System.out.println("Chosen Defense: " + chosenDefense);
38a404b3
KZ
98 }
99
100 @Override
101 public void autonomousPeriodic() {
102 Scheduler.getInstance().run();
38a404b3
KZ
103 }
104
105 @Override
106 public void teleopInit() {
107 }
108
109 @Override
110 public void teleopPeriodic() {
111 Scheduler.getInstance().run();
112
113 }
114}