-
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.
feat: clean up staging and shoot commands
- Loading branch information
Showing
9 changed files
with
145 additions
and
49 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
32 changes: 0 additions & 32 deletions
32
src/main/java/org/team1540/robot2024/commands/TrampCommand.java
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
src/main/java/org/team1540/robot2024/commands/indexer/StageTrampCommand.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,35 @@ | ||
package org.team1540.robot2024.commands.indexer; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import org.team1540.robot2024.subsystems.indexer.Indexer; | ||
import org.team1540.robot2024.subsystems.tramp.Tramp; | ||
|
||
public class StageTrampCommand extends Command { | ||
|
||
private final Tramp tramp; | ||
private final Indexer indexer; | ||
|
||
public StageTrampCommand(Tramp tramp, Indexer indexer) { | ||
this.tramp = tramp; | ||
this.indexer = indexer; | ||
addRequirements(tramp, indexer); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
tramp.setPercent(0.5); | ||
indexer.setFeederVelocity(-600); | ||
indexer.setIntakePercent(0.5); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return tramp.isBeamBreakBlocked(); | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
indexer.stopFeeder(); | ||
tramp.stop(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/team1540/robot2024/commands/shooter/PrepareShooterCommand.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,25 @@ | ||
package org.team1540.robot2024.commands.shooter; | ||
|
||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import org.team1540.robot2024.subsystems.shooter.Shooter; | ||
|
||
class PrepareShooterCommand extends Command { | ||
private final Shooter shooter; | ||
|
||
public PrepareShooterCommand(Shooter shooter) { | ||
this.shooter = shooter; | ||
addRequirements(shooter); | ||
} | ||
@Override | ||
public void execute() { | ||
// TODO: Make this dynamically update based on estimated pose | ||
shooter.setFlywheelSpeeds(1000, 1000); | ||
shooter.setPivotPosition(Rotation2d.fromDegrees(30)); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return shooter.areFlywheelsSpunUp() && shooter.isPivotAtSetpoint(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/team1540/robot2024/commands/shooter/ShootSequence.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,26 @@ | ||
package org.team1540.robot2024.commands.shooter; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.Commands; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import org.team1540.robot2024.subsystems.indexer.Indexer; | ||
import org.team1540.robot2024.subsystems.shooter.Shooter; | ||
|
||
public class ShootSequence extends SequentialCommandGroup { | ||
public ShootSequence(Shooter shooter, Indexer indexer) { | ||
addCommands( | ||
Commands.parallel( | ||
indexer.feedToShooter(), | ||
new PrepareShooterCommand(shooter) | ||
), | ||
Commands.runOnce(() -> indexer.setIntakePercent(1), indexer) | ||
// TODO: Add a wait for having completed the shot (steady then current spike/velocity dip and then back down?) | ||
); | ||
} | ||
|
||
|
||
@Override | ||
public InterruptionBehavior getInterruptionBehavior() { | ||
return InterruptionBehavior.kCancelIncoming; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/team1540/robot2024/commands/shooter/TuneShooterCommand.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,28 @@ | ||
package org.team1540.robot2024.commands.shooter; | ||
|
||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import org.littletonrobotics.junction.networktables.LoggedDashboardNumber; | ||
import org.team1540.robot2024.subsystems.shooter.Shooter; | ||
|
||
public class TuneShooterCommand extends Command { | ||
private final LoggedDashboardNumber leftFlywheelSetpoint = new LoggedDashboardNumber("Shooter/Flywheels/leftSetpoint", 6000); | ||
private final LoggedDashboardNumber rightFlywheelSetpoint = new LoggedDashboardNumber("Shooter/Flywheels/rightSetpoint", 6000); | ||
private final LoggedDashboardNumber angleSetpoint = new LoggedDashboardNumber("Shooter/Pivot/angleSetpoint", 30); | ||
private final Shooter shooter; | ||
|
||
public TuneShooterCommand(Shooter shooter) { | ||
this.shooter = shooter; | ||
addRequirements(shooter); | ||
} | ||
|
||
public void execute() { | ||
shooter.setFlywheelSpeeds(leftFlywheelSetpoint.get(), rightFlywheelSetpoint.get()); | ||
shooter.setPivotPosition(Rotation2d.fromDegrees(angleSetpoint.get())); | ||
} | ||
|
||
public void end() { | ||
shooter.stopFlywheels(); | ||
shooter.stopPivot(); | ||
} | ||
} |
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