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