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
;
32 private final static double NANOSECONDS_PER_SECOND
= 1000000000;
34 public GyroClass gyro
;
36 double degreesIncreased
;
40 public void robotInit() {
41 // driveTrain = new DriveTrain();
42 gyro
= new GyroClass(I2C
.Port
.kOnboard
, (byte) 0x68);
45 shooter
= new Shooter();
46 scaler
= new Scaler();
47 intakeArm
= new IntakeArm();
49 // Sendable Choosers allows the driver to select the position of the
51 // and the positions of the defenses from a drop-down menu on the Smart
53 // make the Sendable Choosers
54 // initializeSendableChoosers();
55 // addPositionChooserOptions();
56 // addDefensesToAllDefenseSendableChooosers();
57 // sendSendableChoosersToSmartDashboard();
61 private void initializeSendableChoosers() {
62 positionChooser
= new SendableChooser();
63 positionOneDefense
= new SendableChooser();
64 positionTwoDefense
= new SendableChooser();
65 positionThreeDefense
= new SendableChooser();
66 positionFourDefense
= new SendableChooser();
67 positionFiveDefense
= new SendableChooser();
70 private void addPositionChooserOptions() {
71 positionChooser
.addDefault("Position 1", 1);
72 positionChooser
.addObject("Position 2", 2);
73 positionChooser
.addObject("Position 3", 3);
74 positionChooser
.addObject("Position 4", 4);
75 positionChooser
.addObject("Position 5", 5);
78 private void addDefensesToAllDefenseSendableChooosers() {
79 addDefenseOptions(positionOneDefense
);
80 addDefenseOptions(positionTwoDefense
);
81 addDefenseOptions(positionThreeDefense
);
82 addDefenseOptions(positionFourDefense
);
83 addDefenseOptions(positionFiveDefense
);
86 private void addDefenseOptions(SendableChooser chooser
) {
87 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
88 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
89 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
90 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
91 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
92 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
93 chooser
.addObject("Moat", Defense
.MOAT
);
94 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
97 private void sendSendableChoosersToSmartDashboard() {
98 SmartDashboard
.putData("PositionChooser", positionChooser
);
99 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
100 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
101 SmartDashboard
.putData("Position Three Defense Chooser",
102 positionThreeDefense
);
103 SmartDashboard
.putData("Position Four Defense Chooser",
104 positionFourDefense
);
105 SmartDashboard
.putData("Position Five Defense Chooser",
106 positionFiveDefense
);
108 SmartDashboard
.putData("Position Four Defense Chooser",
109 positionFourDefense
);
110 SmartDashboard
.putData("Position Five Defense Chooser",
111 positionFiveDefense
);
113 shooter
= new Shooter();
118 public void autonomousInit() {
119 Scheduler
.getInstance().run();
121 // get options chosen from drop down menu
122 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
123 Integer chosenDefense
= 0;
125 switch (chosenPosition
) {
127 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
129 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
131 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
133 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
135 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
138 System
.out
.println("Chosen Position: " + chosenPosition
);
139 System
.out
.println("Chosen Defense: " + chosenDefense
);
143 public void autonomousPeriodic() {
144 Scheduler
.getInstance().run();
148 public void teleopInit() {
152 public void teleopPeriodic() {
153 Scheduler
.getInstance().run();