1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Auton
;
4 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Defense
;
5 import org
.usfirst
.frc
.team3501
.robot
.commands
.auton
.ChooseStrategy
;
6 import org
.usfirst
.frc
.team3501
.robot
.commands
.driving
.SetLowGear
;
7 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DriveTrain
;
8 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.IntakeArm
;
9 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
11 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
12 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
13 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
14 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
16 public class Robot
extends IterativeRobot
{
18 public static DriveTrain driveTrain
;
19 public static Shooter shooter
;
20 public static IntakeArm intakeArm
;
22 // Sendable Choosers send a drop down menu to the Smart Dashboard.
23 SendableChooser positionChooser
;
24 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
25 positionFourDefense
, positionFiveDefense
;
28 public void robotInit() {
29 driveTrain
= new DriveTrain();
30 shooter
= new Shooter();
31 intakeArm
= new IntakeArm();
35 initializeSendableChoosers();
36 addPositionChooserOptions();
37 addDefensesToAllDefenseSendableChoosers();
38 sendSendableChoosersToSmartDashboard();
41 private void initializeSendableChoosers() {
42 positionChooser
= new SendableChooser();
43 positionOneDefense
= new SendableChooser();
44 positionTwoDefense
= new SendableChooser();
45 positionThreeDefense
= new SendableChooser();
46 positionFourDefense
= new SendableChooser();
47 positionFiveDefense
= new SendableChooser();
50 private void addPositionChooserOptions() {
51 positionChooser
.addDefault("None", 0);
52 positionChooser
.addObject("Position 1", 1);
53 positionChooser
.addObject("Position 2", 2);
54 positionChooser
.addObject("Position 3", 3);
55 positionChooser
.addObject("Position 4", 4);
56 positionChooser
.addObject("Position 5", 5);
59 private void addDefensesToAllDefenseSendableChoosers() {
60 addDefenseOptions(positionOneDefense
);
61 addDefenseOptions(positionTwoDefense
);
62 addDefenseOptions(positionThreeDefense
);
63 addDefenseOptions(positionFourDefense
);
64 addDefenseOptions(positionFiveDefense
);
67 private void addDefenseOptions(SendableChooser chooser
) {
68 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
69 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
70 chooser
.addObject("Rough Terrain" + Auton
.ROUGH_TERRAIN_SPEED
+ " "
71 + Auton
.ROUGH_TERRAIN_TIME
, Defense
.ROUGH_TERRAIN
);
72 chooser
.addObject("Low Bar" + " Will probably work...", Defense
.LOW_BAR
);
73 chooser
.addObject("Chival De Frise", Defense
.CHIVAL_DE_FRISE
);
74 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
75 chooser
.addObject("Moat" + Auton
.MOAT_SPEED
+ " " + Auton
.MOAT_TIME
,
77 chooser
.addObject("Rock Wall" + Auton
.ROCK_WALL_SPEED
+ " "
78 + Auton
.ROCK_WALL_TIME
, Defense
.ROCK_WALL
);
81 private void sendSendableChoosersToSmartDashboard() {
82 SmartDashboard
.putData("PositionChooser", positionChooser
);
83 SmartDashboard
.putData("Position 1 Defense Chooser", positionOneDefense
);
84 SmartDashboard
.putData("Position 2 Defense Chooser", positionTwoDefense
);
85 SmartDashboard
.putData("Position 3 Defense Chooser", positionThreeDefense
);
86 SmartDashboard
.putData("Position 4 Defense Chooser", positionFourDefense
);
87 SmartDashboard
.putData("Position 5 Defense Chooser", positionFiveDefense
);
92 public void autonomousInit() {
93 // get options chosen from drop down menu
94 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
95 Defense chosenDefense
= null;
97 if (chosenPosition
== 1)
98 chosenDefense
= (Defense
) positionOneDefense
.getSelected();
99 else if (chosenPosition
== 2)
100 chosenDefense
= (Defense
) positionTwoDefense
.getSelected();
101 else if (chosenPosition
== 3)
102 chosenDefense
= (Defense
) positionThreeDefense
.getSelected();
103 else if (chosenPosition
== 4)
104 chosenDefense
= (Defense
) positionFourDefense
.getSelected();
105 else if (chosenPosition
== 5)
106 chosenDefense
= (Defense
) positionFiveDefense
.getSelected();
108 if (chosenPosition
!= 0)
109 Scheduler
.getInstance().add(
110 new ChooseStrategy(chosenPosition
, chosenDefense
));
112 // Scheduler.getInstance().add(new TimeDrive(.6, 4));
116 public void autonomousPeriodic() {
117 Scheduler
.getInstance().run();
121 public void teleopInit() {
122 Scheduler
.getInstance().add(new SetLowGear());
126 public void teleopPeriodic() {
127 Scheduler
.getInstance().run();