Merge branch 'cindy/secondHood'
[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.sensors.Photogate;
5 import org.usfirst.frc.team3501.robot.subsystems.DefenseArm;
6 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
7 import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
8 import org.usfirst.frc.team3501.robot.subsystems.Scaler;
9 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
10
11 import edu.wpi.first.wpilibj.IterativeRobot;
12 import edu.wpi.first.wpilibj.command.Scheduler;
13 import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
14 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
15
16 public class Robot extends IterativeRobot {
17 public static OI oi;
18 public static DriveTrain driveTrain;
19 public static Shooter shooter;
20
21 public static Scaler scaler;
22
23 public static IntakeArm intakeArm;
24 public static DefenseArm defenseArm;
25
26 public static Photogate photogate;
27
28 // Sendable Choosers send a drop down menu to the Smart Dashboard.
29 SendableChooser positionChooser;
30 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
31 positionFourDefense, positionFiveDefense;
32
33 @Override
34 public void robotInit() {
35 driveTrain = new DriveTrain();
36 oi = new OI();
37
38 shooter = new Shooter();
39 scaler = new Scaler();
40 intakeArm = new IntakeArm();
41
42 initializeSendableChoosers();
43 addPositionChooserOptions();
44 addDefensesToAllDefenseSendableChoosers();
45 sendSendableChoosersToSmartDashboard();
46
47 }
48
49 private void initializeSendableChoosers() {
50 positionChooser = new SendableChooser();
51 positionOneDefense = new SendableChooser();
52 positionTwoDefense = new SendableChooser();
53 positionThreeDefense = new SendableChooser();
54 positionFourDefense = new SendableChooser();
55 positionFiveDefense = new SendableChooser();
56 }
57
58 private void addPositionChooserOptions() {
59 positionChooser.addDefault("Position 1", 1);
60 positionChooser.addObject("Position 2", 2);
61 positionChooser.addObject("Position 3", 3);
62 positionChooser.addObject("Position 4", 4);
63 positionChooser.addObject("Position 5", 5);
64 }
65
66 private void addDefensesToAllDefenseSendableChoosers() {
67 addDefenseOptions(positionOneDefense);
68 addDefenseOptions(positionTwoDefense);
69 addDefenseOptions(positionThreeDefense);
70 addDefenseOptions(positionFourDefense);
71 addDefenseOptions(positionFiveDefense);
72 }
73
74 private void addDefenseOptions(SendableChooser chooser) {
75 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
76 chooser.addObject("Sally Port", Defense.SALLY_PORT);
77 chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN);
78 chooser.addObject("Low Bar", Defense.LOW_BAR);
79 chooser.addObject("Cheval De Frise", Defense.CHEVAL_DE_FRISE);
80 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
81 chooser.addObject("Moat", Defense.MOAT);
82 chooser.addObject("Rock Wall", Defense.ROCK_WALL);
83 }
84
85 private void sendSendableChoosersToSmartDashboard() {
86 SmartDashboard.putData("PositionChooser", positionChooser);
87 SmartDashboard.putData("Position One Defense Chooser", positionOneDefense);
88 SmartDashboard.putData("Position Two Defense Chooser", positionTwoDefense);
89 SmartDashboard.putData("Position Three Defense Chooser",
90 positionThreeDefense);
91 SmartDashboard.putData("Position Four Defense Chooser",
92 positionFourDefense);
93 SmartDashboard.putData("Position Five Defense Chooser",
94 positionFiveDefense);
95
96 SmartDashboard.putData("Position Four Defense Chooser",
97 positionFourDefense);
98 SmartDashboard.putData("Position Five Defense Chooser",
99 positionFiveDefense);
100
101 shooter = new Shooter();
102
103 }
104
105 @Override
106 public void autonomousInit() {
107 Scheduler.getInstance().run();
108
109 // get options chosen from drop down menu
110 Integer chosenPosition = (Integer) positionChooser.getSelected();
111 Integer chosenDefense = 0;
112
113 if (chosenPosition == 1)
114 chosenDefense = (Integer) positionOneDefense.getSelected();
115 else if (chosenPosition == 2)
116 chosenDefense = (Integer) positionTwoDefense.getSelected();
117 else if (chosenPosition == 3)
118 chosenDefense = (Integer) positionThreeDefense.getSelected();
119 else if (chosenPosition == 4)
120 chosenDefense = (Integer) positionFourDefense.getSelected();
121 else if (chosenPosition == 5)
122 chosenDefense = (Integer) positionFiveDefense.getSelected();
123
124 System.out.println("Chosen Position: " + chosenPosition);
125 System.out.println("Chosen Defense: " + chosenDefense);
126 }
127
128 @Override
129 public void autonomousPeriodic() {
130 Scheduler.getInstance().run();
131 }
132
133 @Override
134 public void teleopInit() {
135 }
136
137 @Override
138 public void teleopPeriodic() {
139 Scheduler.getInstance().run();
140 }
141
142 }