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