From edae343a917a33a7538f7543d91d20a27bbba931 Mon Sep 17 00:00:00 2001 From: Vihaan Date: Wed, 26 Feb 2025 20:49:17 -0600 Subject: [PATCH] Made it so that shooter won't shoot when under a certain value. Current value is 10, value is not accurate change later. --- src/main/java/team/gif/robot/Constants.java | 2 +- src/main/java/team/gif/robot/commands/shooter/Shoot.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/team/gif/robot/Constants.java b/src/main/java/team/gif/robot/Constants.java index f5f7c9a..9830b0a 100644 --- a/src/main/java/team/gif/robot/Constants.java +++ b/src/main/java/team/gif/robot/Constants.java @@ -267,7 +267,7 @@ public static final class Elevator{ public static final double ZERO_OFFSET_TICKS = 1; public static final double MAX_POS = 61; public static final double MIN_POS = 0; - + public static final double ELEVATOR_POS_SHOOT_REQ = 10; // Motion Magic public static final double ELEVATOR_KP = 4.0; // 4 worked, 3 too low, 8 groaned public static final double ELEVATOR_KI = 0; diff --git a/src/main/java/team/gif/robot/commands/shooter/Shoot.java b/src/main/java/team/gif/robot/commands/shooter/Shoot.java index b3d6f61..3e9d38d 100644 --- a/src/main/java/team/gif/robot/commands/shooter/Shoot.java +++ b/src/main/java/team/gif/robot/commands/shooter/Shoot.java @@ -1,6 +1,7 @@ package team.gif.robot.commands.shooter; import edu.wpi.first.wpilibj2.command.Command; +import team.gif.robot.Constants; import team.gif.robot.Robot; public class Shoot extends Command { @@ -24,14 +25,18 @@ public void initialize() { // Called every time the scheduler runs (~20ms) while the command is scheduled @Override public void execute() { - Robot.shooter.runShooterMotor(); + if (Robot.elevator.getPosition() > Constants.Elevator.ELEVATOR_POS_SHOOT_REQ) { + return; + } + counter++; + Robot.shooter.runShooterMotor(); } // Return true when the command should end, false if it should continue. Runs every ~20ms. @Override public boolean isFinished() { - return counter > 12; + return counter > 12 || Robot.elevator.getPosition() < 10; } // Called when the command ends or is interrupted.