Make methods to convert DegreesPerSecond to Degrees
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
53d61b3e 3import org.usfirst.frc.team3501.robot.Constants.Defense;
2947642e 4import org.usfirst.frc.team3501.robot.subsystems.DefenseArm;
047383c3 5import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
e47f0862 6import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
02cb494e 7import org.usfirst.frc.team3501.robot.subsystems.Scaler;
40348cab
E
8import org.usfirst.frc.team3501.robot.subsystems.Shooter;
9
38a404b3
KZ
10import edu.wpi.first.wpilibj.IterativeRobot;
11import edu.wpi.first.wpilibj.command.Scheduler;
3366a59a
ME
12import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
13import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
38a404b3
KZ
14
15public class Robot extends IterativeRobot {
16 public static OI oi;
17 public static DriveTrain driveTrain;
40348cab 18 public static Shooter shooter;
2c9f5abb 19
02cb494e 20 public static Scaler scaler;
a96fa926 21 public static IntakeArm intakeArm;
200caf63 22 public static DefenseArm defenseArm;
38a404b3 23
88e66b4e 24 // Sendable Choosers send a drop down menu to the Smart Dashboard.
3366a59a 25 SendableChooser positionChooser;
6947c8a4 26 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
e23bfd98 27 positionFourDefense, positionFiveDefense;
3366a59a 28
38a404b3
KZ
29 @Override
30 public void robotInit() {
31 driveTrain = new DriveTrain();
32 oi = new OI();
2ac0cc17 33
40348cab 34 shooter = new Shooter();
02cb494e 35 scaler = new Scaler();
a96fa926 36 intakeArm = new IntakeArm();
3366a59a 37
a96fa926
D
38 // Sendable Choosers allows the driver to select the position of the
39 // robot
88e66b4e
ME
40 // and the positions of the defenses from a drop-down menu on the Smart
41 // Dashboard
29d59f48
ME
42 // make the Sendable Choosers
43 initializeSendableChoosers();
44 addPositionChooserOptions();
45 addDefensesToAllDefenseSendableChooosers();
46 sendSendableChoosersToSmartDashboard();
47
3366a59a
ME
48 }
49
6947c8a4
ME
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
29d59f48
ME
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) {
3366a59a
ME
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);
38a404b3
KZ
84 }
85
29d59f48
ME
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);
e23bfd98
E
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();
29d59f48
ME
102 }
103
38a404b3
KZ
104 @Override
105 public void autonomousInit() {
3366a59a
ME
106 Scheduler.getInstance().run();
107
108 // get options chosen from drop down menu
109 Integer chosenPosition = (Integer) positionChooser.getSelected();
e13d2293 110 Integer chosenDefense = 0;
3366a59a 111
33981335
ME
112 switch (chosenPosition) {
113 case 1:
3366a59a 114 chosenDefense = (Integer) positionOneDefense.getSelected();
33981335 115 case 2:
3366a59a 116 chosenDefense = (Integer) positionTwoDefense.getSelected();
33981335 117 case 3:
3366a59a 118 chosenDefense = (Integer) positionThreeDefense.getSelected();
33981335 119 case 4:
3366a59a 120 chosenDefense = (Integer) positionFourDefense.getSelected();
33981335 121 case 5:
3366a59a 122 chosenDefense = (Integer) positionFiveDefense.getSelected();
33981335 123 }
3366a59a
ME
124
125 System.out.println("Chosen Position: " + chosenPosition);
126 System.out.println("Chosen Defense: " + chosenDefense);
38a404b3
KZ
127 }
128
129 @Override
130 public void autonomousPeriodic() {
131 Scheduler.getInstance().run();
38a404b3
KZ
132 }
133
134 @Override
135 public void teleopInit() {
9a4d37df 136 Robot.driveTrain.initializeGyro();
38a404b3
KZ
137 }
138
139 @Override
140 public void teleopPeriodic() {
141 Scheduler.getInstance().run();
38a404b3
KZ
142 }
143}