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