add smart dashboard autonomous selection
[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
20 SendableChooser positionOneDefense;
21 SendableChooser positionTwoDefense;
22 SendableChooser positionThreeDefense;
23 SendableChooser positionFourDefense;
24 SendableChooser positionFiveDefense;
25 SendableChooser positionChooser;
26
38a404b3
KZ
27 @Override
28 public void robotInit() {
29 driveTrain = new DriveTrain();
30 oi = new OI();
40348cab 31 shooter = new Shooter();
3366a59a
ME
32
33 // intialize all the Sendable Choosers
34 positionChooser = new SendableChooser();
35 positionOneDefense = new SendableChooser();
36 positionTwoDefense = new SendableChooser();
37 positionThreeDefense = new SendableChooser();
38 positionFourDefense = new SendableChooser();
39 positionFiveDefense = new SendableChooser();
40
41 // add options for positions to the positionChooser
42 positionChooser.addDefault("Position 1", 1);
43 positionChooser.addObject("Position 2", 2);
44 positionChooser.addObject("Position 3", 3);
45 positionChooser.addObject("Position 4", 4);
46 positionChooser.addObject("Position 5", 5);
47
48 // add options for defenses into each defense chooser (5)
49 addDefense(positionOneDefense);
50 addDefense(positionTwoDefense);
51 addDefense(positionThreeDefense);
52 addDefense(positionFourDefense);
53 addDefense(positionFiveDefense);
54
55 SmartDashboard.putData("Position", positionChooser);
56 SmartDashboard.putData("Position One Defense", positionOneDefense);
57 SmartDashboard.putData("Position Two Defense", positionTwoDefense);
58 SmartDashboard.putData("Position Three Defense", positionThreeDefense);
59 SmartDashboard.putData("Position Four Defense", positionFourDefense);
60 SmartDashboard.putData("Position Five Defense", positionFiveDefense);
61
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();
81 Integer chosenDefense = -1;
82
83 if (chosenPosition == 1)
84 chosenDefense = (Integer) positionOneDefense.getSelected();
85 if (chosenPosition == 2)
86 chosenDefense = (Integer) positionTwoDefense.getSelected();
87 if (chosenPosition == 3)
88 chosenDefense = (Integer) positionThreeDefense.getSelected();
89 if (chosenPosition == 4)
90 chosenDefense = (Integer) positionFourDefense.getSelected();
91 if (chosenPosition == 5)
92 chosenDefense = (Integer) positionFiveDefense.getSelected();
93
94 System.out.println("Chosen Position: " + chosenPosition);
95 System.out.println("Chosen Defense: " + chosenDefense);
38a404b3
KZ
96 }
97
98 @Override
99 public void autonomousPeriodic() {
100 Scheduler.getInstance().run();
38a404b3
KZ
101 }
102
103 @Override
104 public void teleopInit() {
3366a59a 105 System.out.println("running teleopInit");
38a404b3
KZ
106 }
107
108 @Override
109 public void teleopPeriodic() {
110 Scheduler.getInstance().run();
111
112 }
3366a59a
ME
113
114 public void operate() {
115
116 }
117
38a404b3 118}