1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Defense
;
4 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DriveTrain
;
5 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
7 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
8 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
9 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
10 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
12 public class Robot
extends IterativeRobot
{
14 public static DriveTrain driveTrain
;
15 public static Shooter shooter
;
17 // Sendable Choosers send a drop down menu to the Smart Dashboard.
18 SendableChooser positionChooser
;
19 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
20 positionFourDefense
, positionFiveDefense
;
23 public void robotInit() {
24 driveTrain
= new DriveTrain();
26 shooter
= new Shooter();
28 // Sendable Choosers allows the driver to select the position of the robot
29 // and the positions of the defenses from a drop-down menu on the Smart
31 // make the Sendable Choosers
32 initializeSendableChoosers();
33 addPositionChooserOptions();
34 addDefensesToAllDefenseSendableChooosers();
35 sendSendableChoosersToSmartDashboard();
39 private void initializeSendableChoosers() {
40 positionChooser
= new SendableChooser();
41 positionOneDefense
= new SendableChooser();
42 positionTwoDefense
= new SendableChooser();
43 positionThreeDefense
= new SendableChooser();
44 positionFourDefense
= new SendableChooser();
45 positionFiveDefense
= new SendableChooser();
48 private void addPositionChooserOptions() {
49 positionChooser
.addDefault("Position 1", 1);
50 positionChooser
.addObject("Position 2", 2);
51 positionChooser
.addObject("Position 3", 3);
52 positionChooser
.addObject("Position 4", 4);
53 positionChooser
.addObject("Position 5", 5);
56 private void addDefensesToAllDefenseSendableChooosers() {
57 addDefenseOptions(positionOneDefense
);
58 addDefenseOptions(positionTwoDefense
);
59 addDefenseOptions(positionThreeDefense
);
60 addDefenseOptions(positionFourDefense
);
61 addDefenseOptions(positionFiveDefense
);
64 private void addDefenseOptions(SendableChooser chooser
) {
65 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
66 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
67 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
68 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
69 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
70 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
71 chooser
.addObject("Moat", Defense
.MOAT
);
72 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
75 private void sendSendableChoosersToSmartDashboard() {
76 SmartDashboard
.putData("PositionChooser", positionChooser
);
77 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
78 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
79 SmartDashboard
.putData("Position Three Defense Chooser",
80 positionThreeDefense
);
81 SmartDashboard
.putData("Position Four Defense Chooser",
83 SmartDashboard
.putData("Position Five Defense Chooser",
88 public void autonomousInit() {
89 Scheduler
.getInstance().run();
91 // get options chosen from drop down menu
92 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
93 Integer chosenDefense
= 0;
95 switch (chosenPosition
) {
97 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
99 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
101 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
103 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
105 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
108 System
.out
.println("Chosen Position: " + chosenPosition
);
109 System
.out
.println("Chosen Defense: " + chosenDefense
);
113 public void autonomousPeriodic() {
114 Scheduler
.getInstance().run();
118 public void teleopInit() {
122 public void teleopPeriodic() {
123 Scheduler
.getInstance().run();