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
;
21 public static IntakeArm intakeArm
;
22 public static DefenseArm defenseArm
;
24 // Sendable Choosers send a drop down menu to the Smart Dashboard.
25 SendableChooser positionChooser
;
26 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
27 positionFourDefense
, positionFiveDefense
;
30 public void robotInit() {
31 driveTrain
= new DriveTrain();
33 shooter
= new Shooter();
34 scaler
= new Scaler();
35 defenseArm
= new DefenseArm();
36 intakeArm
= new IntakeArm();
38 // Sendable Choosers allows the driver to select the position of the robot
39 // and the positions of the defenses from a drop-down menu on the Smart
41 // make the Sendable Choosers
42 initializeSendableChoosers();
43 addPositionChooserOptions();
44 addDefensesToAllDefenseSendableChooosers();
45 sendSendableChoosersToSmartDashboard();
49 private void initializeSendableChoosers() {
50 positionChooser
= new SendableChooser();
51 positionOneDefense
= new SendableChooser();
52 positionTwoDefense
= new SendableChooser();
53 positionThreeDefense
= new SendableChooser();
54 positionFourDefense
= new SendableChooser();
55 positionFiveDefense
= new SendableChooser();
58 private void addPositionChooserOptions() {
59 positionChooser
.addDefault("Position 1", 1);
60 positionChooser
.addObject("Position 2", 2);
61 positionChooser
.addObject("Position 3", 3);
62 positionChooser
.addObject("Position 4", 4);
63 positionChooser
.addObject("Position 5", 5);
66 private void addDefensesToAllDefenseSendableChooosers() {
67 addDefenseOptions(positionOneDefense
);
68 addDefenseOptions(positionTwoDefense
);
69 addDefenseOptions(positionThreeDefense
);
70 addDefenseOptions(positionFourDefense
);
71 addDefenseOptions(positionFiveDefense
);
74 private void addDefenseOptions(SendableChooser chooser
) {
75 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
76 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
77 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
78 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
79 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
80 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
81 chooser
.addObject("Moat", Defense
.MOAT
);
82 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
85 private void sendSendableChoosersToSmartDashboard() {
86 SmartDashboard
.putData("PositionChooser", positionChooser
);
87 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
88 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
89 SmartDashboard
.putData("Position Three Defense Chooser",
90 positionThreeDefense
);
91 SmartDashboard
.putData("Position Four Defense Chooser",
93 SmartDashboard
.putData("Position Five Defense Chooser",
96 SmartDashboard
.putData("Position Four Defense Chooser",
98 SmartDashboard
.putData("Position Five Defense Chooser",
101 shooter
= new Shooter();
105 private void addDefense(SendableChooser chooser
) {
106 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
107 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
108 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
109 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
110 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
111 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
112 chooser
.addObject("Moat", Defense
.MOAT
);
113 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
115 shooter
= new Shooter();
120 public void autonomousInit() {
121 Scheduler
.getInstance().run();
123 // get options chosen from drop down menu
124 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
125 Integer chosenDefense
= 0;
127 switch (chosenPosition
) {
129 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
131 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
133 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
135 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
137 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
140 System
.out
.println("Chosen Position: " + chosenPosition
);
141 System
.out
.println("Chosen Defense: " + chosenDefense
);
145 public void autonomousPeriodic() {
146 Scheduler
.getInstance().run();
150 public void teleopInit() {
154 public void teleopPeriodic() {
155 Scheduler
.getInstance().run();