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