From c876483a0ba6ae9ad5b527274c1ff4388e8a8c1f Mon Sep 17 00:00:00 2001 From: Niosocket11 Date: Fri, 20 Mar 2026 15:31:24 -0700 Subject: [PATCH 1/2] Fixed another issue --- .../ManipulatorCommands/SmartShoot.java | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/carlmontrobotics/commands/ManipulatorCommands/SmartShoot.java b/src/main/java/org/carlmontrobotics/commands/ManipulatorCommands/SmartShoot.java index 73a0927..f9af1db 100644 --- a/src/main/java/org/carlmontrobotics/commands/ManipulatorCommands/SmartShoot.java +++ b/src/main/java/org/carlmontrobotics/commands/ManipulatorCommands/SmartShoot.java @@ -10,6 +10,7 @@ import org.carlmontrobotics.subsystems.Intake; import org.carlmontrobotics.subsystems.Outtake; +import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; @@ -20,6 +21,10 @@ public class SmartShoot extends Command { Outtake outtake; Intake intake; double goalRPM; + double oscillateTimeStampForward = -1; + double oscillateTimeStampBackward = -1; + + private final boolean oscillate = true; /** Creates a new SmartShoot. */ public SmartShoot(Outtake outtake, Intake intake, double RPM) { // Use addRequirements() here to declare subsystem dependencies. @@ -27,22 +32,36 @@ public SmartShoot(Outtake outtake, Intake intake, double RPM) { this.outtake = outtake; this.intake = intake; addRequirements(outtake, intake); - SmartDashboard.putNumber("GoalRPMOuttake", goalRPM); - } // Called when the command is initially scheduled. @Override public void initialize() { - outtake.spinOuttake(SmartDashboard.getNumber("GoalRPMOuttake", goalRPM)); + outtake.spinOuttake(goalRPM); } // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(outtake.atVelGoal(SmartDashboard.getNumber("GoalRPMOuttake", goalRPM), OUTTAKE_ESTIMATE_OFFSET)){ + if(outtake.atVelGoal(goalRPM, OUTTAKE_ESTIMATE_OFFSET)){ outtake.spinOuttakeFeeder(OUTTAKE_FEEDER_VOLT_PERC); - intake.spinConveyor(CONVEYOR_SPEED); + if (oscillate) { + if (oscillateTimeStampForward == -1) { + oscillateTimeStampForward = Timer.getFPGATimestamp(); + intake.spinConveyor(CONVEYOR_SPEED); + } + else if (Timer.getFPGATimestamp() - oscillateTimeStampForward > 5) { + oscillateTimeStampBackward = Timer.getFPGATimestamp(); + intake.spinConveyor(-0.2); + } + else if (Timer.getFPGATimestamp() - oscillateTimeStampBackward > 2) { + oscillateTimeStampForward = Timer.getFPGATimestamp(); + intake.spinConveyor(CONVEYOR_SPEED); + } + } + else { + intake.spinConveyor(CONVEYOR_SPEED); + } } } From 2c4777f9a778a708b6e73aa6a93c014787798554 Mon Sep 17 00:00:00 2001 From: Niosocket11 Date: Fri, 20 Mar 2026 21:55:09 -0700 Subject: [PATCH 2/2] fixed tims thingy that tim really wanted --- .../ManipulatorCommands/SmartShoot.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/carlmontrobotics/commands/ManipulatorCommands/SmartShoot.java b/src/main/java/org/carlmontrobotics/commands/ManipulatorCommands/SmartShoot.java index f9af1db..9a3a67e 100644 --- a/src/main/java/org/carlmontrobotics/commands/ManipulatorCommands/SmartShoot.java +++ b/src/main/java/org/carlmontrobotics/commands/ManipulatorCommands/SmartShoot.java @@ -18,11 +18,10 @@ /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ public class SmartShoot extends Command { - Outtake outtake; - Intake intake; - double goalRPM; - double oscillateTimeStampForward = -1; - double oscillateTimeStampBackward = -1; + private final Outtake outtake; + private final Intake intake; + private final double goalRPM; + private final Timer timer; private final boolean oscillate = true; /** Creates a new SmartShoot. */ @@ -31,6 +30,7 @@ public SmartShoot(Outtake outtake, Intake intake, double RPM) { goalRPM = RPM; this.outtake = outtake; this.intake = intake; + timer = new Timer(); addRequirements(outtake, intake); } @@ -38,6 +38,8 @@ public SmartShoot(Outtake outtake, Intake intake, double RPM) { @Override public void initialize() { outtake.spinOuttake(goalRPM); + timer.restart(); + } // Called every time the scheduler runs while the command is scheduled. @@ -46,16 +48,12 @@ public void execute() { if(outtake.atVelGoal(goalRPM, OUTTAKE_ESTIMATE_OFFSET)){ outtake.spinOuttakeFeeder(OUTTAKE_FEEDER_VOLT_PERC); if (oscillate) { - if (oscillateTimeStampForward == -1) { - oscillateTimeStampForward = Timer.getFPGATimestamp(); - intake.spinConveyor(CONVEYOR_SPEED); - } - else if (Timer.getFPGATimestamp() - oscillateTimeStampForward > 5) { - oscillateTimeStampBackward = Timer.getFPGATimestamp(); + if (timer.get() > 5) { + timer.restart(); intake.spinConveyor(-0.2); } - else if (Timer.getFPGATimestamp() - oscillateTimeStampBackward > 2) { - oscillateTimeStampForward = Timer.getFPGATimestamp(); + else if (timer.get() > 0.5) { + timer.restart(); intake.spinConveyor(CONVEYOR_SPEED); } } @@ -71,6 +69,7 @@ public void end(boolean interrupted) { outtake.stopOuttake(); outtake.spinOuttakeFeeder(0); intake.stopConveyor(); + timer.stop(); } // Returns true when the command should end.