| 1 | package org.usfirst.frc.team3501.robot; |
| 2 | |
| 3 | import org.usfirst.frc.team3501.robot.Constants.Defense; |
| 4 | import org.usfirst.frc.team3501.robot.commands.auton.ChooseStrategy; |
| 5 | import org.usfirst.frc.team3501.robot.commands.driving.SetLowGear; |
| 6 | import org.usfirst.frc.team3501.robot.commands.intakearm.Photogate; |
| 7 | import org.usfirst.frc.team3501.robot.subsystems.DriveTrain; |
| 8 | import org.usfirst.frc.team3501.robot.subsystems.IntakeArm; |
| 9 | import org.usfirst.frc.team3501.robot.subsystems.Shooter; |
| 10 | |
| 11 | import edu.wpi.first.wpilibj.IterativeRobot; |
| 12 | import edu.wpi.first.wpilibj.command.Scheduler; |
| 13 | import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; |
| 14 | import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; |
| 15 | |
| 16 | public class Robot extends IterativeRobot { |
| 17 | public static OI oi; |
| 18 | public static DriveTrain driveTrain; |
| 19 | public static Shooter shooter; |
| 20 | public static IntakeArm intakeArm; |
| 21 | public static Photogate photogate; |
| 22 | public static CameraFeeds cameraFeeds; |
| 23 | |
| 24 | // Sendable Choosers send a drop down menu to the Smart Dashboard. |
| 25 | private static SendableChooser defenseChooser; |
| 26 | private static SendableChooser frontChooser; |
| 27 | boolean choseIntakeIsFront; |
| 28 | |
| 29 | @Override |
| 30 | public void robotInit() { |
| 31 | driveTrain = new DriveTrain(); |
| 32 | shooter = new Shooter(); |
| 33 | intakeArm = new IntakeArm(); |
| 34 | photogate = new Photogate(); |
| 35 | cameraFeeds = new CameraFeeds(); |
| 36 | |
| 37 | oi = new OI(); |
| 38 | |
| 39 | defenseChooser = new SendableChooser(); |
| 40 | addDefenseOptions(defenseChooser); |
| 41 | SmartDashboard.putData("Defense Chooser", defenseChooser); |
| 42 | |
| 43 | frontChooser = new SendableChooser(); |
| 44 | addFrontChooserOptions(); |
| 45 | SmartDashboard.putData("Front Chooser", frontChooser); |
| 46 | } |
| 47 | |
| 48 | private void addFrontChooserOptions() { |
| 49 | frontChooser.addDefault("Intake is Back", false); |
| 50 | frontChooser.addObject("Intake is True", true); |
| 51 | } |
| 52 | |
| 53 | private void addDefenseOptions(SendableChooser chooser) { |
| 54 | chooser.addDefault("Portcullis", Defense.PORTCULLIS); |
| 55 | chooser.addObject("Sally Port", Defense.SALLY_PORT); |
| 56 | chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN); |
| 57 | chooser.addObject("Low Bar", Defense.LOW_BAR); |
| 58 | chooser.addObject("Chival De Frise", Defense.CHIVAL_DE_FRISE); |
| 59 | chooser.addObject("Drawbridge", Defense.DRAWBRIDGE); |
| 60 | chooser.addObject("Moat", Defense.MOAT); |
| 61 | chooser.addObject("Rock Wall", Defense.ROCK_WALL); |
| 62 | chooser.addObject("No Auton", Defense.NONE); |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public void autonomousInit() { |
| 67 | Defense chosenDefense = (Defense) (defenseChooser.getSelected()); |
| 68 | choseIntakeIsFront = (boolean) frontChooser.getSelected(); |
| 69 | |
| 70 | // if the shooter is not the front (intake is front) - toggle the drivetrain |
| 71 | if (choseIntakeIsFront) |
| 72 | driveTrain.toggleFlipped(); |
| 73 | |
| 74 | Scheduler.getInstance().add(new ChooseStrategy(chosenDefense)); |
| 75 | |
| 76 | // Scheduler.getInstance().add(new TimeDrive(.6, 4)); |
| 77 | |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public void autonomousPeriodic() { |
| 82 | Scheduler.getInstance().run(); |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public void teleopInit() { |
| 87 | // if intake is front, switch back to shooter as front |
| 88 | // this is done on purpose! |
| 89 | if (choseIntakeIsFront) |
| 90 | driveTrain.toggleFlipped(); |
| 91 | |
| 92 | cameraFeeds.init(); |
| 93 | Scheduler.getInstance().add(new SetLowGear()); |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public void teleopPeriodic() { |
| 98 | Scheduler.getInstance().run(); |
| 99 | cameraFeeds.run(); |
| 100 | } |
| 101 | |
| 102 | } |