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
;
21 // public static Photogate photogate;
23 // Sendable Choosers send a drop down menu to the Smart Dashboard.
24 SendableChooser positionChooser
;
25 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
26 positionFourDefense
, positionFiveDefense
;
29 public void robotInit() {
30 driveTrain
= new DriveTrain();
31 shooter
= new Shooter();
32 intakeArm
= new IntakeArm();
35 // photogate = new Photogate();
37 initializeSendableChoosers();
38 addPositionChooserOptions();
39 addDefensesToAllDefenseSendableChoosers();
40 sendSendableChoosersToSmartDashboard();
43 private void initializeSendableChoosers() {
44 positionChooser
= new SendableChooser();
45 positionOneDefense
= new SendableChooser();
46 positionTwoDefense
= new SendableChooser();
47 positionThreeDefense
= new SendableChooser();
48 positionFourDefense
= new SendableChooser();
49 positionFiveDefense
= new SendableChooser();
52 private void addPositionChooserOptions() {
53 positionChooser
.addDefault("None", 0);
54 positionChooser
.addObject("Position 1", 1);
55 positionChooser
.addObject("Position 2", 2);
56 positionChooser
.addObject("Position 3", 3);
57 positionChooser
.addObject("Position 4", 4);
58 positionChooser
.addObject("Position 5", 5);
61 private void addDefensesToAllDefenseSendableChoosers() {
62 addDefenseOptions(positionOneDefense
);
63 addDefenseOptions(positionTwoDefense
);
64 addDefenseOptions(positionThreeDefense
);
65 addDefenseOptions(positionFourDefense
);
66 addDefenseOptions(positionFiveDefense
);
69 private void addDefenseOptions(SendableChooser chooser
) {
70 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
71 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
72 chooser
.addObject("Rough Terrain" + Auton
.ROUGH_TERRAIN_SPEED
+ " "
73 + Auton
.ROUGH_TERRAIN_TIME
, Defense
.ROUGH_TERRAIN
);
74 chooser
.addObject("Low Bar" + " Will probably work...", Defense
.LOW_BAR
);
75 chooser
.addObject("Chival De Frise", Defense
.CHIVAL_DE_FRISE
);
76 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
77 chooser
.addObject("Moat" + Auton
.MOAT_SPEED
+ " " + Auton
.MOAT_TIME
,
79 chooser
.addObject("Rock Wall" + Auton
.ROCK_WALL_SPEED
+ " "
80 + Auton
.ROCK_WALL_TIME
, Defense
.ROCK_WALL
);
83 private void sendSendableChoosersToSmartDashboard() {
84 SmartDashboard
.putData("PositionChooser", positionChooser
);
85 SmartDashboard
.putData("Position 1 Defense Chooser", positionOneDefense
);
86 SmartDashboard
.putData("Position 2 Defense Chooser", positionTwoDefense
);
87 SmartDashboard
.putData("Position 3 Defense Chooser", positionThreeDefense
);
88 SmartDashboard
.putData("Position 4 Defense Chooser", positionFourDefense
);
89 SmartDashboard
.putData("Position 5 Defense Chooser", positionFiveDefense
);
94 public void autonomousInit() {
95 // get options chosen from drop down menu
96 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
97 Defense chosenDefense
= null;
99 if (chosenPosition
== 1)
100 chosenDefense
= (Defense
) positionOneDefense
.getSelected();
101 else if (chosenPosition
== 2)
102 chosenDefense
= (Defense
) positionTwoDefense
.getSelected();
103 else if (chosenPosition
== 3)
104 chosenDefense
= (Defense
) positionThreeDefense
.getSelected();
105 else if (chosenPosition
== 4)
106 chosenDefense
= (Defense
) positionFourDefense
.getSelected();
107 else if (chosenPosition
== 5)
108 chosenDefense
= (Defense
) positionFiveDefense
.getSelected();
110 if (chosenPosition
!= 0)
111 Scheduler
.getInstance().add(
112 new ChooseStrategy(chosenPosition
, chosenDefense
));
114 // Scheduler.getInstance().add(new TimeDrive(.6, 4));
118 public void autonomousPeriodic() {
119 Scheduler
.getInstance().run();
123 public void teleopInit() {
124 Scheduler
.getInstance().add(new SetLowGear());
128 public void teleopPeriodic() {
129 Scheduler
.getInstance().run();