Skip to content

Commit

Permalink
factor: moved FunctionalCommand to an indexer method
Browse files Browse the repository at this point in the history
  • Loading branch information
AdleyJ committed Feb 7, 2024
1 parent 95fbd9f commit ed529d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.team1540.robot2024.commands.shooter;

import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.FunctionalCommand;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import org.team1540.robot2024.commands.indexer.PrepareFeederForShooter;
import org.team1540.robot2024.subsystems.indexer.Indexer;
Expand All @@ -13,13 +12,7 @@ public ShootSequence(Shooter shooter, Indexer indexer) {
Commands.parallel(
new PrepareShooterCommand(shooter),
Commands.sequence(
new FunctionalCommand(
() -> indexer.setIntakePercent(-1),
() -> {},
(interrupted) -> indexer.stopIntake(),
() -> !indexer.isNoteStaged(),
indexer
),
indexer.moveNoteOut(),
new PrepareFeederForShooter(indexer)
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.FunctionalCommand;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import org.littletonrobotics.junction.Logger;
import org.team1540.robot2024.Constants;
Expand Down Expand Up @@ -51,7 +52,16 @@ public Command feedToAmp() {
public Command feedToShooter() {
return Commands.runOnce(() -> io.setFeederVelocity(1200), this);
}


public Command moveNoteOut() {
return new FunctionalCommand(
() -> setIntakePercent(-1),
() -> {},
(interrupted) -> stopIntake(),
() -> !isNoteStaged(),
this
);
}
public boolean isFeederAtSetpoint() {
return Math.abs(inputs.feederVelocityError) < VELOCITY_ERR_TOLERANCE_RPM;
// return MathUtil.isNear(inputs.setpointRPM, inputs.feederVelocityRPM, VELOCITY_ERR_TOLERANCE_RPM);
Expand Down

0 comments on commit ed529d0

Please sign in to comment.