Change shooter to function off of two pistons, remove punch, shooter motors, and...
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
53d61b3e 3import org.usfirst.frc.team3501.robot.Constants.Defense;
e4fbab02 4import org.usfirst.frc.team3501.robot.commands.shooter.ResetCatapult;
2947642e 5import org.usfirst.frc.team3501.robot.subsystems.DefenseArm;
047383c3 6import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
e47f0862 7import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
02cb494e 8import org.usfirst.frc.team3501.robot.subsystems.Scaler;
40348cab
E
9import org.usfirst.frc.team3501.robot.subsystems.Shooter;
10
38a404b3
KZ
11import edu.wpi.first.wpilibj.IterativeRobot;
12import edu.wpi.first.wpilibj.command.Scheduler;
3366a59a
ME
13import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
14import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
38a404b3
KZ
15
16public class Robot extends IterativeRobot {
17 public static OI oi;
18 public static DriveTrain driveTrain;
40348cab 19 public static Shooter shooter;
2c9f5abb 20
02cb494e 21 public static Scaler scaler;
c97fbce2 22
a96fa926 23 public static IntakeArm intakeArm;
200caf63 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,
53f43a72 29 positionFourDefense, positionFiveDefense;
3366a59a 30
38a404b3
KZ
31 @Override
32 public void robotInit() {
9742fe2e
KZ
33 driveTrain = new DriveTrain();
34 oi = new OI();
2ac0cc17 35
40348cab 36 shooter = new Shooter();
02cb494e 37 scaler = new Scaler();
a96fa926 38 intakeArm = new IntakeArm();
3366a59a 39
9742fe2e
KZ
40 initializeSendableChoosers();
41 addPositionChooserOptions();
42 addDefensesToAllDefenseSendableChoosers();
43 sendSendableChoosersToSmartDashboard();
44
3366a59a
ME
45 }
46
6947c8a4
ME
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
29d59f48
ME
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
9742fe2e 64 private void addDefensesToAllDefenseSendableChoosers() {
29d59f48
ME
65 addDefenseOptions(positionOneDefense);
66 addDefenseOptions(positionTwoDefense);
67 addDefenseOptions(positionThreeDefense);
68 addDefenseOptions(positionFourDefense);
69 addDefenseOptions(positionFiveDefense);
70 }
71
72 private void addDefenseOptions(SendableChooser chooser) {
3366a59a
ME
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);
38a404b3
KZ
81 }
82
29d59f48
ME
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);
e4fbab02
HD
89 SmartDashboard
90 .putData("Position Four Defense Chooser", positionFourDefense);
91 SmartDashboard
92 .putData("Position Five Defense Chooser", positionFiveDefense);
d06ee698 93
e4fbab02
HD
94 SmartDashboard
95 .putData("Position Four Defense Chooser", positionFourDefense);
96 SmartDashboard
97 .putData("Position Five Defense Chooser", positionFiveDefense);
e23bfd98
E
98
99 shooter = new Shooter();
d06ee698 100
29d59f48
ME
101 }
102
38a404b3
KZ
103 @Override
104 public void autonomousInit() {
3366a59a
ME
105 Scheduler.getInstance().run();
106
107 // get options chosen from drop down menu
108 Integer chosenPosition = (Integer) positionChooser.getSelected();
e13d2293 109 Integer chosenDefense = 0;
3366a59a 110
ee177a4a 111 if (chosenPosition == 1)
3366a59a 112 chosenDefense = (Integer) positionOneDefense.getSelected();
ee177a4a 113 else if (chosenPosition == 2)
3366a59a 114 chosenDefense = (Integer) positionTwoDefense.getSelected();
ee177a4a 115 else if (chosenPosition == 3)
3366a59a 116 chosenDefense = (Integer) positionThreeDefense.getSelected();
ee177a4a 117 else if (chosenPosition == 4)
3366a59a 118 chosenDefense = (Integer) positionFourDefense.getSelected();
ee177a4a 119 else if (chosenPosition == 5)
3366a59a
ME
120 chosenDefense = (Integer) positionFiveDefense.getSelected();
121
122 System.out.println("Chosen Position: " + chosenPosition);
123 System.out.println("Chosen Defense: " + chosenDefense);
38a404b3
KZ
124 }
125
126 @Override
127 public void autonomousPeriodic() {
128 Scheduler.getInstance().run();
38a404b3
KZ
129 }
130
131 @Override
132 public void teleopInit() {
e4fbab02
HD
133 Scheduler.getInstance().add(new ResetCatapult()); // Reset catapult at start
134 // of each match.
38a404b3
KZ
135 }
136
137 @Override
138 public void teleopPeriodic() {
139 Scheduler.getInstance().run();
1e039ebd
E
140 }
141
38a404b3 142}