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
.Scaler
;
7 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
9 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
10 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
11 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
12 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
14 public class Robot
extends IterativeRobot
{
16 public static DriveTrain driveTrain
;
17 public static Shooter shooter
;
18 public static Scaler scaler
;
19 public static DefenseArm defenseArm
;
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();
30 shooter
= new Shooter();
31 scaler
= new Scaler();
32 defenseArm
= new DefenseArm();
34 // Sendable Choosers allows the driver to select the position of the robot
35 // and the positions of the defenses from a drop-down menu on the Smart
37 // make the Sendable Choosers
38 initializeSendableChoosers();
39 addPositionChooserOptions();
40 addDefensesToAllDefenseSendableChooosers();
41 sendSendableChoosersToSmartDashboard();
45 private void initializeSendableChoosers() {
46 positionChooser
= new SendableChooser();
47 positionOneDefense
= new SendableChooser();
48 positionTwoDefense
= new SendableChooser();
49 positionThreeDefense
= new SendableChooser();
50 positionFourDefense
= new SendableChooser();
51 positionFiveDefense
= new SendableChooser();
54 private void addPositionChooserOptions() {
55 positionChooser
.addDefault("Position 1", 1);
56 positionChooser
.addObject("Position 2", 2);
57 positionChooser
.addObject("Position 3", 3);
58 positionChooser
.addObject("Position 4", 4);
59 positionChooser
.addObject("Position 5", 5);
62 private void addDefensesToAllDefenseSendableChooosers() {
63 addDefenseOptions(positionOneDefense
);
64 addDefenseOptions(positionTwoDefense
);
65 addDefenseOptions(positionThreeDefense
);
66 addDefenseOptions(positionFourDefense
);
67 addDefenseOptions(positionFiveDefense
);
70 private void addDefenseOptions(SendableChooser chooser
) {
71 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
72 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
73 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
74 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
75 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
76 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
77 chooser
.addObject("Moat", Defense
.MOAT
);
78 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
81 private void sendSendableChoosersToSmartDashboard() {
82 SmartDashboard
.putData("PositionChooser", positionChooser
);
83 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
84 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
85 SmartDashboard
.putData("Position Three Defense Chooser",
86 positionThreeDefense
);
87 SmartDashboard
.putData("Position Four Defense Chooser",
89 SmartDashboard
.putData("Position Five Defense Chooser",
94 public void autonomousInit() {
95 Scheduler
.getInstance().run();
97 // get options chosen from drop down menu
98 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
99 Integer chosenDefense
= 0;
101 switch (chosenPosition
) {
103 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
105 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
107 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
109 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
111 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
114 System
.out
.println("Chosen Position: " + chosenPosition
);
115 System
.out
.println("Chosen Defense: " + chosenDefense
);
119 public void autonomousPeriodic() {
120 Scheduler
.getInstance().run();
124 public void teleopInit() {
128 public void teleopPeriodic() {
129 Scheduler
.getInstance().run();