Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import frc.robot.constants.AlignmentPosition;
import frc.robot.constants.Constants;
import frc.robot.subsystems.lightStrip.LightStrip;
import frc.robot.subsystems.swervev3.SwerveDrivetrain;
import frc.robot.utils.BlinkinPattern;
import frc.robot.utils.logging.commands.LoggableCommand;
import frc.robot.utils.logging.commands.LoggableCommandWrapper;
import org.littletonrobotics.junction.Logger;

public class AlignClosestBranch extends LoggableCommand {
private AlignmentPosition alignmentTarget;
private final SwerveDrivetrain drivetrain;
private final LightStrip light;
private LoggableCommand followTrajectory;
private final Timer timer = new Timer();

public AlignClosestBranch(SwerveDrivetrain drivetrain) {
public AlignClosestBranch(SwerveDrivetrain drivetrain, LightStrip lightStrip) {
this.drivetrain = drivetrain;
addRequirements(drivetrain);
this.light = lightStrip;
addRequirements(drivetrain, lightStrip);
}

@Override
Expand Down Expand Up @@ -46,6 +50,14 @@ public void end(boolean interrupted) {

@Override
public boolean isFinished() {
return followTrajectory.isFinished() || timer.hasElapsed(Constants.AUTO_ALIGN_TIMEOUT);
if (followTrajectory.isFinished()) {
light.setPattern(BlinkinPattern.LAWN_GREEN);
return true;
} else if (timer.hasElapsed(Constants.AUTO_ALIGN_TIMEOUT)) {
light.setPattern(BlinkinPattern.HEARTBEAT_RED);
return true;
} else {
return false;
}
}
}