Add lidar to drivetrain
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
53d61b3e 3import org.usfirst.frc.team3501.robot.Constants.Defense;
047383c3 4import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
02cb494e 5import org.usfirst.frc.team3501.robot.subsystems.Scaler;
40348cab
E
6import org.usfirst.frc.team3501.robot.subsystems.Shooter;
7
38a404b3
KZ
8import edu.wpi.first.wpilibj.IterativeRobot;
9import edu.wpi.first.wpilibj.command.Scheduler;
3366a59a
ME
10import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
11import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
38a404b3
KZ
12
13public class Robot extends IterativeRobot {
14 public static OI oi;
15 public static DriveTrain driveTrain;
40348cab 16 public static Shooter shooter;
02cb494e 17 public static Scaler scaler;
38a404b3 18
88e66b4e 19 // Sendable Choosers send a drop down menu to the Smart Dashboard.
3366a59a 20 SendableChooser positionChooser;
6947c8a4
ME
21 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
22 positionFourDefense, positionFiveDefense;
3366a59a 23
38a404b3
KZ
24 @Override
25 public void robotInit() {
26 driveTrain = new DriveTrain();
27 oi = new OI();
40348cab 28 shooter = new Shooter();
02cb494e 29 scaler = new Scaler();
3366a59a 30
88e66b4e
ME
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
29d59f48
ME
34 // make the Sendable Choosers
35 initializeSendableChoosers();
36 addPositionChooserOptions();
37 addDefensesToAllDefenseSendableChooosers();
38 sendSendableChoosersToSmartDashboard();
39
3366a59a
ME
40 }
41
6947c8a4
ME
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
29d59f48
ME
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) {
3366a59a
ME
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);
38a404b3
KZ
76 }
77
29d59f48
ME
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
38a404b3
KZ
90 @Override
91 public void autonomousInit() {
3366a59a
ME
92 Scheduler.getInstance().run();
93
94 // get options chosen from drop down menu
95 Integer chosenPosition = (Integer) positionChooser.getSelected();
e13d2293 96 Integer chosenDefense = 0;
3366a59a 97
33981335
ME
98 switch (chosenPosition) {
99 case 1:
3366a59a 100 chosenDefense = (Integer) positionOneDefense.getSelected();
33981335 101 case 2:
3366a59a 102 chosenDefense = (Integer) positionTwoDefense.getSelected();
33981335 103 case 3:
3366a59a 104 chosenDefense = (Integer) positionThreeDefense.getSelected();
33981335 105 case 4:
3366a59a 106 chosenDefense = (Integer) positionFourDefense.getSelected();
33981335 107 case 5:
3366a59a 108 chosenDefense = (Integer) positionFiveDefense.getSelected();
33981335 109 }
3366a59a
ME
110
111 System.out.println("Chosen Position: " + chosenPosition);
112 System.out.println("Chosen Defense: " + chosenDefense);
38a404b3
KZ
113 }
114
115 @Override
116 public void autonomousPeriodic() {
117 Scheduler.getInstance().run();
38a404b3
KZ
118 }
119
120 @Override
121 public void teleopInit() {
122 }
123
124 @Override
125 public void teleopPeriodic() {
126 Scheduler.getInstance().run();
127
128 }
129}