rename print line statement to say Degrees: and rename AnotherGyroClass to GyroLib...
[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;
cbd64f34 4import org.usfirst.frc.team3501.robot.GyroLib.Rotation;
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
2680d6fc 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 {
18 public static OI oi;
19 public static DriveTrain driveTrain;
40348cab 20 public static Shooter shooter;
fbab1d06 21
02cb494e 22 public static Scaler scaler;
bd5a85e3 23 double then;
5997d0fa 24
f81370d3 25 public static IntakeArm intakeArm;
bd5a85e3 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,
bd5a85e3 31 positionFourDefense, positionFiveDefense;
2680d6fc
E
32
33 // Gyro stuff
2680d6fc 34 short rawValue;
cbd64f34 35 public GyroLib gyro;
2680d6fc 36
bd5a85e3 37 double now;
213e82b1 38 double degreesIncreased;
2680d6fc 39 double degrees;
3366a59a 40
bd5a85e3
E
41 Rotation rotation;
42
38a404b3
KZ
43 @Override
44 public void robotInit() {
2680d6fc 45 // driveTrain = new DriveTrain();
cbd64f34 46 gyro = new GyroLib(I2C.Port.kOnboard, false);
2680d6fc 47 // oi = new OI();
5d5bc4ed 48
40348cab 49 shooter = new Shooter();
02cb494e 50 scaler = new Scaler();
8a0a9571 51 defenseArm = new DefenseArm();
2680d6fc 52 intakeArm = new IntakeArm();
3366a59a 53
bd5a85e3
E
54 // Sendable Choosers allows the driver to select the position of the
55 // robot
88e66b4e
ME
56 // and the positions of the defenses from a drop-down menu on the Smart
57 // Dashboard
29d59f48 58 // make the Sendable Choosers
213e82b1
E
59 // initializeSendableChoosers();
60 // addPositionChooserOptions();
61 // addDefensesToAllDefenseSendableChooosers();
62 // sendSendableChoosersToSmartDashboard();
29d59f48 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
83 private void addDefensesToAllDefenseSendableChooosers() {
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);
108 SmartDashboard.putData("Position Four Defense Chooser",
109 positionFourDefense);
110 SmartDashboard.putData("Position Five Defense Chooser",
111 positionFiveDefense);
213e82b1 112
6740fa40
E
113 SmartDashboard.putData("Position Four Defense Chooser",
114 positionFourDefense);
115 SmartDashboard.putData("Position Five Defense Chooser",
116 positionFiveDefense);
117
118 shooter = new Shooter();
213e82b1 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() {
cbd64f34
E
154
155 gyro.start();
156
38a404b3
KZ
157 }
158
159 @Override
160 public void teleopPeriodic() {
161 Scheduler.getInstance().run();
bd5a85e3 162
cbd64f34
E
163 System.out.println("Degrees: " + gyro.getRotationZ().getAngle());
164
bd5a85e3
E
165 }
166
38a404b3 167}