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