add Sendable Chooser for what is the front of the robot
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
b378dfef 3import org.usfirst.frc.team3501.robot.Constants.Auton;
9e9154af
HD
4import org.usfirst.frc.team3501.robot.Constants.Defense;
5import org.usfirst.frc.team3501.robot.commands.auton.ChooseStrategy;
eeb6c3d9 6import org.usfirst.frc.team3501.robot.commands.driving.SetLowGear;
e2c4d3a5 7import org.usfirst.frc.team3501.robot.commands.intakearm.Photogate;
047383c3 8import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
e47f0862 9import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
40348cab
E
10import org.usfirst.frc.team3501.robot.subsystems.Shooter;
11
38a404b3
KZ
12import edu.wpi.first.wpilibj.IterativeRobot;
13import edu.wpi.first.wpilibj.command.Scheduler;
9e9154af
HD
14import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
15import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
38a404b3
KZ
16
17public class Robot extends IterativeRobot {
18 public static OI oi;
19 public static DriveTrain driveTrain;
40348cab 20 public static Shooter shooter;
a96fa926 21 public static IntakeArm intakeArm;
e2c4d3a5 22 public static Photogate photogate;
3366a59a 23
9e9154af 24 // Sendable Choosers send a drop down menu to the Smart Dashboard.
157ea726
ME
25 private static SendableChooser defenseChooser;
26 private static SendableChooser frontChooser;
27 boolean choseIntakeIsFront;
9e9154af 28
38a404b3
KZ
29 @Override
30 public void robotInit() {
9742fe2e 31 driveTrain = new DriveTrain();
40348cab 32 shooter = new Shooter();
a96fa926 33 intakeArm = new IntakeArm();
fab544eb
HD
34
35 oi = new OI();
e2c4d3a5 36 photogate = new Photogate();
9e9154af 37
de0cd1ce
ME
38 defenseChooser = new SendableChooser();
39 addDefenseOptions(defenseChooser);
40 SmartDashboard.putData("Defense Chooser", defenseChooser);
157ea726
ME
41
42 frontChooser = new SendableChooser();
43 addFrontChooserOptions();
44 SmartDashboard.putData("Front Chooser", frontChooser);
45 }
46
47 private void addFrontChooserOptions() {
48 frontChooser.addDefault("Intake is Back", false);
49 frontChooser.addObject("Intake is True", true);
9e9154af
HD
50 }
51
52 private void addDefenseOptions(SendableChooser chooser) {
53 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
54 chooser.addObject("Sally Port", Defense.SALLY_PORT);
b378dfef
HD
55 chooser.addObject("Rough Terrain" + Auton.ROUGH_TERRAIN_SPEED + " "
56 + Auton.ROUGH_TERRAIN_TIME, Defense.ROUGH_TERRAIN);
949415d0 57 chooser.addObject("Low Bar" + " Will probably work...", Defense.LOW_BAR);
9e9154af
HD
58 chooser.addObject("Chival De Frise", Defense.CHIVAL_DE_FRISE);
59 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
b378dfef
HD
60 chooser.addObject("Moat" + Auton.MOAT_SPEED + " " + Auton.MOAT_TIME,
61 Defense.MOAT);
de0cd1ce
ME
62 chooser.addObject(
63 "Rock Wall" + Auton.ROCK_WALL_SPEED + " " + Auton.ROCK_WALL_TIME,
64 Defense.ROCK_WALL);
c62f7132 65 chooser.addObject("No Auton", Defense.NONE);
29d59f48
ME
66 }
67
38a404b3
KZ
68 @Override
69 public void autonomousInit() {
de0cd1ce 70 Defense chosenDefense = (Defense) (defenseChooser.getSelected());
157ea726
ME
71 choseIntakeIsFront = (boolean) frontChooser.getSelected();
72
73 // if the shooter is not the front (intake is front) - toggle the drivetrain
74 if (choseIntakeIsFront)
75 driveTrain.toggleFlipped();
9e9154af 76
de0cd1ce 77 Scheduler.getInstance().add(new ChooseStrategy(chosenDefense));
35e19c59
HD
78
79 // Scheduler.getInstance().add(new TimeDrive(.6, 4));
157ea726 80
38a404b3
KZ
81 }
82
83 @Override
84 public void autonomousPeriodic() {
85 Scheduler.getInstance().run();
38a404b3
KZ
86 }
87
88 @Override
89 public void teleopInit() {
157ea726
ME
90 // if intake is front, switch back to shooter as front
91 if (choseIntakeIsFront)
92 driveTrain.toggleFlipped();
93
eeb6c3d9 94 Scheduler.getInstance().add(new SetLowGear());
38a404b3
KZ
95 }
96
97 @Override
98 public void teleopPeriodic() {
99 Scheduler.getInstance().run();
1e039ebd
E
100 }
101
38a404b3 102}