|
| 1 | +package frc.robot.commands.auton; |
| 2 | + |
| 3 | +import edu.wpi.first.wpilibj.DriverStation.Alliance; |
| 4 | +import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; |
| 5 | +import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; |
| 6 | +import frc.robot.commands.auto.SetHoloContKPCommand; |
| 7 | +import frc.robot.commands.drive.DriveAutonCommand; |
| 8 | +import frc.robot.commands.drive.ResetGyroCommand; |
| 9 | +import frc.robot.commands.drive.setAngleOffsetCommand; |
| 10 | +import frc.robot.commands.elbow.ZeroElbowCommand; |
| 11 | +import frc.robot.commands.robotState.SubWooferCommand; |
| 12 | +import frc.robot.commands.superStructure.SpinUpWheelsCommand; |
| 13 | +import frc.robot.constants.SuperStructureConstants; |
| 14 | +import frc.robot.subsystems.auto.AutoCommandInterface; |
| 15 | +import frc.robot.subsystems.drive.DriveSubsystem; |
| 16 | +import frc.robot.subsystems.elbow.ElbowSubsystem; |
| 17 | +import frc.robot.subsystems.intake.IntakeSubsystem; |
| 18 | +import frc.robot.subsystems.led.LedSubsystem; |
| 19 | +import frc.robot.subsystems.magazine.MagazineSubsystem; |
| 20 | +import frc.robot.subsystems.robotState.RobotStateSubsystem; |
| 21 | +import frc.robot.subsystems.superStructure.SuperStructure; |
| 22 | +import frc.robot.subsystems.vision.DeadEyeSubsystem; |
| 23 | + |
| 24 | +public class FallBack4PieceCommand extends SequentialCommandGroup implements AutoCommandInterface { |
| 25 | + |
| 26 | + private DriveAutonCommand midInitWingNote3; |
| 27 | + private DriveAutonCommand wingNote3MidInit; |
| 28 | + private DriveAutonCommand midInitWingNote2; |
| 29 | + private DriveAutonCommand wingNote2MidInit; |
| 30 | + private DriveAutonCommand midInitWingNote1; |
| 31 | + private DriveAutonCommand wingNote1MidInit; |
| 32 | + private boolean hasGenerated = false; |
| 33 | + private Alliance alliance = Alliance.Blue; |
| 34 | + private RobotStateSubsystem robotStateSubsystem; |
| 35 | + private ElbowSubsystem elbowSubsystem; |
| 36 | + private DeadEyeSubsystem deadeye; |
| 37 | + |
| 38 | + public FallBack4PieceCommand( |
| 39 | + DriveSubsystem driveSubsystem, |
| 40 | + RobotStateSubsystem robotStateSubsystem, |
| 41 | + SuperStructure superStructure, |
| 42 | + MagazineSubsystem magazineSubsystem, |
| 43 | + IntakeSubsystem intakeSubsystem, |
| 44 | + ElbowSubsystem elbowSubsystem, |
| 45 | + DeadEyeSubsystem deadeye, |
| 46 | + LedSubsystem ledSubsystem) { |
| 47 | + this.robotStateSubsystem = robotStateSubsystem; |
| 48 | + this.elbowSubsystem = elbowSubsystem; |
| 49 | + this.deadeye = deadeye; |
| 50 | + |
| 51 | + midInitWingNote3 = |
| 52 | + new DriveAutonCommand(driveSubsystem, "MiddleInitial1_WingNote3", true, true); |
| 53 | + wingNote3MidInit = |
| 54 | + new DriveAutonCommand(driveSubsystem, "WingNote3_MiddleInitial1", true, false); |
| 55 | + midInitWingNote2 = |
| 56 | + new DriveAutonCommand(driveSubsystem, "MiddleInitial1_WingNote2", true, false); |
| 57 | + |
| 58 | + wingNote2MidInit = |
| 59 | + new DriveAutonCommand(driveSubsystem, "WingNote2_MiddleInitial1", true, false); |
| 60 | + midInitWingNote1 = |
| 61 | + new DriveAutonCommand(driveSubsystem, "MiddleInitial1_WingNote1", true, false); |
| 62 | + wingNote1MidInit = |
| 63 | + new DriveAutonCommand(driveSubsystem, "WingNote1_MiddleInitial1", true, false); |
| 64 | + |
| 65 | + addCommands( |
| 66 | + new ResetGyroCommand(driveSubsystem), |
| 67 | + new ParallelCommandGroup( |
| 68 | + new SpinUpWheelsCommand( |
| 69 | + superStructure, |
| 70 | + SuperStructureConstants.kShooterSubwooferSetPoint, |
| 71 | + SuperStructureConstants.kShooterSubwooferSetPoint), |
| 72 | + new setAngleOffsetCommand(driveSubsystem, 0.0), |
| 73 | + new SetHoloContKPCommand(driveSubsystem, 1.0), |
| 74 | + new ZeroElbowCommand(elbowSubsystem)), |
| 75 | + new SubWooferCommand(robotStateSubsystem, superStructure, magazineSubsystem), |
| 76 | + midInitWingNote3, |
| 77 | + // new WaitCommand(0.05), |
| 78 | + // new AutoWaitNoteStagedCommand(robotStateSubsystem), |
| 79 | + |
| 80 | + wingNote3MidInit, |
| 81 | + new SubWooferCommand(robotStateSubsystem, superStructure, magazineSubsystem), |
| 82 | + midInitWingNote2, |
| 83 | + wingNote2MidInit, |
| 84 | + // new WaitCommand(0.05), |
| 85 | + new AutoWaitNoteStagedCommand(robotStateSubsystem), |
| 86 | + new SubWooferCommand(robotStateSubsystem, superStructure, magazineSubsystem), |
| 87 | + midInitWingNote1, |
| 88 | + wingNote1MidInit, |
| 89 | + new ParallelCommandGroup( |
| 90 | + // new WaitCommand(0.05), |
| 91 | + new SequentialCommandGroup( |
| 92 | + new AutoWaitNoteStagedCommand(robotStateSubsystem), |
| 93 | + new SpinUpWheelsCommand( |
| 94 | + superStructure, |
| 95 | + SuperStructureConstants.kShooterSubwooferSetPoint, |
| 96 | + SuperStructureConstants.kShooterSubwooferSetPoint))), |
| 97 | + new SubWooferCommand(robotStateSubsystem, superStructure, magazineSubsystem)); |
| 98 | + } |
| 99 | + |
| 100 | + public void generateTrajectory() { |
| 101 | + midInitWingNote3.generateTrajectory(); |
| 102 | + wingNote3MidInit.generateTrajectory(); |
| 103 | + midInitWingNote2.generateTrajectory(); |
| 104 | + wingNote2MidInit.generateTrajectory(); |
| 105 | + midInitWingNote1.generateTrajectory(); |
| 106 | + wingNote1MidInit.generateTrajectory(); |
| 107 | + hasGenerated = true; |
| 108 | + alliance = robotStateSubsystem.getAllianceColor(); |
| 109 | + } |
| 110 | + |
| 111 | + public boolean hasGenerated() { |
| 112 | + return hasGenerated && (alliance == robotStateSubsystem.getAllianceColor()); |
| 113 | + } |
| 114 | +} |
0 commit comments