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