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 positionOneDefense
;
19 SendableChooser positionTwoDefense
;
20 SendableChooser positionThreeDefense
;
21 SendableChooser positionFourDefense
;
22 SendableChooser positionFiveDefense
;
23 SendableChooser positionChooser
;
26 public void robotInit() {
27 driveTrain
= new DriveTrain();
29 shooter
= new Shooter();
31 // initialize all the Sendable Choosers
32 positionChooser
= new SendableChooser();
33 positionOneDefense
= new SendableChooser();
34 positionTwoDefense
= new SendableChooser();
35 positionThreeDefense
= new SendableChooser();
36 positionFourDefense
= new SendableChooser();
37 positionFiveDefense
= new SendableChooser();
39 // add options for positions to the positionChooser
40 positionChooser
.addDefault("Position 1", 1);
41 positionChooser
.addObject("Position 2", 2);
42 positionChooser
.addObject("Position 3", 3);
43 positionChooser
.addObject("Position 4", 4);
44 positionChooser
.addObject("Position 5", 5);
46 // add options for defenses into each defense chooser (5)
47 addDefense(positionOneDefense
);
48 addDefense(positionTwoDefense
);
49 addDefense(positionThreeDefense
);
50 addDefense(positionFourDefense
);
51 addDefense(positionFiveDefense
);
53 // send the Sendable Choosers to the Smart Dashboard
54 // Sendable Choosers allows the driver to select the position of the robot
55 // and the positions of the defenses from a drop-down menu on the Smart
57 SmartDashboard
.putData("PositionChooser", positionChooser
);
58 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
59 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
60 SmartDashboard
.putData("Position Three Defense Chooser",
61 positionThreeDefense
);
62 SmartDashboard
.putData("Position Four Defense Chooser",
64 SmartDashboard
.putData("Position Five Defense Chooser",
68 private void addDefense(SendableChooser chooser
) {
69 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
70 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
71 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
72 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
73 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
74 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
75 chooser
.addObject("Moat", Defense
.MOAT
);
76 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
80 public void autonomousInit() {
81 Scheduler
.getInstance().run();
83 // get options chosen from drop down menu
84 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
85 Integer chosenDefense
= 0;
87 switch (chosenPosition
) {
89 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
91 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
93 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
95 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
97 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
100 System
.out
.println("Chosen Position: " + chosenPosition
);
101 System
.out
.println("Chosen Defense: " + chosenDefense
);
105 public void autonomousPeriodic() {
106 Scheduler
.getInstance().run();
110 public void teleopInit() {
114 public void teleopPeriodic() {
115 Scheduler
.getInstance().run();