89f5f0fbc3be384baa34e981a958f8229c0679e9
[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.DriveTrain;
4 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
5
6 import edu.wpi.first.wpilibj.IterativeRobot;
7 import edu.wpi.first.wpilibj.command.Scheduler;
8 import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
9 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
10
11 public class Robot extends IterativeRobot {
12 public static OI oi;
13 public static DriveTrain driveTrain;
14 public static Shooter shooter;
15
16 enum Defense {
17 PORTCULLIS, SALLY_PORT, ROUGH_TERRAIN, LOW_BAR, CHEVAL_DE_FRISE, DRAWBRIDGE, MOAT, ROCK_WALL
18 };
19
20 // Sendable Choosers send a drop down menu to the Smart Dashboard.
21 SendableChooser positionOneDefense;
22 SendableChooser positionTwoDefense;
23 SendableChooser positionThreeDefense;
24 SendableChooser positionFourDefense;
25 SendableChooser positionFiveDefense;
26 SendableChooser positionChooser;
27
28 @Override
29 public void robotInit() {
30 driveTrain = new DriveTrain();
31 oi = new OI();
32 shooter = new Shooter();
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
56 // send the Sendable Choosers to the Smart Dashboard
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
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);
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);
80 }
81
82 @Override
83 public void autonomousInit() {
84 Scheduler.getInstance().run();
85
86 // get options chosen from drop down menu
87 Integer chosenPosition = (Integer) positionChooser.getSelected();
88 Integer chosenDefense = 0;
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);
103 }
104
105 @Override
106 public void autonomousPeriodic() {
107 Scheduler.getInstance().run();
108 }
109
110 @Override
111 public void teleopInit() {
112 System.out.println("running teleopInit");
113 }
114
115 @Override
116 public void teleopPeriodic() {
117 Scheduler.getInstance().run();
118
119 }
120
121 public void operate() {
122
123 }
124
125 }