1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Defense
;
4 import org
.usfirst
.frc
.team3501
.robot
.commands
.auton
.ChooseStrategy
;
5 import org
.usfirst
.frc
.team3501
.robot
.commands
.driving
.SetHighGear
;
6 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DriveTrain
;
7 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.IntakeArm
;
8 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
10 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
11 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
12 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
13 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
15 public class Robot
extends IterativeRobot
{
17 public static DriveTrain driveTrain
;
18 public static Shooter shooter
;
19 public static IntakeArm intakeArm
;
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();
29 shooter
= new Shooter();
30 intakeArm
= new IntakeArm();
34 initializeSendableChoosers();
35 addPositionChooserOptions();
36 addDefensesToAllDefenseSendableChoosers();
37 sendSendableChoosersToSmartDashboard();
40 private void initializeSendableChoosers() {
41 positionChooser
= new SendableChooser();
42 positionOneDefense
= new SendableChooser();
43 positionTwoDefense
= new SendableChooser();
44 positionThreeDefense
= new SendableChooser();
45 positionFourDefense
= new SendableChooser();
46 positionFiveDefense
= new SendableChooser();
49 private void addPositionChooserOptions() {
50 positionChooser
.addDefault("None", 0);
51 positionChooser
.addObject("Position 1", 1);
52 positionChooser
.addObject("Position 2", 2);
53 positionChooser
.addObject("Position 3", 3);
54 positionChooser
.addObject("Position 4", 4);
55 positionChooser
.addObject("Position 5", 5);
58 private void addDefensesToAllDefenseSendableChoosers() {
59 addDefenseOptions(positionOneDefense
);
60 addDefenseOptions(positionTwoDefense
);
61 addDefenseOptions(positionThreeDefense
);
62 addDefenseOptions(positionFourDefense
);
63 addDefenseOptions(positionFiveDefense
);
66 private void addDefenseOptions(SendableChooser chooser
) {
67 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
68 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
69 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
70 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
71 chooser
.addObject("Chival De Frise", Defense
.CHIVAL_DE_FRISE
);
72 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
73 chooser
.addObject("Moat", Defense
.MOAT
);
74 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
77 private void sendSendableChoosersToSmartDashboard() {
78 SmartDashboard
.putData("PositionChooser", positionChooser
);
79 SmartDashboard
.putData("Position 1 Defense Chooser", positionOneDefense
);
80 SmartDashboard
.putData("Position 2 Defense Chooser", positionTwoDefense
);
81 SmartDashboard
.putData("Position 3 Defense Chooser", positionThreeDefense
);
82 SmartDashboard
.putData("Position 4 Defense Chooser", positionFourDefense
);
83 SmartDashboard
.putData("Position 5 Defense Chooser", positionFiveDefense
);
88 public void autonomousInit() {
89 // get options chosen from drop down menu
90 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
91 Defense chosenDefense
= null;
93 if (chosenPosition
== 1)
94 chosenDefense
= (Defense
) positionOneDefense
.getSelected();
95 else if (chosenPosition
== 2)
96 chosenDefense
= (Defense
) positionTwoDefense
.getSelected();
97 else if (chosenPosition
== 3)
98 chosenDefense
= (Defense
) positionThreeDefense
.getSelected();
99 else if (chosenPosition
== 4)
100 chosenDefense
= (Defense
) positionFourDefense
.getSelected();
101 else if (chosenPosition
== 5)
102 chosenDefense
= (Defense
) positionFiveDefense
.getSelected();
104 if (chosenPosition
!= 0)
105 Scheduler
.getInstance().add(
106 new ChooseStrategy(chosenPosition
, chosenDefense
));
108 // Scheduler.getInstance().add(new TimeDrive(.6, 4));
112 public void autonomousPeriodic() {
113 Scheduler
.getInstance().run();
117 public void teleopInit() {
118 Scheduler
.getInstance().add(new SetHighGear());
122 public void teleopPeriodic() {
123 Scheduler
.getInstance().run();