41b0defcce39ef1ed1144d677719d924f97ff270
[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.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.Photogate;
8 import org.usfirst.frc.team3501.robot.subsystems.Scaler;
9 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
10
11 import edu.wpi.first.wpilibj.I2C;
12 import edu.wpi.first.wpilibj.IterativeRobot;
13 import edu.wpi.first.wpilibj.command.Scheduler;
14 import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
15 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
16
17 public class Robot extends IterativeRobot {
18 public static OI oi;
19 public static DriveTrain driveTrain;
20 public static Shooter shooter;
21
22 public static Scaler scaler;
23
24 public static IntakeArm intakeArm;
25 public static DefenseArm defenseArm;
26
27 public static Photogate photogate;
28
29 // Sendable Choosers send a drop down menu to the Smart Dashboard.
30 SendableChooser positionChooser;
31 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
32 positionFourDefense, positionFiveDefense;
33
34 // Gyro stuff
35 public GyroLib gyro;
36
37 @Override
38 public void robotInit() {
39 driveTrain = new DriveTrain();
40 oi = new OI();
41
42 shooter = new Shooter();
43 scaler = new Scaler();
44 intakeArm = new IntakeArm();
45
46 // initializeSendableChoosers();
47 // addPositionChooserOptions();
48 // addDefensesToAllDefenseSendableChoosers();
49 // sendSendableChoosersToSmartDashboard();
50
51 }
52
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();
60 }
61
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);
68 }
69
70 private void addDefensesToAllDefenseSendableChoosers() {
71 addDefenseOptions(positionOneDefense);
72 addDefenseOptions(positionTwoDefense);
73 addDefenseOptions(positionThreeDefense);
74 addDefenseOptions(positionFourDefense);
75 addDefenseOptions(positionFiveDefense);
76 }
77
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);
87 }
88
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
96 .putData("Position Four Defense Chooser", positionFourDefense);
97 SmartDashboard
98 .putData("Position Five Defense Chooser", positionFiveDefense);
99
100 SmartDashboard
101 .putData("Position Four Defense Chooser", positionFourDefense);
102 SmartDashboard
103 .putData("Position Five Defense Chooser", positionFiveDefense);
104
105 }
106
107 @Override
108 public void autonomousInit() {
109 Scheduler.getInstance().run();
110
111 // // get options chosen from drop down menu
112 // Integer chosenPosition = (Integer) positionChooser.getSelected();
113 // Integer chosenDefense = 0;
114 //
115 // if (chosenPosition == 1)
116 // chosenDefense = (Integer) positionOneDefense.getSelected();
117 // else if (chosenPosition == 2)
118 // chosenDefense = (Integer) positionTwoDefense.getSelected();
119 // else if (chosenPosition == 3)
120 // chosenDefense = (Integer) positionThreeDefense.getSelected();
121 // else if (chosenPosition == 4)
122 // chosenDefense = (Integer) positionFourDefense.getSelected();
123 // else if (chosenPosition == 5)
124 // chosenDefense = (Integer) positionFiveDefense.getSelected();
125 //
126 // System.out.println("Chosen Position: " + chosenPosition);
127 // System.out.println("Chosen Defense: " + chosenDefense);
128 }
129
130 @Override
131 public void autonomousPeriodic() {
132 Scheduler.getInstance().run();
133 }
134
135 @Override
136 public void teleopInit() {
137 Robot.driveTrain.setLowGear();
138 Robot.shooter.raiseHood();
139 }
140
141 @Override
142 public void teleopPeriodic() {
143 Scheduler.getInstance().run();
144 if (OI.rightJoystick.getTrigger()) {
145 Robot.shooter.setSpeed(.8);
146 } else {
147 Robot.shooter.setSpeed(0);
148 }
149 if (OI.rightJoystick.getRawButton(2)) {
150 Robot.shooter.extendPunch();
151 } else {
152 Robot.shooter.retractPunch();
153 }
154 }
155
156 }