This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/KHS-Robotics/Demonator13
- Loading branch information
Showing
10 changed files
with
217 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package frc.robot; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import edu.wpi.first.wpilibj2.command.WaitCommand; | ||
import frc.robot.commands.arm.SetArmState; | ||
import frc.robot.commands.arm.WaitForArmStow; | ||
import frc.robot.commands.intake.SetIntakeState; | ||
import frc.robot.commands.shooter.SetShooterState; | ||
import frc.robot.subsystems.Arm.ArmState; | ||
import frc.robot.subsystems.Intake.IntakeState; | ||
import frc.robot.subsystems.Shooter.ShooterState; | ||
|
||
public class StateCommandGenerator { | ||
public static Command goToStowCommand() { | ||
if (RobotContainer.arm.getPosition() > ArmState.kShoot.rotations + 0.02) { | ||
// arm down | ||
// move arm then move intake | ||
return new SequentialCommandGroup(new SetArmState(ArmState.kStow), new SetIntakeState(IntakeState.kUp)); | ||
} else { | ||
// arm up | ||
// move arm and intake together | ||
return new ParallelCommandGroup(new SetArmState(ArmState.kStow), new SetIntakeState(IntakeState.kUp)); | ||
} | ||
} | ||
|
||
public static Command goToAmpCommand() { | ||
if (RobotContainer.arm.getPosition() < ArmState.kShoot.rotations + 0.02) { | ||
// arm up | ||
// move arm and intake together | ||
return new ParallelCommandGroup(new SetIntakeState(IntakeState.kUp), new SetArmState(ArmState.kAmp)); | ||
} else { | ||
// arm down | ||
// move arm then move intake | ||
return new ParallelCommandGroup(new SetArmState(ArmState.kAmp), new SequentialCommandGroup(new WaitForArmStow(), new SetIntakeState(IntakeState.kUp))); | ||
} | ||
} | ||
|
||
public static Command goToFlatCommand() { | ||
if (RobotContainer.intake.isIntakeUp()) { | ||
// intake up | ||
// move arm flat | ||
return new ParallelCommandGroup(new SetArmState(ArmState.kShoot), new SetShooterState(ShooterState.kShootFromPodium)); | ||
} else if (RobotContainer.arm.getPosition() < ArmState.kStow.rotations + 0.02) { | ||
// intake down and arm down | ||
// move arm to stow move intake up move arm to flat | ||
return new ParallelCommandGroup(new SetArmState(ArmState.kStow), new SequentialCommandGroup(new WaitForArmStow(), new SetIntakeState(IntakeState.kUp), new SetArmState(ArmState.kShoot)), new SetShooterState(ShooterState.kShootFromPodium)); | ||
} else { | ||
// intake down and arm up | ||
// | ||
return new ParallelCommandGroup(new SequentialCommandGroup(new ParallelCommandGroup(new SetArmState(ArmState.kStow), new SetIntakeState(IntakeState.kUp)), new SetArmState(ArmState.kShoot)), new SetShooterState(ShooterState.kShootFromPodium)); | ||
} | ||
|
||
} | ||
|
||
public static Command goToHandoffCommand() { | ||
if (RobotContainer.arm.getPosition() < ArmState.kStow.rotations + 0.2) { | ||
// intake up | ||
// move intake then move | ||
return new SequentialCommandGroup(new SetIntakeState(IntakeState.kDown), new ParallelCommandGroup(new SetArmState(ArmState.kIntake), new SetShooterState(ShooterState.kIntake))); | ||
} else if (RobotContainer.arm.isAtState(ArmState.kShootFromPodium)) { | ||
// arm flat | ||
// move arm up and intake down together, then arm down and shooter down together | ||
return new SequentialCommandGroup(new ParallelCommandGroup(new SetArmState(ArmState.kStow), new SequentialCommandGroup(new WaitCommand(0.1), new SetIntakeState(IntakeState.kDown))), new ParallelCommandGroup(new SetArmState(ArmState.kIntake), new SetShooterState(ShooterState.kIntake))); | ||
} else { | ||
// arm down | ||
// move arm and shooter together | ||
return new ParallelCommandGroup(new SetArmState(ArmState.kIntake), new SetShooterState(ShooterState.kIntake)); | ||
} | ||
} | ||
|
||
public static Command goToSubwooferCommand() { | ||
if (RobotContainer.arm.getPosition() < ArmState.kStow.rotations + 0.2) { | ||
// intake up | ||
// move intake then move | ||
return new SequentialCommandGroup(new SetIntakeState(IntakeState.kDown), new ParallelCommandGroup(new SetArmState(ArmState.kShootFromSubwoofer), new SetShooterState(ShooterState.kShootFromSubwoofer))); | ||
} else if (RobotContainer.arm.isAtState(ArmState.kShootFromPodium)) { | ||
// arm flat | ||
// move arm up and intake down together, then arm down and shooter down together | ||
return new SequentialCommandGroup(new ParallelCommandGroup(new SetArmState(ArmState.kStow), new SequentialCommandGroup(new WaitCommand(0.1), new SetIntakeState(IntakeState.kDown))), new ParallelCommandGroup(new SetArmState(ArmState.kShootFromSubwoofer), new SetShooterState(ShooterState.kShootFromSubwoofer))); | ||
} else { | ||
// arm down | ||
// move arm and shooter together | ||
return new ParallelCommandGroup(new SetArmState(ArmState.kShootFromSubwoofer), new SetShooterState(ShooterState.kShootFromSubwoofer)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands.arm; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.RobotContainer; | ||
import frc.robot.subsystems.Arm.ArmState; | ||
|
||
public class WaitForArmStow extends Command { | ||
/** Creates a new WaitForArmStow. */ | ||
public WaitForArmStow() { | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() {} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() {} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) {} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return Math.abs(RobotContainer.arm.getPosition() - ArmState.kStow.rotations) < 0.05; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/frc/robot/commands/intake/WaitForIntakeUp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands.intake; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.RobotContainer; | ||
|
||
public class WaitForIntakeUp extends Command { | ||
/** Creates a new WaitForIntakeUp. */ | ||
public WaitForIntakeUp() { | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() {} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() {} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) {} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return RobotContainer.intake.isIntakeUp(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters