Use AnotherGyroClass's method of getAngle for getRotationZ, MAGICALLY WORKS
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
3cde7378 3import org.usfirst.frc.team3501.robot.AnotherGyroClass.Rotation;
53d61b3e 4import org.usfirst.frc.team3501.robot.Constants.Defense;
8a0a9571 5import org.usfirst.frc.team3501.robot.subsystems.DefenseArm;
047383c3 6import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
f81370d3 7import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
02cb494e 8import org.usfirst.frc.team3501.robot.subsystems.Scaler;
40348cab
E
9import org.usfirst.frc.team3501.robot.subsystems.Shooter;
10
4f0e0052 11import edu.wpi.first.wpilibj.I2C;
38a404b3
KZ
12import edu.wpi.first.wpilibj.IterativeRobot;
13import edu.wpi.first.wpilibj.command.Scheduler;
3366a59a
ME
14import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
15import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
38a404b3
KZ
16
17public class Robot extends IterativeRobot {
60a09454
KZ
18 public static OI oi;
19 public static DriveTrain driveTrain;
20 public static Shooter shooter;
dd5f8abe 21
60a09454 22 public static Scaler scaler;
3cde7378 23 double then;
4f0e0052 24
60a09454
KZ
25 public static IntakeArm intakeArm;
26 public static DefenseArm defenseArm;
38a404b3 27
88e66b4e 28 // Sendable Choosers send a drop down menu to the Smart Dashboard.
3366a59a 29 SendableChooser positionChooser;
6947c8a4 30 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
2faa7f35 31 positionFourDefense, positionFiveDefense;
2680d6fc 32
4f0e0052
E
33 // Gyro stuff
34 private final static double NANOSECONDS_PER_SECOND = 1000000000;
35 short rawValue;
b02fb554 36 public AnotherGyroClass gyro;
4f0e0052 37
3cde7378
E
38 double now;
39 double degreesIncreased;
4f0e0052
E
40 double degrees;
41
3cde7378
E
42 Rotation rotation;
43
38a404b3
KZ
44 @Override
45 public void robotInit() {
4f0e0052 46 // driveTrain = new DriveTrain();
b02fb554 47 gyro = new AnotherGyroClass(I2C.Port.kOnboard, false);
4f0e0052 48 // oi = new OI();
6f2bab66 49
40348cab 50 shooter = new Shooter();
02cb494e 51 scaler = new Scaler();
2680d6fc 52 intakeArm = new IntakeArm();
3366a59a 53
3cde7378
E
54 // Sendable Choosers allows the driver to select the position of the
55 // robot
2faa7f35
SG
56 // and the positions of the defenses from a drop-down menu on the Smart
57 // Dashboard
58 // make the Sendable Choosers
c8ec852e
KZ
59 initializeSendableChoosers();
60 addPositionChooserOptions();
2faa7f35 61 addDefensesToAllDefenseSendableChooosers();
c8ec852e
KZ
62 sendSendableChoosersToSmartDashboard();
63
3366a59a
ME
64 }
65
6947c8a4
ME
66 private void initializeSendableChoosers() {
67 positionChooser = new SendableChooser();
68 positionOneDefense = new SendableChooser();
69 positionTwoDefense = new SendableChooser();
70 positionThreeDefense = new SendableChooser();
71 positionFourDefense = new SendableChooser();
72 positionFiveDefense = new SendableChooser();
73 }
74
29d59f48
ME
75 private void addPositionChooserOptions() {
76 positionChooser.addDefault("Position 1", 1);
77 positionChooser.addObject("Position 2", 2);
78 positionChooser.addObject("Position 3", 3);
79 positionChooser.addObject("Position 4", 4);
80 positionChooser.addObject("Position 5", 5);
81 }
82
2faa7f35 83 private void addDefensesToAllDefenseSendableChooosers() {
29d59f48
ME
84 addDefenseOptions(positionOneDefense);
85 addDefenseOptions(positionTwoDefense);
86 addDefenseOptions(positionThreeDefense);
87 addDefenseOptions(positionFourDefense);
88 addDefenseOptions(positionFiveDefense);
89 }
90
91 private void addDefenseOptions(SendableChooser chooser) {
3366a59a
ME
92 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
93 chooser.addObject("Sally Port", Defense.SALLY_PORT);
94 chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN);
95 chooser.addObject("Low Bar", Defense.LOW_BAR);
96 chooser.addObject("Cheval De Frise", Defense.CHEVAL_DE_FRISE);
97 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
98 chooser.addObject("Moat", Defense.MOAT);
99 chooser.addObject("Rock Wall", Defense.ROCK_WALL);
38a404b3
KZ
100 }
101
29d59f48
ME
102 private void sendSendableChoosersToSmartDashboard() {
103 SmartDashboard.putData("PositionChooser", positionChooser);
104 SmartDashboard.putData("Position One Defense Chooser", positionOneDefense);
105 SmartDashboard.putData("Position Two Defense Chooser", positionTwoDefense);
106 SmartDashboard.putData("Position Three Defense Chooser",
107 positionThreeDefense);
f8f47b97
E
108 SmartDashboard.putData("Position Four Defense Chooser",
109 positionFourDefense);
110 SmartDashboard.putData("Position Five Defense Chooser",
111 positionFiveDefense);
3cde7378 112
f8f47b97
E
113 SmartDashboard.putData("Position Four Defense Chooser",
114 positionFourDefense);
115 SmartDashboard.putData("Position Five Defense Chooser",
116 positionFiveDefense);
117
118 shooter = new Shooter();
3cde7378 119
29d59f48
ME
120 }
121
38a404b3
KZ
122 @Override
123 public void autonomousInit() {
3366a59a
ME
124 Scheduler.getInstance().run();
125
126 // get options chosen from drop down menu
127 Integer chosenPosition = (Integer) positionChooser.getSelected();
e13d2293 128 Integer chosenDefense = 0;
3366a59a 129
33981335
ME
130 switch (chosenPosition) {
131 case 1:
3366a59a 132 chosenDefense = (Integer) positionOneDefense.getSelected();
33981335 133 case 2:
3366a59a 134 chosenDefense = (Integer) positionTwoDefense.getSelected();
33981335 135 case 3:
3366a59a 136 chosenDefense = (Integer) positionThreeDefense.getSelected();
33981335 137 case 4:
3366a59a 138 chosenDefense = (Integer) positionFourDefense.getSelected();
33981335 139 case 5:
3366a59a 140 chosenDefense = (Integer) positionFiveDefense.getSelected();
33981335 141 }
3366a59a
ME
142
143 System.out.println("Chosen Position: " + chosenPosition);
144 System.out.println("Chosen Defense: " + chosenDefense);
38a404b3
KZ
145 }
146
147 @Override
148 public void autonomousPeriodic() {
149 Scheduler.getInstance().run();
38a404b3
KZ
150 }
151
152 @Override
153 public void teleopInit() {
154 }
155
156 @Override
157 public void teleopPeriodic() {
158 Scheduler.getInstance().run();
bd5a85e3
E
159
160 }
3cde7378 161
38a404b3 162}