1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.DriveTrain
;
4 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
6 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
7 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
8 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
9 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
11 public class Robot
extends IterativeRobot
{
13 public static DriveTrain driveTrain
;
14 public static Shooter shooter
;
17 PORTCULLIS
, SALLY_PORT
, ROUGH_TERRAIN
, LOW_BAR
, CHEVAL_DE_FRISE
, DRAWBRIDGE
, MOAT
, ROCK_WALL
20 // Sendable Choosers send a drop down menu to the Smart Dashboard.
21 SendableChooser positionOneDefense
;
22 SendableChooser positionTwoDefense
;
23 SendableChooser positionThreeDefense
;
24 SendableChooser positionFourDefense
;
25 SendableChooser positionFiveDefense
;
26 SendableChooser positionChooser
;
29 public void robotInit() {
30 driveTrain
= new DriveTrain();
32 shooter
= new Shooter();
34 // intialize all the Sendable Choosers
35 positionChooser
= new SendableChooser();
36 positionOneDefense
= new SendableChooser();
37 positionTwoDefense
= new SendableChooser();
38 positionThreeDefense
= new SendableChooser();
39 positionFourDefense
= new SendableChooser();
40 positionFiveDefense
= new SendableChooser();
42 // add options for positions to the positionChooser
43 positionChooser
.addDefault("Position 1", 1);
44 positionChooser
.addObject("Position 2", 2);
45 positionChooser
.addObject("Position 3", 3);
46 positionChooser
.addObject("Position 4", 4);
47 positionChooser
.addObject("Position 5", 5);
49 // add options for defenses into each defense chooser (5)
50 addDefense(positionOneDefense
);
51 addDefense(positionTwoDefense
);
52 addDefense(positionThreeDefense
);
53 addDefense(positionFourDefense
);
54 addDefense(positionFiveDefense
);
56 // send the Sendable Choosers to the Smart Dashboard
57 // Sendable Choosers allows the driver to select the position of the robot
58 // and the positions of the defenses from a drop-down menu on the Smart
60 SmartDashboard
.putData("PositionChooser", positionChooser
);
61 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
62 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
63 SmartDashboard
.putData("Position Three Defense Chooser",
64 positionThreeDefense
);
65 SmartDashboard
.putData("Position Four Defense Chooser",
67 SmartDashboard
.putData("Position Five Defense Chooser",
71 private void addDefense(SendableChooser chooser
) {
72 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
73 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
74 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
75 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
76 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
77 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
78 chooser
.addObject("Moat", Defense
.MOAT
);
79 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
83 public void autonomousInit() {
84 Scheduler
.getInstance().run();
86 // get options chosen from drop down menu
87 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
88 Integer chosenDefense
= 0;
90 switch (chosenPosition
) {
92 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
94 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
96 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
98 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
100 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
103 System
.out
.println("Chosen Position: " + chosenPosition
);
104 System
.out
.println("Chosen Defense: " + chosenDefense
);
108 public void autonomousPeriodic() {
109 Scheduler
.getInstance().run();
113 public void teleopInit() {
114 System
.out
.println("running teleopInit");
118 public void teleopPeriodic() {
119 Scheduler
.getInstance().run();
123 public void operate() {