1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Defense
;
4 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DefenseArm
;
5 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DriveTrain
;
6 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.IntakeArm
;
7 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Scaler
;
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 Scaler scaler
;
20 public static IntakeArm intakeArm
;
21 public static DefenseArm defenseArm
;
23 // Sendable Choosers send a drop down menu to the Smart Dashboard.
24 SendableChooser positionChooser
;
25 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
26 positionFourDefense
, positionFiveDefense
;
29 public void robotInit() {
30 driveTrain
= new DriveTrain();
32 shooter
= new Shooter();
33 scaler
= new Scaler();
34 defenseArm
= new DefenseArm();
35 intakeArm
= new IntakeArm();
37 // Sendable Choosers allows the driver to select the position of the robot
38 // and the positions of the defenses from a drop-down menu on the Smart
40 // make the Sendable Choosers
41 initializeSendableChoosers();
42 addPositionChooserOptions();
43 addDefensesToAllDefenseSendableChooosers();
44 sendSendableChoosersToSmartDashboard();
48 private void initializeSendableChoosers() {
49 positionChooser
= new SendableChooser();
50 positionOneDefense
= new SendableChooser();
51 positionTwoDefense
= new SendableChooser();
52 positionThreeDefense
= new SendableChooser();
53 positionFourDefense
= new SendableChooser();
54 positionFiveDefense
= new SendableChooser();
57 private void addPositionChooserOptions() {
58 positionChooser
.addDefault("Position 1", 1);
59 positionChooser
.addObject("Position 2", 2);
60 positionChooser
.addObject("Position 3", 3);
61 positionChooser
.addObject("Position 4", 4);
62 positionChooser
.addObject("Position 5", 5);
65 private void addDefensesToAllDefenseSendableChooosers() {
66 addDefenseOptions(positionOneDefense
);
67 addDefenseOptions(positionTwoDefense
);
68 addDefenseOptions(positionThreeDefense
);
69 addDefenseOptions(positionFourDefense
);
70 addDefenseOptions(positionFiveDefense
);
73 private void addDefenseOptions(SendableChooser chooser
) {
74 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
75 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
76 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
77 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
78 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
79 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
80 chooser
.addObject("Moat", Defense
.MOAT
);
81 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
84 private void sendSendableChoosersToSmartDashboard() {
85 SmartDashboard
.putData("PositionChooser", positionChooser
);
86 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
87 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
88 SmartDashboard
.putData("Position Three Defense Chooser",
89 positionThreeDefense
);
91 .putData("Position Four Defense Chooser", positionFourDefense
);
93 .putData("Position Five Defense Chooser", positionFiveDefense
);
97 public void autonomousInit() {
98 Scheduler
.getInstance().run();
100 // get options chosen from drop down menu
101 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
102 Integer chosenDefense
= 0;
104 switch (chosenPosition
) {
106 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
108 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
110 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
112 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
114 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
117 System
.out
.println("Chosen Position: " + chosenPosition
);
118 System
.out
.println("Chosen Defense: " + chosenDefense
);
122 public void autonomousPeriodic() {
123 Scheduler
.getInstance().run();
127 public void teleopInit() {
131 public void teleopPeriodic() {
132 Scheduler
.getInstance().run();