prepare to bring photogate
[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.Auton;
4 import org.usfirst.frc.team3501.robot.Constants.Defense;
5 import org.usfirst.frc.team3501.robot.commands.auton.ChooseStrategy;
6 import org.usfirst.frc.team3501.robot.commands.driving.SetLowGear;
7 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
8 import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
9 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
10
11 import edu.wpi.first.wpilibj.IterativeRobot;
12 import edu.wpi.first.wpilibj.command.Scheduler;
13 import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
14 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
15
16 public class Robot extends IterativeRobot {
17 public static OI oi;
18 public static DriveTrain driveTrain;
19 public static Shooter shooter;
20 public static IntakeArm intakeArm;
21 // public static Photogate photogate;
22
23 // Sendable Choosers send a drop down menu to the Smart Dashboard.
24 SendableChooser positionChooser;
25 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
26 positionFourDefense, positionFiveDefense;
27
28 @Override
29 public void robotInit() {
30 driveTrain = new DriveTrain();
31 shooter = new Shooter();
32 intakeArm = new IntakeArm();
33
34 oi = new OI();
35 // photogate = new Photogate();
36
37 initializeSendableChoosers();
38 addPositionChooserOptions();
39 addDefensesToAllDefenseSendableChoosers();
40 sendSendableChoosersToSmartDashboard();
41 }
42
43 private void initializeSendableChoosers() {
44 positionChooser = new SendableChooser();
45 positionOneDefense = new SendableChooser();
46 positionTwoDefense = new SendableChooser();
47 positionThreeDefense = new SendableChooser();
48 positionFourDefense = new SendableChooser();
49 positionFiveDefense = new SendableChooser();
50 }
51
52 private void addPositionChooserOptions() {
53 positionChooser.addDefault("None", 0);
54 positionChooser.addObject("Position 1", 1);
55 positionChooser.addObject("Position 2", 2);
56 positionChooser.addObject("Position 3", 3);
57 positionChooser.addObject("Position 4", 4);
58 positionChooser.addObject("Position 5", 5);
59 }
60
61 private void addDefensesToAllDefenseSendableChoosers() {
62 addDefenseOptions(positionOneDefense);
63 addDefenseOptions(positionTwoDefense);
64 addDefenseOptions(positionThreeDefense);
65 addDefenseOptions(positionFourDefense);
66 addDefenseOptions(positionFiveDefense);
67 }
68
69 private void addDefenseOptions(SendableChooser chooser) {
70 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
71 chooser.addObject("Sally Port", Defense.SALLY_PORT);
72 chooser.addObject("Rough Terrain" + Auton.ROUGH_TERRAIN_SPEED + " "
73 + Auton.ROUGH_TERRAIN_TIME, Defense.ROUGH_TERRAIN);
74 chooser.addObject("Low Bar" + " Will probably work...", Defense.LOW_BAR);
75 chooser.addObject("Chival De Frise", Defense.CHIVAL_DE_FRISE);
76 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
77 chooser.addObject("Moat" + Auton.MOAT_SPEED + " " + Auton.MOAT_TIME,
78 Defense.MOAT);
79 chooser.addObject("Rock Wall" + Auton.ROCK_WALL_SPEED + " "
80 + Auton.ROCK_WALL_TIME, Defense.ROCK_WALL);
81 }
82
83 private void sendSendableChoosersToSmartDashboard() {
84 SmartDashboard.putData("PositionChooser", positionChooser);
85 SmartDashboard.putData("Position 1 Defense Chooser", positionOneDefense);
86 SmartDashboard.putData("Position 2 Defense Chooser", positionTwoDefense);
87 SmartDashboard.putData("Position 3 Defense Chooser", positionThreeDefense);
88 SmartDashboard.putData("Position 4 Defense Chooser", positionFourDefense);
89 SmartDashboard.putData("Position 5 Defense Chooser", positionFiveDefense);
90
91 }
92
93 @Override
94 public void autonomousInit() {
95 // get options chosen from drop down menu
96 Integer chosenPosition = (Integer) positionChooser.getSelected();
97 Defense chosenDefense = null;
98
99 if (chosenPosition == 1)
100 chosenDefense = (Defense) positionOneDefense.getSelected();
101 else if (chosenPosition == 2)
102 chosenDefense = (Defense) positionTwoDefense.getSelected();
103 else if (chosenPosition == 3)
104 chosenDefense = (Defense) positionThreeDefense.getSelected();
105 else if (chosenPosition == 4)
106 chosenDefense = (Defense) positionFourDefense.getSelected();
107 else if (chosenPosition == 5)
108 chosenDefense = (Defense) positionFiveDefense.getSelected();
109
110 if (chosenPosition != 0)
111 Scheduler.getInstance().add(
112 new ChooseStrategy(chosenPosition, chosenDefense));
113
114 // Scheduler.getInstance().add(new TimeDrive(.6, 4));
115 }
116
117 @Override
118 public void autonomousPeriodic() {
119 Scheduler.getInstance().run();
120 }
121
122 @Override
123 public void teleopInit() {
124 Scheduler.getInstance().add(new SetLowGear());
125 }
126
127 @Override
128 public void teleopPeriodic() {
129 Scheduler.getInstance().run();
130 }
131
132 }