add code that sends data to SmartDashboard
[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 SendableChooser positionOneDefense;
21 SendableChooser positionTwoDefense;
22 SendableChooser positionThreeDefense;
23 SendableChooser positionFourDefense;
24 SendableChooser positionFiveDefense;
25 SendableChooser positionChooser;
26
27 @Override
28 public void robotInit() {
29 driveTrain = new DriveTrain();
30 oi = new OI();
31 shooter = new Shooter();
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 // send the Sendable Choosers to the Smart Dashboard
56 SmartDashboard.putData("PositionChooser", positionChooser);
57 SmartDashboard.putData("Position One Defense Chooser", positionOneDefense);
58 SmartDashboard.putData("Position Two Defense Chooser", positionTwoDefense);
59 SmartDashboard.putData("Position Three Defense Chooser",
60 positionThreeDefense);
61 SmartDashboard.putData("Position Four Defense Chooser",
62 positionFourDefense);
63 SmartDashboard.putData("Position Five Defense Chooser",
64 positionFiveDefense);
65 }
66
67 private void addDefense(SendableChooser chooser) {
68 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
69 chooser.addObject("Sally Port", Defense.SALLY_PORT);
70 chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN);
71 chooser.addObject("Low Bar", Defense.LOW_BAR);
72 chooser.addObject("Cheval De Frise", Defense.CHEVAL_DE_FRISE);
73 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
74 chooser.addObject("Moat", Defense.MOAT);
75 chooser.addObject("Rock Wall", Defense.ROCK_WALL);
76 }
77
78 @Override
79 public void autonomousInit() {
80 Scheduler.getInstance().run();
81
82 // get options chosen from drop down menu
83 Integer chosenPosition = (Integer) positionChooser.getSelected();
84 Integer chosenDefense = 0;
85
86 if (chosenPosition == 1)
87 chosenDefense = (Integer) positionOneDefense.getSelected();
88 if (chosenPosition == 2)
89 chosenDefense = (Integer) positionTwoDefense.getSelected();
90 if (chosenPosition == 3)
91 chosenDefense = (Integer) positionThreeDefense.getSelected();
92 if (chosenPosition == 4)
93 chosenDefense = (Integer) positionFourDefense.getSelected();
94 if (chosenPosition == 5)
95 chosenDefense = (Integer) positionFiveDefense.getSelected();
96
97 System.out.println("Chosen Position: " + chosenPosition);
98 System.out.println("Chosen Defense: " + chosenDefense);
99 }
100
101 @Override
102 public void autonomousPeriodic() {
103 Scheduler.getInstance().run();
104 }
105
106 @Override
107 public void teleopInit() {
108 System.out.println("running teleopInit");
109 }
110
111 @Override
112 public void teleopPeriodic() {
113 Scheduler.getInstance().run();
114
115 }
116
117 public void operate() {
118
119 }
120
121 }