| 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.Scaler; |
| 8 | import org.usfirst.frc.team3501.robot.subsystems.Shooter; |
| 9 | |
| 10 | import edu.wpi.first.wpilibj.IterativeRobot; |
| 11 | import edu.wpi.first.wpilibj.command.Scheduler; |
| 12 | import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; |
| 13 | import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; |
| 14 | |
| 15 | public class Robot extends IterativeRobot { |
| 16 | public static OI oi; |
| 17 | public static DriveTrain driveTrain; |
| 18 | public static Shooter shooter; |
| 19 | |
| 20 | public static Scaler scaler; |
| 21 | |
| 22 | public static IntakeArm intakeArm; |
| 23 | public static DefenseArm defenseArm; |
| 24 | |
| 25 | // Sendable Choosers send a drop down menu to the Smart Dashboard. |
| 26 | SendableChooser positionChooser; |
| 27 | SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense, |
| 28 | positionFourDefense, positionFiveDefense; |
| 29 | |
| 30 | @Override |
| 31 | public void robotInit() { |
| 32 | driveTrain = new DriveTrain(); |
| 33 | oi = new OI(); |
| 34 | |
| 35 | shooter = new Shooter(); |
| 36 | |
| 37 | // shooter = new Shooter(); |
| 38 | // scaler = new Scaler(); |
| 39 | // intakeArm = new IntakeArm(); |
| 40 | // |
| 41 | // initializeSendableChoosers(); |
| 42 | // addPositionChooserOptions(); |
| 43 | // addDefensesToAllDefenseSendableChoosers(); |
| 44 | // sendSendableChoosersToSmartDashboard(); |
| 45 | |
| 46 | } |
| 47 | |
| 48 | private void initializeSendableChoosers() { |
| 49 | positionChooser = new SendableChooser(); |
| 50 | positionOneDefense = new SendableChooser(); |
| 51 | positionTwoDefense = new SendableChooser(); |
| 52 | positionThreeDefense = new SendableChooser(); |
| 53 | positionFourDefense = new SendableChooser(); |
| 54 | positionFiveDefense = new SendableChooser(); |
| 55 | } |
| 56 | |
| 57 | private void addPositionChooserOptions() { |
| 58 | positionChooser.addDefault("Position 1", 1); |
| 59 | positionChooser.addObject("Position 2", 2); |
| 60 | positionChooser.addObject("Position 3", 3); |
| 61 | positionChooser.addObject("Position 4", 4); |
| 62 | positionChooser.addObject("Position 5", 5); |
| 63 | } |
| 64 | |
| 65 | private void addDefensesToAllDefenseSendableChoosers() { |
| 66 | addDefenseOptions(positionOneDefense); |
| 67 | addDefenseOptions(positionTwoDefense); |
| 68 | addDefenseOptions(positionThreeDefense); |
| 69 | addDefenseOptions(positionFourDefense); |
| 70 | addDefenseOptions(positionFiveDefense); |
| 71 | } |
| 72 | |
| 73 | private void addDefenseOptions(SendableChooser chooser) { |
| 74 | chooser.addDefault("Portcullis", Defense.PORTCULLIS); |
| 75 | chooser.addObject("Sally Port", Defense.SALLY_PORT); |
| 76 | chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN); |
| 77 | chooser.addObject("Low Bar", Defense.LOW_BAR); |
| 78 | chooser.addObject("Cheval De Frise", Defense.CHEVAL_DE_FRISE); |
| 79 | chooser.addObject("Drawbridge", Defense.DRAWBRIDGE); |
| 80 | chooser.addObject("Moat", Defense.MOAT); |
| 81 | chooser.addObject("Rock Wall", Defense.ROCK_WALL); |
| 82 | } |
| 83 | |
| 84 | private void sendSendableChoosersToSmartDashboard() { |
| 85 | SmartDashboard.putData("PositionChooser", positionChooser); |
| 86 | SmartDashboard.putData("Position One Defense Chooser", positionOneDefense); |
| 87 | SmartDashboard.putData("Position Two Defense Chooser", positionTwoDefense); |
| 88 | SmartDashboard.putData("Position Three Defense Chooser", |
| 89 | positionThreeDefense); |
| 90 | SmartDashboard |
| 91 | .putData("Position Four Defense Chooser", positionFourDefense); |
| 92 | SmartDashboard |
| 93 | .putData("Position Five Defense Chooser", positionFiveDefense); |
| 94 | |
| 95 | SmartDashboard |
| 96 | .putData("Position Four Defense Chooser", positionFourDefense); |
| 97 | SmartDashboard |
| 98 | .putData("Position Five Defense Chooser", positionFiveDefense); |
| 99 | |
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public void autonomousInit() { |
| 104 | Scheduler.getInstance().run(); |
| 105 | |
| 106 | // Scheduler.getInstance().add(new DriveDistance(24, 5)); |
| 107 | // Scheduler.getInstance().add(new DriveForTime(2, 0.3)); |
| 108 | // Scheduler.getInstance().add(new TurnForAngle(90, 5)); |
| 109 | // Scheduler.getInstance().add( |
| 110 | // new TurnForTime(3, Constants.Direction.RIGHT, 0.3)); |
| 111 | // Scheduler.getInstance().add( |
| 112 | // new TurnForTime(3, Constants.Direction.LEFT, 0.3)); |
| 113 | // Scheduler.getInstance().add(new Turn180()); |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public void autonomousPeriodic() { |
| 118 | Scheduler.getInstance().run(); |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | public void teleopInit() { |
| 123 | Robot.driveTrain.setLowGear(); |
| 124 | Robot.shooter.raiseHood(); |
| 125 | } |
| 126 | |
| 127 | @Override |
| 128 | public void teleopPeriodic() { |
| 129 | Scheduler.getInstance().run(); |
| 130 | if (OI.rightJoystick.getTrigger()) { |
| 131 | Robot.shooter.setSpeed(.8); |
| 132 | } else { |
| 133 | Robot.shooter.setSpeed(0); |
| 134 | } |
| 135 | if (OI.rightJoystick.getRawButton(2)) { |
| 136 | Robot.shooter.extendPunch(); |
| 137 | } else { |
| 138 | Robot.shooter.retractPunch(); |
| 139 | |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | } |