Skip to content

Commit

Permalink
Add safety to prevent note come down from AMP
Browse files Browse the repository at this point in the history
  • Loading branch information
gvaldez7206 committed Sep 28, 2024
1 parent 32e26cd commit f3dde51
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ private void configureButtonBindings() {
operator.rightTrigger().and(operator.leftTrigger()).whileTrue(intake.runIndexerMotor(1));
// set shooter to home preset position
operator.y().onTrue(elevatorWrist.homePosition());
operator.y().and(elevatorWrist.elevatorAtAmp).and(noteInIndexer)
.onTrue(intake.runIntakeMotorNonStop(0, -0.2).withTimeout(2.0)
.until(new Trigger(() -> !this.intake.getIndexerBeamBrakeStatus()).debounce(.5)));

// increment once through states list to next state
operator.povRight().onTrue(Commands.runOnce(() -> {
OperatorState.increment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.lib.util.FieldConstants;
import frc.robot.Constants;
import frc.robot.OperatorState;
Expand Down Expand Up @@ -69,6 +70,8 @@ public class ElevatorWrist extends SubsystemBase {

private double estimatedWristAngle = 0;

public Trigger elevatorAtAmp = new Trigger(() -> elevatorAtAmp());

/**
* Create new ElevatorWrist.
*/
Expand Down Expand Up @@ -392,4 +395,14 @@ public boolean elevatorAtHome() {
3);
}

/**
* Check if the elevator is at the AMP position
*
* @return True if the elevator is AMP
*/
public boolean elevatorAtAmp() {
return MathUtil.isNear(Constants.ElevatorWristConstants.SetPoints.AMP_HEIGHT, getHeight(),
3);
}

}

0 comments on commit f3dde51

Please sign in to comment.