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
.Scaler
;
6 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
8 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
9 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
10 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
11 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
13 public class Robot
extends IterativeRobot
{
15 public static DriveTrain driveTrain
;
16 public static Shooter shooter
;
17 public static Scaler scaler
;
19 // Sendable Choosers send a drop down menu to the Smart Dashboard.
20 SendableChooser positionChooser
;
21 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
22 positionFourDefense
, positionFiveDefense
;
25 public void robotInit() {
26 driveTrain
= new DriveTrain();
28 shooter
= new Shooter();
29 scaler
= new Scaler();
31 // Sendable Choosers allows the driver to select the position of the robot
32 // and the positions of the defenses from a drop-down menu on the Smart
34 // make the Sendable Choosers
35 initializeSendableChoosers();
36 addPositionChooserOptions();
37 addDefensesToAllDefenseSendableChooosers();
38 sendSendableChoosersToSmartDashboard();
42 private void initializeSendableChoosers() {
43 positionChooser
= new SendableChooser();
44 positionOneDefense
= new SendableChooser();
45 positionTwoDefense
= new SendableChooser();
46 positionThreeDefense
= new SendableChooser();
47 positionFourDefense
= new SendableChooser();
48 positionFiveDefense
= new SendableChooser();
51 private void addPositionChooserOptions() {
52 positionChooser
.addDefault("Position 1", 1);
53 positionChooser
.addObject("Position 2", 2);
54 positionChooser
.addObject("Position 3", 3);
55 positionChooser
.addObject("Position 4", 4);
56 positionChooser
.addObject("Position 5", 5);
59 private void addDefensesToAllDefenseSendableChooosers() {
60 addDefenseOptions(positionOneDefense
);
61 addDefenseOptions(positionTwoDefense
);
62 addDefenseOptions(positionThreeDefense
);
63 addDefenseOptions(positionFourDefense
);
64 addDefenseOptions(positionFiveDefense
);
67 private void addDefenseOptions(SendableChooser chooser
) {
68 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
69 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
70 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
71 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
72 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
73 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
74 chooser
.addObject("Moat", Defense
.MOAT
);
75 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
78 private void sendSendableChoosersToSmartDashboard() {
79 SmartDashboard
.putData("PositionChooser", positionChooser
);
80 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
81 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
82 SmartDashboard
.putData("Position Three Defense Chooser",
83 positionThreeDefense
);
84 SmartDashboard
.putData("Position Four Defense Chooser",
86 SmartDashboard
.putData("Position Five Defense Chooser",
91 public void autonomousInit() {
92 Scheduler
.getInstance().run();
94 // get options chosen from drop down menu
95 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
96 Integer chosenDefense
= 0;
98 switch (chosenPosition
) {
100 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
102 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
104 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
106 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
108 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
111 System
.out
.println("Chosen Position: " + chosenPosition
);
112 System
.out
.println("Chosen Defense: " + chosenDefense
);
116 public void autonomousPeriodic() {
117 Scheduler
.getInstance().run();
121 public void teleopInit() {
125 public void teleopPeriodic() {
126 Scheduler
.getInstance().run();