Skip to content

Commit

Permalink
[#479] - made a command for it
Browse files Browse the repository at this point in the history
  • Loading branch information
HeeistHo committed Mar 26, 2024
1 parent a3673a6 commit dce9461
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,10 @@ public class CandConstants { // TODO get real
public static final double SOURCE_RPM = -300d; // TODO test
public static final double SOURCE_ANGLE = 90d; // TODO test

// Pass
public static final double NOTE_PASS_ANGLE = 0d;
public static final double NOTE_PASS_RPM = 0d;

// TODO find time to shoot
public static final double TIME_TO_SHOOT = 1d; // Time in seconds it takes from indexer start to flywheel exit
}
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/frc/robot/command/shoot/NotePass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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.command.shoot;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.RobotContainer;
import frc.robot.Constants.CandConstants;
import frc.robot.subsystems.Flywheel;
import frc.robot.subsystems.Pivot;
import frc.thunder.command.TimedCommand;

public class NotePass extends Command {
private final Flywheel flywheel;
private final Pivot pivot;

/**
* Creates a new NotePass.
*
* @param pivot subsystem
* @param flywheel subsystem
*/
public NotePass(Flywheel flywheel, Pivot pivot) {
this.flywheel = flywheel;
this.pivot = pivot;

addRequirements(flywheel, pivot);
}

@Override
public void initialize() {
flywheel.setAllMotorsRPM(CandConstants.NOTE_PASS_RPM + flywheel.getBias());
pivot.setTargetAngle(CandConstants.NOTE_PASS_ANGLE + pivot.getBias());
}

@Override
public void execute() {
flywheel.setAllMotorsRPM(CandConstants.NOTE_PASS_RPM + pivot.getBias());
pivot.setTargetAngle(CandConstants.NOTE_PASS_ANGLE + flywheel.getBias());
if(flywheel.allMotorsOnTarget() && pivot.onTarget()) {
new TimedCommand(RobotContainer.hapticCopilotCommand(), 1d).schedule();
}
}

@Override
public void end(boolean interrupted) {
flywheel.coast(true);
pivot.setTargetAngle(pivot.getStowAngle());
}

@Override
public boolean isFinished() {
return false;
}
}

0 comments on commit dce9461

Please sign in to comment.