Skip to content

Commit

Permalink
Add button to execute a one-shot atGoal override, bypassing positiona…
Browse files Browse the repository at this point in the history
…l loop goal checking (useful if a mechanism is close but not at setpoint because of damage)
  • Loading branch information
superpenguin612 committed Mar 19, 2024
1 parent 6dfb69f commit 3285bca
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/subsystems/Climber.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,8 @@ public Command zeroMechanismCommand() {
}).until(() -> motor.getOutputCurrent() > 10)
.andThen(resetPositionCommand());
}

public boolean atGoal() {
return pidController.atGoal() || GlobalStates.AT_GOAL_OVERRIDE.enabled();
}
}
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/subsystems/Intake.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,8 @@ public Command zeroMechanismCommand() {
.until(() -> (leftArmMotor.getOutputCurrent() > 20) && (rightArmMotor.getOutputCurrent() > 20))
.andThen(resetPositionCommand());
}

public boolean atGoal() {
return pidController.atGoal() || GlobalStates.AT_GOAL_OVERRIDE.enabled();
}
}
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/subsystems/NoteLift.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,8 @@ public Command zeroMechanismCommand() {
}).until(() -> motor.getOutputCurrent() > 10)
.andThen(resetPositionCommand());
}

public boolean atGoal() {
return pidController.atGoal() || GlobalStates.AT_GOAL_OVERRIDE.enabled();
}
}
12 changes: 7 additions & 5 deletions src/main/java/frc/robot/subsystems/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
import frc.robot.FieldConstants;
import frc.robot.GlobalStates;

@LoggedObject
public class Shooter extends SubsystemBase implements BaseShooter {
Expand Down Expand Up @@ -254,12 +255,13 @@ public Command sysIdDynamic(SysIdRoutine.Direction direction) {
return sysIdRoutine.dynamic(direction).withName("shooter.sysIdDynamic");
}

@Log
public boolean atGoal() {
return leftPidController.atSetpoint() && rightPidController.atSetpoint();
}

public Command stopCommand() {
return run(this::stop);
}

@Log
public boolean atGoal() {
return leftPidController.atSetpoint() && rightPidController.atSetpoint()
|| GlobalStates.AT_GOAL_OVERRIDE.enabled();
}
}
6 changes: 4 additions & 2 deletions src/main/java/frc/robot/subsystems/ShooterTilt.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ public Command sysIdDynamic(SysIdRoutine.Direction direction) {

@Log
public boolean atGoal() {
return pidController.atSetpoint()
return (pidController.atSetpoint()
&& Math.abs(pidController.getGoal().position - pidController.getSetpoint().position) <= TOLERANCE
&& !beyondMaxDistance;
&& !beyondMaxDistance)

|| GlobalStates.AT_GOAL_OVERRIDE.enabled();
}

public Command resetControllersCommand() {
Expand Down

0 comments on commit 3285bca

Please sign in to comment.