Change shooter to function off of two pistons, remove punch, shooter motors, and...
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
1 package org.usfirst.frc.team3501.robot;
2
3 import org.usfirst.frc.team3501.robot.Constants.Defense;
4 import org.usfirst.frc.team3501.robot.commands.shooter.ResetCatapult;
5 import org.usfirst.frc.team3501.robot.subsystems.DefenseArm;
6 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
7 import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
8 import org.usfirst.frc.team3501.robot.subsystems.Scaler;
9 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
10
11 import edu.wpi.first.wpilibj.IterativeRobot;
12 import edu.wpi.first.wpilibj.command.Scheduler;
13 import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
14 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
15
16 public class Robot extends IterativeRobot {
17 public static OI oi;
18 public static DriveTrain driveTrain;
19 public static Shooter shooter;
20
21 public static Scaler scaler;
22
23 public static IntakeArm intakeArm;
24 public static DefenseArm defenseArm;
25
26 // Sendable Choosers send a drop down menu to the Smart Dashboard.
27 SendableChooser positionChooser;
28 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
29 positionFourDefense, positionFiveDefense;
30
31 @Override
32 public void robotInit() {
33 driveTrain = new DriveTrain();
34 oi = new OI();
35
36 shooter = new Shooter();
37 scaler = new Scaler();
38 intakeArm = new IntakeArm();
39
40 initializeSendableChoosers();
41 addPositionChooserOptions();
42 addDefensesToAllDefenseSendableChoosers();
43 sendSendableChoosersToSmartDashboard();
44
45 }
46
47 private void initializeSendableChoosers() {
48 positionChooser = new SendableChooser();
49 positionOneDefense = new SendableChooser();
50 positionTwoDefense = new SendableChooser();
51 positionThreeDefense = new SendableChooser();
52 positionFourDefense = new SendableChooser();
53 positionFiveDefense = new SendableChooser();
54 }
55
56 private void addPositionChooserOptions() {
57 positionChooser.addDefault("Position 1", 1);
58 positionChooser.addObject("Position 2", 2);
59 positionChooser.addObject("Position 3", 3);
60 positionChooser.addObject("Position 4", 4);
61 positionChooser.addObject("Position 5", 5);
62 }
63
64 private void addDefensesToAllDefenseSendableChoosers() {
65 addDefenseOptions(positionOneDefense);
66 addDefenseOptions(positionTwoDefense);
67 addDefenseOptions(positionThreeDefense);
68 addDefenseOptions(positionFourDefense);
69 addDefenseOptions(positionFiveDefense);
70 }
71
72 private void addDefenseOptions(SendableChooser chooser) {
73 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
74 chooser.addObject("Sally Port", Defense.SALLY_PORT);
75 chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN);
76 chooser.addObject("Low Bar", Defense.LOW_BAR);
77 chooser.addObject("Cheval De Frise", Defense.CHEVAL_DE_FRISE);
78 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
79 chooser.addObject("Moat", Defense.MOAT);
80 chooser.addObject("Rock Wall", Defense.ROCK_WALL);
81 }
82
83 private void sendSendableChoosersToSmartDashboard() {
84 SmartDashboard.putData("PositionChooser", positionChooser);
85 SmartDashboard.putData("Position One Defense Chooser", positionOneDefense);
86 SmartDashboard.putData("Position Two Defense Chooser", positionTwoDefense);
87 SmartDashboard.putData("Position Three Defense Chooser",
88 positionThreeDefense);
89 SmartDashboard
90 .putData("Position Four Defense Chooser", positionFourDefense);
91 SmartDashboard
92 .putData("Position Five Defense Chooser", positionFiveDefense);
93
94 SmartDashboard
95 .putData("Position Four Defense Chooser", positionFourDefense);
96 SmartDashboard
97 .putData("Position Five Defense Chooser", positionFiveDefense);
98
99 shooter = new Shooter();
100
101 }
102
103 @Override
104 public void autonomousInit() {
105 Scheduler.getInstance().run();
106
107 // get options chosen from drop down menu
108 Integer chosenPosition = (Integer) positionChooser.getSelected();
109 Integer chosenDefense = 0;
110
111 if (chosenPosition == 1)
112 chosenDefense = (Integer) positionOneDefense.getSelected();
113 else if (chosenPosition == 2)
114 chosenDefense = (Integer) positionTwoDefense.getSelected();
115 else if (chosenPosition == 3)
116 chosenDefense = (Integer) positionThreeDefense.getSelected();
117 else if (chosenPosition == 4)
118 chosenDefense = (Integer) positionFourDefense.getSelected();
119 else if (chosenPosition == 5)
120 chosenDefense = (Integer) positionFiveDefense.getSelected();
121
122 System.out.println("Chosen Position: " + chosenPosition);
123 System.out.println("Chosen Defense: " + chosenDefense);
124 }
125
126 @Override
127 public void autonomousPeriodic() {
128 Scheduler.getInstance().run();
129 }
130
131 @Override
132 public void teleopInit() {
133 Scheduler.getInstance().add(new ResetCatapult()); // Reset catapult at start
134 // of each match.
135 }
136
137 @Override
138 public void teleopPeriodic() {
139 Scheduler.getInstance().run();
140 }
141
142 }