From 235f43fd2e6b0b6e9a3c401ef9c27d0be7f411b2 Mon Sep 17 00:00:00 2001 From: NoahLacks63 Date: Thu, 19 Mar 2026 15:16:29 -0400 Subject: [PATCH] made intake jimmy a method and added a button for it --- src/main/java/frc/robot/RobotContainer.java | 18 +++++------ .../frc/robot/subsystems/IntakePivot.java | 32 +++++++++++++++---- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index fa34384..f9c5cb4 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -310,6 +310,12 @@ public class RobotContainer { secondary.rightBumper().onTrue(hood.trackToAngle(() -> Units.degreesToRadians(10))); //10 degrees good for shooting ~33in away from hub + secondary.y().whileTrue( + intakePivot.jimmy(.2) + .andThen( + intakePivot.manualSpeed(() -> -0.5) + ) + ); hood.setDefaultCommand(hood.trackToAngle(() -> { Pose2d drivetrainPose = drivetrain.getPose(); @@ -374,18 +380,12 @@ public class RobotContainer { NamedCommands.registerCommand("stop spindexer", spindexer.instantaneousStop()); NamedCommands.registerCommand("jimmy", - Commands.repeatingSequence( - intakePivot.manualSpeed(() -> -0.75).withTimeout(0.2) - .andThen(intakePivot.manualSpeed(() -> 0.75).withTimeout(0.2)) - ) - ); + intakePivot.jimmy(0.2) + ); NamedCommands.registerCommand("shoot N jimmy", Commands.parallel( - Commands.repeatingSequence( - intakePivot.manualSpeed(() -> -0.75).withTimeout(0.5), - intakePivot.manualSpeed(() -> 0.75).withTimeout(0.5) - ), + intakePivot.jimmy(0.5), spindexer.spinToShooter() .alongWith(shooter.maintainSpeed(ShooterSpeeds.kHubSpeed), hood.trackToAngle(() -> Units.degreesToRadians(10))) diff --git a/src/main/java/frc/robot/subsystems/IntakePivot.java b/src/main/java/frc/robot/subsystems/IntakePivot.java index 14f9428..5aa2c16 100644 --- a/src/main/java/frc/robot/subsystems/IntakePivot.java +++ b/src/main/java/frc/robot/subsystems/IntakePivot.java @@ -14,6 +14,7 @@ import com.revrobotics.spark.SparkBase.ControlType; import com.revrobotics.spark.SparkLowLevel.MotorType; import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.constants.IntakePivotConstants; import frc.robot.constants.IntakePivotConstants.IntakePivotPosition; @@ -80,12 +81,31 @@ public class IntakePivot extends SubsystemBase { }); } - // public Command jimmy(){ - // return run(() -> { - // leftMotor.set(0.5 * IntakePivotConstants.kMaxManualSpeedMultiplier); - // rightMotor.set(0.5 * IntakePivotConstants.kMaxManualSpeedMultiplier); - // }) - // } + /** + * Repeatedly moves the intake up and down. AKA "Jimmying" the intake + * + * @param time How long the intake will go both ways for (seconds) + * @return Command that repeatedly Jimmys the intake + */ + public Command jimmy(double time){ + return Commands.repeatingSequence( + manualSpeed(() -> -0.75).withTimeout(time) + .andThen(manualSpeed(() -> 0.75).withTimeout(time)) + ); + } + + /** + * Repeatedly moves the intake up and down. AKA "Jimmying" the intake + * + * @param time How long the intake will go both ways for (seconds) + * @return Command that repeatedly Jimmys the intake + */ + public Command jimmy(DoubleSupplier time) { + return Commands.repeatingSequence( + manualSpeed(() -> -0.75).withTimeout(time.getAsDouble()) + .andThen(manualSpeed(() -> 0.75).withTimeout(time.getAsDouble())) + ); + } public Command stop() { return manualSpeed(() -> 0);