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 initializeSendableChoosers();
30 // add options for positions to the positionChooser
31 positionChooser
.addDefault("Position 1", 1);
32 positionChooser
.addObject("Position 2", 2);
33 positionChooser
.addObject("Position 3", 3);
34 positionChooser
.addObject("Position 4", 4);
35 positionChooser
.addObject("Position 5", 5);
37 // add options for defenses into each defense chooser (5)
38 addDefense(positionOneDefense
);
39 addDefense(positionTwoDefense
);
40 addDefense(positionThreeDefense
);
41 addDefense(positionFourDefense
);
42 addDefense(positionFiveDefense
);
44 // send the Sendable Choosers to the Smart Dashboard
45 // Sendable Choosers allows the driver to select the position of the robot
46 // and the positions of the defenses from a drop-down menu on the Smart
48 SmartDashboard
.putData("PositionChooser", positionChooser
);
49 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
50 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
51 SmartDashboard
.putData("Position Three Defense Chooser",
52 positionThreeDefense
);
53 SmartDashboard
.putData("Position Four Defense Chooser",
55 SmartDashboard
.putData("Position Five Defense Chooser",
59 // initialize all the Sendable Choosers
60 private void initializeSendableChoosers() {
61 positionChooser
= new SendableChooser();
62 positionOneDefense
= new SendableChooser();
63 positionTwoDefense
= new SendableChooser();
64 positionThreeDefense
= new SendableChooser();
65 positionFourDefense
= new SendableChooser();
66 positionFiveDefense
= new SendableChooser();
69 private void addDefense(SendableChooser chooser
) {
70 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
71 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
72 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
73 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
74 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
75 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
76 chooser
.addObject("Moat", Defense
.MOAT
);
77 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
81 public void autonomousInit() {
82 Scheduler
.getInstance().run();
84 // get options chosen from drop down menu
85 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
86 Integer chosenDefense
= 0;
88 switch (chosenPosition
) {
90 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
92 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
94 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
96 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
98 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
101 System
.out
.println("Chosen Position: " + chosenPosition
);
102 System
.out
.println("Chosen Defense: " + chosenDefense
);
106 public void autonomousPeriodic() {
107 Scheduler
.getInstance().run();
111 public void teleopInit() {
115 public void teleopPeriodic() {
116 Scheduler
.getInstance().run();