1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.AnotherGyroClass
.Rotation
;
4 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Defense
;
5 import org
.usfirst
.frc
.team3501
.robot
.GyroLib
.Rotation
;
6 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DefenseArm
;
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
.Scaler
;
10 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
12 import edu
.wpi
.first
.wpilibj
.I2C
;
13 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
14 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
15 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
16 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
18 public class Robot
extends IterativeRobot
{
20 public static DriveTrain driveTrain
;
21 public static Shooter shooter
;
23 public static Scaler scaler
;
25 public static IntakeArm intakeArm
;
26 public static DefenseArm defenseArm
;
28 // Sendable Choosers send a drop down menu to the Smart Dashboard.
29 SendableChooser positionChooser
;
30 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
31 positionFourDefense
, positionFiveDefense
;
37 public void robotInit() {
38 driveTrain
= new DriveTrain();
40 gyro
= new GyroLib(I2C
.Port
.kOnboard
, false);
42 shooter
= new Shooter();
43 scaler
= new Scaler();
44 intakeArm
= new IntakeArm();
46 initializeSendableChoosers();
47 addPositionChooserOptions();
48 addDefensesToAllDefenseSendableChoosers();
49 sendSendableChoosersToSmartDashboard();
53 private void initializeSendableChoosers() {
54 positionChooser
= new SendableChooser();
55 positionOneDefense
= new SendableChooser();
56 positionTwoDefense
= new SendableChooser();
57 positionThreeDefense
= new SendableChooser();
58 positionFourDefense
= new SendableChooser();
59 positionFiveDefense
= new SendableChooser();
62 private void addPositionChooserOptions() {
63 positionChooser
.addDefault("Position 1", 1);
64 positionChooser
.addObject("Position 2", 2);
65 positionChooser
.addObject("Position 3", 3);
66 positionChooser
.addObject("Position 4", 4);
67 positionChooser
.addObject("Position 5", 5);
70 private void addDefensesToAllDefenseSendableChoosers() {
71 addDefenseOptions(positionOneDefense
);
72 addDefenseOptions(positionTwoDefense
);
73 addDefenseOptions(positionThreeDefense
);
74 addDefenseOptions(positionFourDefense
);
75 addDefenseOptions(positionFiveDefense
);
78 private void addDefenseOptions(SendableChooser chooser
) {
79 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
80 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
81 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
82 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
83 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
84 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
85 chooser
.addObject("Moat", Defense
.MOAT
);
86 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
89 private void sendSendableChoosersToSmartDashboard() {
90 SmartDashboard
.putData("PositionChooser", positionChooser
);
91 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
92 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
93 SmartDashboard
.putData("Position Three Defense Chooser",
94 positionThreeDefense
);
95 SmartDashboard
.putData("Position Four Defense Chooser",
97 SmartDashboard
.putData("Position Five Defense Chooser",
100 SmartDashboard
.putData("Position Four Defense Chooser",
101 positionFourDefense
);
102 SmartDashboard
.putData("Position Five Defense Chooser",
103 positionFiveDefense
);
105 shooter
= new Shooter();
110 public void autonomousInit() {
111 Scheduler
.getInstance().run();
113 // get options chosen from drop down menu
114 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
115 Integer chosenDefense
= 0;
117 switch (chosenPosition
) {
119 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
121 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
123 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
125 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
127 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
130 System
.out
.println("Chosen Position: " + chosenPosition
);
131 System
.out
.println("Chosen Defense: " + chosenDefense
);
135 public void autonomousPeriodic() {
136 Scheduler
.getInstance().run();
140 public void teleopInit() {
147 public void teleopPeriodic() {
148 Scheduler
.getInstance().run();
150 System
.out
.println("Degrees: " + gyro
.getRotationZ().getAngle());