1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Defense
;
4 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DriveTrain
;
5 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Scaler
;
6 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
8 import edu
.wpi
.first
.wpilibj
.I2C
;
9 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
10 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
11 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
12 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
14 public class Robot
extends IterativeRobot
{
16 public static DriveTrain driveTrain
;
17 public static Shooter shooter
;
18 public static Scaler scaler
;
20 // Sendable Choosers send a drop down menu to the Smart Dashboard.
21 SendableChooser positionChooser
;
22 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
23 positionFourDefense
, positionFiveDefense
;
25 public static Lidar lidar
;
28 public void robotInit() {
29 driveTrain
= new DriveTrain();
31 shooter
= new Shooter();
32 scaler
= new Scaler();
33 lidar
= new Lidar(I2C
.Port
.kOnboard
);
35 // Sendable Choosers allows the driver to select the position of the robot
36 // and the positions of the defenses from a drop-down menu on the Smart
38 // make the Sendable Choosers
39 initializeSendableChoosers();
40 addPositionChooserOptions();
41 addDefensesToAllDefenseSendableChooosers();
42 sendSendableChoosersToSmartDashboard();
46 private void initializeSendableChoosers() {
47 positionChooser
= new SendableChooser();
48 positionOneDefense
= new SendableChooser();
49 positionTwoDefense
= new SendableChooser();
50 positionThreeDefense
= new SendableChooser();
51 positionFourDefense
= new SendableChooser();
52 positionFiveDefense
= new SendableChooser();
55 private void addPositionChooserOptions() {
56 positionChooser
.addDefault("Position 1", 1);
57 positionChooser
.addObject("Position 2", 2);
58 positionChooser
.addObject("Position 3", 3);
59 positionChooser
.addObject("Position 4", 4);
60 positionChooser
.addObject("Position 5", 5);
63 private void addDefensesToAllDefenseSendableChooosers() {
64 addDefenseOptions(positionOneDefense
);
65 addDefenseOptions(positionTwoDefense
);
66 addDefenseOptions(positionThreeDefense
);
67 addDefenseOptions(positionFourDefense
);
68 addDefenseOptions(positionFiveDefense
);
71 private void addDefenseOptions(SendableChooser chooser
) {
72 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
73 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
74 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
75 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
76 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
77 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
78 chooser
.addObject("Moat", Defense
.MOAT
);
79 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
82 private void sendSendableChoosersToSmartDashboard() {
83 SmartDashboard
.putData("PositionChooser", positionChooser
);
84 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
85 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
86 SmartDashboard
.putData("Position Three Defense Chooser",
87 positionThreeDefense
);
88 SmartDashboard
.putData("Position Four Defense Chooser",
90 SmartDashboard
.putData("Position Five Defense Chooser",
95 public void autonomousInit() {
96 Scheduler
.getInstance().run();
98 // get options chosen from drop down menu
99 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
100 Integer chosenDefense
= 0;
102 switch (chosenPosition
) {
104 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
106 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
108 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
110 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
112 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
115 System
.out
.println("Chosen Position: " + chosenPosition
);
116 System
.out
.println("Chosen Defense: " + chosenDefense
);
120 public void autonomousPeriodic() {
121 Scheduler
.getInstance().run();
125 public void teleopInit() {
130 public void teleopPeriodic() {
132 Scheduler
.getInstance().run();
136 public void printLidarValues() {
138 System
.out
.println(lidar
.pidGet());