Add lidar to drivetrain
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
1 package org.usfirst.frc.team3501.robot;
2
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;
7
8 import edu.wpi.first.wpilibj.IterativeRobot;
9 import edu.wpi.first.wpilibj.command.Scheduler;
10 import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
11 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
12
13 public class Robot extends IterativeRobot {
14 public static OI oi;
15 public static DriveTrain driveTrain;
16 public static Shooter shooter;
17 public static Scaler scaler;
18
19 // Sendable Choosers send a drop down menu to the Smart Dashboard.
20 SendableChooser positionChooser;
21 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
22 positionFourDefense, positionFiveDefense;
23
24 @Override
25 public void robotInit() {
26 driveTrain = new DriveTrain();
27 oi = new OI();
28 shooter = new Shooter();
29 scaler = new Scaler();
30
31 // Sendable Choosers allows the driver to select the position of the robot
32 // and the positions of the defenses from a drop-down menu on the Smart
33 // Dashboard
34 // make the Sendable Choosers
35 initializeSendableChoosers();
36 addPositionChooserOptions();
37 addDefensesToAllDefenseSendableChooosers();
38 sendSendableChoosersToSmartDashboard();
39
40 }
41
42 private void initializeSendableChoosers() {
43 positionChooser = new SendableChooser();
44 positionOneDefense = new SendableChooser();
45 positionTwoDefense = new SendableChooser();
46 positionThreeDefense = new SendableChooser();
47 positionFourDefense = new SendableChooser();
48 positionFiveDefense = new SendableChooser();
49 }
50
51 private void addPositionChooserOptions() {
52 positionChooser.addDefault("Position 1", 1);
53 positionChooser.addObject("Position 2", 2);
54 positionChooser.addObject("Position 3", 3);
55 positionChooser.addObject("Position 4", 4);
56 positionChooser.addObject("Position 5", 5);
57 }
58
59 private void addDefensesToAllDefenseSendableChooosers() {
60 addDefenseOptions(positionOneDefense);
61 addDefenseOptions(positionTwoDefense);
62 addDefenseOptions(positionThreeDefense);
63 addDefenseOptions(positionFourDefense);
64 addDefenseOptions(positionFiveDefense);
65 }
66
67 private void addDefenseOptions(SendableChooser chooser) {
68 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
69 chooser.addObject("Sally Port", Defense.SALLY_PORT);
70 chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN);
71 chooser.addObject("Low Bar", Defense.LOW_BAR);
72 chooser.addObject("Cheval De Frise", Defense.CHEVAL_DE_FRISE);
73 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
74 chooser.addObject("Moat", Defense.MOAT);
75 chooser.addObject("Rock Wall", Defense.ROCK_WALL);
76 }
77
78 private void sendSendableChoosersToSmartDashboard() {
79 SmartDashboard.putData("PositionChooser", positionChooser);
80 SmartDashboard.putData("Position One Defense Chooser", positionOneDefense);
81 SmartDashboard.putData("Position Two Defense Chooser", positionTwoDefense);
82 SmartDashboard.putData("Position Three Defense Chooser",
83 positionThreeDefense);
84 SmartDashboard.putData("Position Four Defense Chooser",
85 positionFourDefense);
86 SmartDashboard.putData("Position Five Defense Chooser",
87 positionFiveDefense);
88 }
89
90 @Override
91 public void autonomousInit() {
92 Scheduler.getInstance().run();
93
94 // get options chosen from drop down menu
95 Integer chosenPosition = (Integer) positionChooser.getSelected();
96 Integer chosenDefense = 0;
97
98 switch (chosenPosition) {
99 case 1:
100 chosenDefense = (Integer) positionOneDefense.getSelected();
101 case 2:
102 chosenDefense = (Integer) positionTwoDefense.getSelected();
103 case 3:
104 chosenDefense = (Integer) positionThreeDefense.getSelected();
105 case 4:
106 chosenDefense = (Integer) positionFourDefense.getSelected();
107 case 5:
108 chosenDefense = (Integer) positionFiveDefense.getSelected();
109 }
110
111 System.out.println("Chosen Position: " + chosenPosition);
112 System.out.println("Chosen Defense: " + chosenDefense);
113 }
114
115 @Override
116 public void autonomousPeriodic() {
117 Scheduler.getInstance().run();
118 }
119
120 @Override
121 public void teleopInit() {
122 }
123
124 @Override
125 public void teleopPeriodic() {
126 Scheduler.getInstance().run();
127
128 }
129 }