1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Defense
;
4 import org
.usfirst
.frc
.team3501
.robot
.commands
.auton
.ChooseStrategy
;
5 import org
.usfirst
.frc
.team3501
.robot
.commands
.driving
.SetHighGear
;
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
.Shooter
;
10 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
11 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
12 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
13 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
15 public class Robot
extends IterativeRobot
{
17 public static DriveTrain driveTrain
;
18 public static Shooter shooter
;
19 public static IntakeArm intakeArm
;
21 // Sendable Choosers send a drop down menu to the Smart Dashboard.
22 SendableChooser positionChooser
;
23 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
24 positionFourDefense
, positionFiveDefense
;
27 public void robotInit() {
28 driveTrain
= new DriveTrain();
29 shooter
= new Shooter();
30 intakeArm
= new IntakeArm();
34 initializeSendableChoosers();
35 addPositionChooserOptions();
36 addDefensesToAllDefenseSendableChoosers();
37 sendSendableChoosersToSmartDashboard();
40 private void initializeSendableChoosers() {
41 positionChooser
= new SendableChooser();
42 positionOneDefense
= new SendableChooser();
43 positionTwoDefense
= new SendableChooser();
44 positionThreeDefense
= new SendableChooser();
45 positionFourDefense
= new SendableChooser();
46 positionFiveDefense
= new SendableChooser();
49 private void addPositionChooserOptions() {
50 positionChooser
.addDefault("Position 1", 1);
51 positionChooser
.addObject("Position 2", 2);
52 positionChooser
.addObject("Position 3", 3);
53 positionChooser
.addObject("Position 4", 4);
54 positionChooser
.addObject("Position 5", 5);
57 private void addDefensesToAllDefenseSendableChoosers() {
58 addDefenseOptions(positionOneDefense
);
59 addDefenseOptions(positionTwoDefense
);
60 addDefenseOptions(positionThreeDefense
);
61 addDefenseOptions(positionFourDefense
);
62 addDefenseOptions(positionFiveDefense
);
65 private void addDefenseOptions(SendableChooser chooser
) {
66 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
67 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
68 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
69 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
70 chooser
.addObject("Chival De Frise", Defense
.CHIVAL_DE_FRISE
);
71 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
72 chooser
.addObject("Moat", Defense
.MOAT
);
73 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
76 private void sendSendableChoosersToSmartDashboard() {
77 SmartDashboard
.putData("PositionChooser", positionChooser
);
78 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
79 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
80 SmartDashboard
.putData("Position Three Defense Chooser",
81 positionThreeDefense
);
83 .putData("Position Four Defense Chooser", positionFourDefense
);
85 .putData("Position Five Defense Chooser", positionFiveDefense
);
88 .putData("Position Four Defense Chooser", positionFourDefense
);
90 .putData("Position Five Defense Chooser", positionFiveDefense
);
95 public void autonomousInit() {
96 // get options chosen from drop down menu
97 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
98 Defense chosenDefense
= null;
100 if (chosenPosition
== 1)
101 chosenDefense
= (Defense
) positionOneDefense
.getSelected();
102 else if (chosenPosition
== 2)
103 chosenDefense
= (Defense
) positionTwoDefense
.getSelected();
104 else if (chosenPosition
== 3)
105 chosenDefense
= (Defense
) positionThreeDefense
.getSelected();
106 else if (chosenPosition
== 4)
107 chosenDefense
= (Defense
) positionFourDefense
.getSelected();
108 else if (chosenPosition
== 5)
109 chosenDefense
= (Defense
) positionFiveDefense
.getSelected();
111 Scheduler
.getInstance().add(
112 new ChooseStrategy(chosenPosition
, chosenDefense
));
116 public void autonomousPeriodic() {
117 Scheduler
.getInstance().run();
121 public void teleopInit() {
122 Scheduler
.getInstance().add(new SetHighGear());
126 public void teleopPeriodic() {
127 Scheduler
.getInstance().run();