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