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