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