1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Defense
;
4 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DefenseArm
;
5 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DriveTrain
;
6 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.IntakeArm
;
7 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Scaler
;
8 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
10 import edu
.wpi
.first
.wpilibj
.I2C
;
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
;
21 public static Scaler scaler
;
22 public static DefenseArm defenseArm
;
23 public static IntakeArm intakeArm
;
25 // Sendable Choosers send a drop down menu to the Smart Dashboard.
26 SendableChooser positionChooser
;
27 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
28 positionFourDefense
, positionFiveDefense
;
31 private final static double NANOSECONDS_PER_SECOND
= 1000000000;
33 public FirebotGyro gyro
;
35 double degreesIncreased
;
39 public void robotInit() {
40 // driveTrain = new DriveTrain();
41 gyro
= new FirebotGyro(I2C
.Port
.kOnboard
, (byte) 0x68);
44 shooter
= new Shooter();
45 scaler
= new Scaler();
46 defenseArm
= new DefenseArm();
47 intakeArm
= new IntakeArm();
49 // Sendable Choosers allows the driver to select the position of the robot
50 // and the positions of the defenses from a drop-down menu on the Smart
52 // make the Sendable Choosers
53 // initializeSendableChoosers();
54 // addPositionChooserOptions();
55 // addDefensesToAllDefenseSendableChooosers();
56 // sendSendableChoosersToSmartDashboard();
60 private void initializeSendableChoosers() {
61 positionChooser
= new SendableChooser();
62 positionOneDefense
= new SendableChooser();
63 positionTwoDefense
= new SendableChooser();
64 positionThreeDefense
= new SendableChooser();
65 positionFourDefense
= new SendableChooser();
66 positionFiveDefense
= new SendableChooser();
69 private void addPositionChooserOptions() {
70 positionChooser
.addDefault("Position 1", 1);
71 positionChooser
.addObject("Position 2", 2);
72 positionChooser
.addObject("Position 3", 3);
73 positionChooser
.addObject("Position 4", 4);
74 positionChooser
.addObject("Position 5", 5);
77 private void addDefensesToAllDefenseSendableChooosers() {
78 addDefenseOptions(positionOneDefense
);
79 addDefenseOptions(positionTwoDefense
);
80 addDefenseOptions(positionThreeDefense
);
81 addDefenseOptions(positionFourDefense
);
82 addDefenseOptions(positionFiveDefense
);
85 private void addDefenseOptions(SendableChooser chooser
) {
86 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
87 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
88 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
89 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
90 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
91 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
92 chooser
.addObject("Moat", Defense
.MOAT
);
93 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
96 private void sendSendableChoosersToSmartDashboard() {
97 SmartDashboard
.putData("PositionChooser", positionChooser
);
98 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
99 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
100 SmartDashboard
.putData("Position Three Defense Chooser",
101 positionThreeDefense
);
102 SmartDashboard
.putData("Position Four Defense Chooser",
103 positionFourDefense
);
104 SmartDashboard
.putData("Position Five Defense Chooser",
105 positionFiveDefense
);
107 SmartDashboard
.putData("Position Four Defense Chooser",
108 positionFourDefense
);
109 SmartDashboard
.putData("Position Five Defense Chooser",
110 positionFiveDefense
);
112 shooter
= new Shooter();
117 public void autonomousInit() {
118 Scheduler
.getInstance().run();
120 // get options chosen from drop down menu
121 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
122 Integer chosenDefense
= 0;
124 switch (chosenPosition
) {
126 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
128 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
130 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
132 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
134 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
137 System
.out
.println("Chosen Position: " + chosenPosition
);
138 System
.out
.println("Chosen Defense: " + chosenDefense
);
142 public void autonomousPeriodic() {
143 Scheduler
.getInstance().run();
147 public void teleopInit() {
151 public void teleopPeriodic() {
152 Scheduler
.getInstance().run();