Commit | Line | Data |
---|---|---|
38a404b3 KZ |
1 | package org.usfirst.frc.team3501.robot; |
2 | ||
53d61b3e | 3 | import org.usfirst.frc.team3501.robot.Constants.Defense; |
571a0e2a | 4 | import org.usfirst.frc.team3501.robot.commands.driving.SetLowGear; |
e4fbab02 | 5 | import org.usfirst.frc.team3501.robot.commands.shooter.ResetCatapult; |
2947642e | 6 | import org.usfirst.frc.team3501.robot.subsystems.DefenseArm; |
047383c3 | 7 | import org.usfirst.frc.team3501.robot.subsystems.DriveTrain; |
e47f0862 | 8 | import org.usfirst.frc.team3501.robot.subsystems.IntakeArm; |
02cb494e | 9 | import org.usfirst.frc.team3501.robot.subsystems.Scaler; |
40348cab E |
10 | import org.usfirst.frc.team3501.robot.subsystems.Shooter; |
11 | ||
38a404b3 KZ |
12 | import edu.wpi.first.wpilibj.IterativeRobot; |
13 | import edu.wpi.first.wpilibj.command.Scheduler; | |
3366a59a ME |
14 | import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; |
15 | import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | |
38a404b3 KZ |
16 | |
17 | public class Robot extends IterativeRobot { | |
18 | public static OI oi; | |
19 | public static DriveTrain driveTrain; | |
40348cab | 20 | public static Shooter shooter; |
2c9f5abb | 21 | |
02cb494e | 22 | public static Scaler scaler; |
c97fbce2 | 23 | |
a96fa926 | 24 | public static IntakeArm intakeArm; |
200caf63 | 25 | public static DefenseArm defenseArm; |
38a404b3 | 26 | |
88e66b4e | 27 | // Sendable Choosers send a drop down menu to the Smart Dashboard. |
3366a59a | 28 | SendableChooser positionChooser; |
6947c8a4 | 29 | SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense, |
53f43a72 | 30 | positionFourDefense, positionFiveDefense; |
3366a59a | 31 | |
38a404b3 KZ |
32 | @Override |
33 | public void robotInit() { | |
9742fe2e KZ |
34 | driveTrain = new DriveTrain(); |
35 | oi = new OI(); | |
2ac0cc17 | 36 | |
40348cab | 37 | shooter = new Shooter(); |
02cb494e | 38 | scaler = new Scaler(); |
a96fa926 | 39 | intakeArm = new IntakeArm(); |
3366a59a | 40 | |
9742fe2e KZ |
41 | initializeSendableChoosers(); |
42 | addPositionChooserOptions(); | |
43 | addDefensesToAllDefenseSendableChoosers(); | |
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 | ||
9742fe2e | 65 | private void addDefensesToAllDefenseSendableChoosers() { |
29d59f48 ME |
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); | |
e4fbab02 HD |
90 | SmartDashboard |
91 | .putData("Position Four Defense Chooser", positionFourDefense); | |
92 | SmartDashboard | |
93 | .putData("Position Five Defense Chooser", positionFiveDefense); | |
d06ee698 | 94 | |
e4fbab02 HD |
95 | SmartDashboard |
96 | .putData("Position Four Defense Chooser", positionFourDefense); | |
97 | SmartDashboard | |
98 | .putData("Position Five Defense Chooser", positionFiveDefense); | |
e23bfd98 E |
99 | |
100 | shooter = new Shooter(); | |
d06ee698 | 101 | |
29d59f48 ME |
102 | } |
103 | ||
38a404b3 KZ |
104 | @Override |
105 | public void autonomousInit() { | |
3366a59a ME |
106 | Scheduler.getInstance().run(); |
107 | ||
108 | // get options chosen from drop down menu | |
109 | Integer chosenPosition = (Integer) positionChooser.getSelected(); | |
e13d2293 | 110 | Integer chosenDefense = 0; |
3366a59a | 111 | |
ee177a4a | 112 | if (chosenPosition == 1) |
3366a59a | 113 | chosenDefense = (Integer) positionOneDefense.getSelected(); |
ee177a4a | 114 | else if (chosenPosition == 2) |
3366a59a | 115 | chosenDefense = (Integer) positionTwoDefense.getSelected(); |
ee177a4a | 116 | else if (chosenPosition == 3) |
3366a59a | 117 | chosenDefense = (Integer) positionThreeDefense.getSelected(); |
ee177a4a | 118 | else if (chosenPosition == 4) |
3366a59a | 119 | chosenDefense = (Integer) positionFourDefense.getSelected(); |
ee177a4a | 120 | else if (chosenPosition == 5) |
3366a59a ME |
121 | chosenDefense = (Integer) positionFiveDefense.getSelected(); |
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() { | |
571a0e2a HD |
134 | Scheduler.getInstance().add(new SetLowGear()); // Start each match in low |
135 | // gear | |
e4fbab02 HD |
136 | Scheduler.getInstance().add(new ResetCatapult()); // Reset catapult at start |
137 | // of each match. | |
38a404b3 KZ |
138 | } |
139 | ||
140 | @Override | |
141 | public void teleopPeriodic() { | |
142 | Scheduler.getInstance().run(); | |
1e039ebd E |
143 | } |
144 | ||
38a404b3 | 145 | } |