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