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
.Photogate
;
8 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Scaler
;
9 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
11 import edu
.wpi
.first
.wpilibj
.I2C
;
12 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
13 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
14 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
15 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
17 public class Robot
extends IterativeRobot
{
19 public static DriveTrain driveTrain
;
20 public static Shooter shooter
;
22 public static Scaler scaler
;
24 public static IntakeArm intakeArm
;
25 public static DefenseArm defenseArm
;
27 public static Photogate photogate
;
29 // Sendable Choosers send a drop down menu to the Smart Dashboard.
30 SendableChooser positionChooser
;
31 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
32 positionFourDefense
, positionFiveDefense
;
38 public void robotInit() {
39 driveTrain
= new DriveTrain();
41 gyro
= new GyroLib(I2C
.Port
.kOnboard
, false);
43 shooter
= new Shooter();
44 scaler
= new Scaler();
45 intakeArm
= new IntakeArm();
47 initializeSendableChoosers();
48 addPositionChooserOptions();
49 addDefensesToAllDefenseSendableChoosers();
50 sendSendableChoosersToSmartDashboard();
54 private void initializeSendableChoosers() {
55 positionChooser
= new SendableChooser();
56 positionOneDefense
= new SendableChooser();
57 positionTwoDefense
= new SendableChooser();
58 positionThreeDefense
= new SendableChooser();
59 positionFourDefense
= new SendableChooser();
60 positionFiveDefense
= new SendableChooser();
63 private void addPositionChooserOptions() {
64 positionChooser
.addDefault("Position 1", 1);
65 positionChooser
.addObject("Position 2", 2);
66 positionChooser
.addObject("Position 3", 3);
67 positionChooser
.addObject("Position 4", 4);
68 positionChooser
.addObject("Position 5", 5);
71 private void addDefensesToAllDefenseSendableChoosers() {
72 addDefenseOptions(positionOneDefense
);
73 addDefenseOptions(positionTwoDefense
);
74 addDefenseOptions(positionThreeDefense
);
75 addDefenseOptions(positionFourDefense
);
76 addDefenseOptions(positionFiveDefense
);
79 private void addDefenseOptions(SendableChooser chooser
) {
80 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
81 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
82 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
83 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
84 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
85 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
86 chooser
.addObject("Moat", Defense
.MOAT
);
87 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
90 private void sendSendableChoosersToSmartDashboard() {
91 SmartDashboard
.putData("PositionChooser", positionChooser
);
92 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
93 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
94 SmartDashboard
.putData("Position Three Defense Chooser",
95 positionThreeDefense
);
96 SmartDashboard
.putData("Position Four Defense Chooser",
98 SmartDashboard
.putData("Position Five Defense Chooser",
101 SmartDashboard
.putData("Position Four Defense Chooser",
102 positionFourDefense
);
103 SmartDashboard
.putData("Position Five Defense Chooser",
104 positionFiveDefense
);
106 shooter
= new Shooter();
111 public void autonomousInit() {
112 Scheduler
.getInstance().run();
114 // get options chosen from drop down menu
115 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
116 Integer chosenDefense
= 0;
118 switch (chosenPosition
) {
120 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
122 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
124 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
126 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
128 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
131 System
.out
.println("Chosen Position: " + chosenPosition
);
132 System
.out
.println("Chosen Defense: " + chosenDefense
);
136 public void autonomousPeriodic() {
137 Scheduler
.getInstance().run();
141 public void teleopInit() {
148 public void teleopPeriodic() {
149 Scheduler
.getInstance().run();
151 System
.out
.println("Degrees: " + gyro
.getRotationZ().getAngle());