--- /dev/null
+package frc.robot.commands.gpm;
+
+import edu.wpi.first.wpilibj.Timer;
+import edu.wpi.first.wpilibj2.command.Command;
+import frc.robot.subsystems.Intake.Intake;
+
+public class IntakeMovementCommand extends Command {
+ private final Intake intake;
+ private final double interval = 0.6; // Change this to make it faster/slower (seconds)
+
+ public IntakeMovementCommand(Intake intake) {
+ this.intake = intake;
+ addRequirements(intake);
+ }
+
+ @Override
+ public void execute() {
+ intake.spinStop();
+ if ((int) (Timer.getFPGATimestamp() / interval) % 2 == 0) {
+ intake.extend();
+ } else {
+ intake.intermediateExtend();
+ }
+ }
+
+ @Override
+ public void end(boolean interrupted) {
+
+ }
+}
\ No newline at end of file
import frc.robot.Robot;
import frc.robot.commands.gpm.AutoShootCommand;
import frc.robot.commands.gpm.ClimbDriveCommand;
+import frc.robot.commands.gpm.IntakeMovementCommand;
import frc.robot.commands.gpm.ReverseMotors;
import frc.robot.constants.Constants;
import frc.robot.subsystems.Climb.LinearClimb;
intake.spinStop();
intakeBoolean = true;
}
- }));
+ }, intake));
// Retract if hold for 3 seconds
controller.get(PS5Button.RIGHT_TRIGGER).debounce(3.0).onTrue(new InstantCommand(() -> {
intake.retract();
intakeBoolean = true;
intake.spinStop();
- }));
+ }, intake));
+
+ // Make the intake go in and out while shooter
+ controller.get(DPad.UP).whileTrue(new IntakeMovementCommand(intake)
+ .alongWith(new InstantCommand(()-> intakeBoolean = true)));
// Calibration
controller.get(PS5Button.PS).onTrue(new InstantCommand(() -> {
intake.calibrate();
})).onFalse(new InstantCommand(() -> {
intake.stopCalibrating();
- }));
+ }, intake));
// Stop intake roller
controller.get(DPad.DOWN).onTrue(new InstantCommand(()->{
//Sets the initial motor position
motor.setPosition(motorRotations);
- motor.setPosition(0.0);
-
SmartDashboard.putData("Turn to 0", new InstantCommand(()->{setFieldRelativeTarget(Rotation2d.fromDegrees(0), 0.0);}));
SmartDashboard.putData("Turn to -90", new InstantCommand(()->{setFieldRelativeTarget(Rotation2d.fromDegrees(-90), 0.0);}));
SmartDashboard.putData("Turn to 90", new InstantCommand(()->{setFieldRelativeTarget(Rotation2d.fromDegrees(90), 0.0);}));