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
;
23 public static IntakeArm intakeArm
;
24 public static DefenseArm defenseArm
;
26 // Sendable Choosers send a drop down menu to the Smart Dashboard.
27 SendableChooser positionChooser
;
28 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
29 positionFourDefense
, positionFiveDefense
;
33 >>>>>>> Remove useless variables and commented stuff in Robot
.java
36 public void robotInit() {
37 driveTrain
= new DriveTrain();
39 gyro
= new GyroLib(I2C
.Port
.kOnboard
, false);
40 >>>>>>> Remove useless variables and commented stuff in Robot
.java
42 shooter
= new Shooter();
43 scaler
= new Scaler();
44 defenseArm
= new DefenseArm();
45 intakeArm
= new IntakeArm();
47 initializeSendableChoosers();
48 addPositionChooserOptions();
49 addDefensesToAllDefenseSendableChoosers();
50 sendSendableChoosersToSmartDashboard();
53 >>>>>>> Remove useless variables and commented stuff in Robot
.java
56 private void initializeSendableChoosers() {
57 positionChooser
= new SendableChooser();
58 positionOneDefense
= new SendableChooser();
59 positionTwoDefense
= new SendableChooser();
60 positionThreeDefense
= new SendableChooser();
61 positionFourDefense
= new SendableChooser();
62 positionFiveDefense
= new SendableChooser();
65 private void addPositionChooserOptions() {
66 positionChooser
.addDefault("Position 1", 1);
67 positionChooser
.addObject("Position 2", 2);
68 positionChooser
.addObject("Position 3", 3);
69 positionChooser
.addObject("Position 4", 4);
70 positionChooser
.addObject("Position 5", 5);
73 private void addDefensesToAllDefenseSendableChoosers() {
74 addDefenseOptions(positionOneDefense
);
75 addDefenseOptions(positionTwoDefense
);
76 addDefenseOptions(positionThreeDefense
);
77 addDefenseOptions(positionFourDefense
);
78 addDefenseOptions(positionFiveDefense
);
81 private void addDefenseOptions(SendableChooser chooser
) {
82 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
83 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
84 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
85 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
86 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
87 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
88 chooser
.addObject("Moat", Defense
.MOAT
);
89 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
92 private void sendSendableChoosersToSmartDashboard() {
93 SmartDashboard
.putData("PositionChooser", positionChooser
);
94 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
95 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
96 SmartDashboard
.putData("Position Three Defense Chooser",
97 positionThreeDefense
);
98 SmartDashboard
.putData("Position Four Defense Chooser",
100 SmartDashboard
.putData("Position Five Defense Chooser",
101 positionFiveDefense
);
103 SmartDashboard
.putData("Position Four Defense Chooser",
104 positionFourDefense
);
105 SmartDashboard
.putData("Position Five Defense Chooser",
106 positionFiveDefense
);
108 shooter
= new Shooter();
113 public void autonomousInit() {
114 Scheduler
.getInstance().run();
116 // get options chosen from drop down menu
117 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
118 Integer chosenDefense
= 0;
120 switch (chosenPosition
) {
122 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
124 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
126 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
128 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
130 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
133 System
.out
.println("Chosen Position: " + chosenPosition
);
134 System
.out
.println("Chosen Defense: " + chosenDefense
);
138 public void autonomousPeriodic() {
139 Scheduler
.getInstance().run();
143 public void teleopInit() {
150 public void teleopPeriodic() {
151 Scheduler
.getInstance().run();
153 System
.out
.println("Degrees: " + gyro
.getRotationZ().getAngle());