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