Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public void runOpMode() throws InterruptedException {
}

// Start the intake forward immediately at autonomous start
robot.intake.runFromTrigger(AutonomousConstants.INTAKE_FORWARD_SPEED);
// robot.intake.runFromTrigger(AutonomousConstants.INTAKE_FORWARD_SPEED);
// note: only uncomment if the breif reversals is breaking something
// so that means dont uncomment it bc they werk

// Wait 800 ms to let the Pinpoint calibrate on reset
sleep(1200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class Controller {
private Follower follower;
private RevColorSensorV3 colorShootSensor;
private boolean isShooting = false;
private volatile boolean isIntakeCycling = false;
private volatile boolean intakePaused = false;
private Thread intakeCycleThread = null;

public Controller(LinearOpMode opMode, RobotContainer robot) {
this.opMode = opMode;
Expand Down Expand Up @@ -51,10 +54,40 @@ public void startShooter(double rpm) {
}

/**
* Turns on the intake to the default forward speed.
* Starts a background thread that continuously cycles the intake:
* - Forward at INTAKE_FORWARD_SPEED for SHOOT_FORWARD_CYCLE_MS
* - Reverse at INTAKE_REVERSE_SPEED for SHOOT_REVERSE_CYCLE_MS (jam clearing)
* The cycle repeats for the entire opmode. Call disableIntake() to stop it.
* While paused (via pauseIntakeCycling()), only the forward phase runs.
*/
public void enableIntake() {
robot.intake.runFromTrigger(AutonomousConstants.INTAKE_FORWARD_SPEED);
if (!opMode.opModeIsActive() || isIntakeCycling) return;

isIntakeCycling = true;
intakeCycleThread = new Thread(() -> {
while (isIntakeCycling && opMode.opModeIsActive()) {
// Phase 1: run forward
robot.intake.runFromTrigger(AutonomousConstants.INTAKE_FORWARD_SPEED);
long forwardEnd = System.currentTimeMillis() + AutonomousConstants.SHOOT_FORWARD_CYCLE_MS;
while (isIntakeCycling && opMode.opModeIsActive() && System.currentTimeMillis() < forwardEnd) {
try { Thread.sleep(10); } catch (InterruptedException e) { return; }
}

if (!isIntakeCycling || !opMode.opModeIsActive()) break;

// Phase 2: briefly reverse to clear jams — skipped while paused
if (!intakePaused) {
robot.intake.reverse(AutonomousConstants.INTAKE_REVERSE_SPEED);
long reverseEnd = System.currentTimeMillis() + AutonomousConstants.SHOOT_REVERSE_CYCLE_MS;
while (isIntakeCycling && opMode.opModeIsActive() && System.currentTimeMillis() < reverseEnd) {
try { Thread.sleep(10); } catch (InterruptedException e) { return; }
}
}
}
robot.intake.stop();
});
intakeCycleThread.setDaemon(true);
intakeCycleThread.start();
}

public void runIntakeForward() {
Expand All @@ -66,9 +99,33 @@ public void runIntakeReverse() {
}

public void disableIntake() {
isIntakeCycling = false;
if (intakeCycleThread != null) {
intakeCycleThread.interrupt();
try { intakeCycleThread.join(500); } catch (InterruptedException ignored) {}
intakeCycleThread = null;
}
robot.intake.stop();
}

/**
* Pauses the reverse (jam-clearing) phase of the intake cycle.
* The intake will run forward-only until resumeIntakeCycling() is called.
* Use this while driving over intake positions so the intake stays engaged.
*/
public void pauseIntakeCycling() {
intakePaused = true;
// Immediately drive forward so there is no gap at the moment of pause
robot.intake.runFromTrigger(AutonomousConstants.INTAKE_FORWARD_SPEED);
}

/**
* Resumes the full forward→reverse jam-clearing cycle.
*/
public void resumeIntakeCycling() {
intakePaused = false;
}

/**
* Drives to a point and blocks until the robot is near the target or opmode stops.
*/
Expand Down Expand Up @@ -148,8 +205,7 @@ public void shoot(long durationMs) {
public void update() {
follower.update();

// Always ensure the intake is running forward during autonomous
robot.intake.runFromTrigger(AutonomousConstants.INTAKE_FORWARD_SPEED);
// Intake is managed by the background cycling thread when enableIntake() is active

if (!isShooting) {
double feederPower;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

if (!AutonomousConstants.SKIP_HUMAN_INTAKE) {
// 3. move to human player ball intake position
Expand All @@ -39,23 +39,27 @@ protected void runAutonomous() {
}

// 5. move to intake position 1 for back row intake
controller.pathTo(AutonomousPoints.Blue.Back.INTAKE_CLOSE_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Blue.Back.INTAKE_CLOSE_1);

// 6. move to intake position 2 for back row intake
controller.pathTo(AutonomousPoints.Blue.Back.INTAKE_CLOSE_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 7. shoot balls
controller.pathTo(AutonomousPoints.Blue.Back.SHOOT);
controller.resumeIntakeCycling();
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);

// 8. move to intake position 1 for middle row intake
controller.pathTo(AutonomousPoints.Blue.Back.INTAKE_MIDDLE_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Blue.Back.INTAKE_MIDDLE_1);

// 9. move to intake position 2 for middle row intake
controller.pathTo(AutonomousPoints.Blue.Back.INTAKE_MIDDLE_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 10. shoot balls
controller.pathTo(AutonomousPoints.Blue.Back.SHOOT);
controller.resumeIntakeCycling();
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);

// 11. park back position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

if (!AutonomousConstants.SKIP_HUMAN_INTAKE) {
// 3. move to human player ball intake position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

if (!AutonomousConstants.SKIP_HUMAN_INTAKE) {
// 3. move to human player ball intake position
Expand All @@ -39,13 +39,15 @@ protected void runAutonomous() {
}

// 5. move to intake position 1 for back row intake
controller.pathTo(AutonomousPoints.Blue.Back.INTAKE_CLOSE_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Blue.Back.INTAKE_CLOSE_1);

// 6. move to intake position 2 for back row intake
controller.pathTo(AutonomousPoints.Blue.Back.INTAKE_CLOSE_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 7. shoot balls
controller.pathTo(AutonomousPoints.Blue.Back.SHOOT);
controller.resumeIntakeCycling();
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);

// 8. park back position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

// 3. move to intake position 1 for far row intake
controller.pathTo(AutonomousPoints.Blue.Front.INTAKE_FAR_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Blue.Front.INTAKE_FAR_1);

// 4. move to intake position 2 for far row intake
controller.pathTo(AutonomousPoints.Blue.Front.INTAKE_FAR_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 5. move to shoot position
controller.pathTo(AutonomousPoints.Blue.Front.SHOOT);
controller.resumeIntakeCycling();

// 6. shoot balls
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,32 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

// 3. move to intake position 1 for far row intake
controller.pathTo(AutonomousPoints.Blue.Front.INTAKE_FAR_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Blue.Front.INTAKE_FAR_1);

// 4. move to intake position 2 for far row intake
controller.pathTo(AutonomousPoints.Blue.Front.INTAKE_FAR_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 5. move to shoot position
controller.pathTo(AutonomousPoints.Blue.Front.SHOOT);
controller.resumeIntakeCycling();

// 6. shoot balls
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);

// 7. move to intake position 1 for middle row intake
controller.pathTo(AutonomousPoints.Blue.Front.INTAKE_MID_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Blue.Front.INTAKE_MID_1);

// 8. move to intake position 2 for middle row intake
controller.pathTo(AutonomousPoints.Blue.Front.INTAKE_MID_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 9. move to shoot position
controller.pathTo(AutonomousPoints.Blue.Front.SHOOT);
controller.resumeIntakeCycling();

// 10. shoot balls
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

if (!AutonomousConstants.SKIP_HUMAN_INTAKE) {
// 3. move to human player ball intake position
Expand All @@ -38,23 +38,27 @@ protected void runAutonomous() {
}

// 5. move to intake position 1 for back row intake
controller.pathTo(AutonomousPoints.Red.Back.INTAKE_CLOSE_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Red.Back.INTAKE_CLOSE_1);

// 6. move to intake position 2 for back row intake
controller.pathTo(AutonomousPoints.Red.Back.INTAKE_CLOSE_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 7. shoot balls
controller.pathTo(AutonomousPoints.Red.Back.SHOOT);
controller.resumeIntakeCycling();
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);

// 8. move to intake position 1 for middle row intake
controller.pathTo(AutonomousPoints.Red.Back.INTAKE_MIDDLE_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Red.Back.INTAKE_MIDDLE_1);

// 9. move to intake position 2 for middle row intake
controller.pathTo(AutonomousPoints.Red.Back.INTAKE_MIDDLE_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 10. shoot balls
controller.pathTo(AutonomousPoints.Red.Back.SHOOT);
controller.resumeIntakeCycling();
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);

// 11. park back position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

if (!AutonomousConstants.SKIP_HUMAN_INTAKE) {
// 3. move to human player ball intake position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

if (!AutonomousConstants.SKIP_HUMAN_INTAKE) {
// 3. move to human player ball intake position
Expand All @@ -38,13 +38,15 @@ protected void runAutonomous() {
}

// 5. move to intake position 1 for back row intake
controller.pathTo(AutonomousPoints.Red.Back.INTAKE_CLOSE_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Red.Back.INTAKE_CLOSE_1);

// 6. move to intake position 2 for back row intake
controller.pathTo(AutonomousPoints.Red.Back.INTAKE_CLOSE_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 7. shoot balls
controller.pathTo(AutonomousPoints.Red.Back.SHOOT);
controller.resumeIntakeCycling();
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);

// 8. park back position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

// 3. move to intake position 1 for far row intake
controller.pathTo(AutonomousPoints.Red.Front.INTAKE_FAR_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Red.Front.INTAKE_FAR_1);

// 4. move to intake position 2 for far row intake
controller.pathTo(AutonomousPoints.Red.Front.INTAKE_FAR_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 5. move to shoot position
controller.pathTo(AutonomousPoints.Red.Front.SHOOT);
controller.resumeIntakeCycling();

// 6. shoot balls
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,32 @@ protected void runAutonomous() {
controller.shoot(AutonomousConstants.PRELOAD_SHOOT_TIME);

// Engage intake (for rest of auton)
controller.runIntakeForward();
controller.enableIntake();

// 3. move to intake position 1 for far row intake
controller.pathTo(AutonomousPoints.Red.Front.INTAKE_FAR_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Red.Front.INTAKE_FAR_1);

// 4. move to intake position 2 for far row intake
controller.pathTo(AutonomousPoints.Red.Front.INTAKE_FAR_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 5. move to shoot position
controller.pathTo(AutonomousPoints.Red.Front.SHOOT);
controller.resumeIntakeCycling();

// 6. shoot balls
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);

// 7. move to intake position 1 for middle row intake
controller.pathTo(AutonomousPoints.Red.Front.INTAKE_MID_1, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);
controller.pauseIntakeCycling();
controller.pathTo(AutonomousPoints.Red.Front.INTAKE_MID_1);

// 8. move to intake position 2 for middle row intake
controller.pathTo(AutonomousPoints.Red.Front.INTAKE_MID_2, AutonomousConstants.INTAKE_PATH_SPEED_SCALING);

// 9. move to shoot position
controller.pathTo(AutonomousPoints.Red.Front.SHOOT);
controller.resumeIntakeCycling();

// 10. shoot balls
controller.shoot(AutonomousConstants.CYCLE_SHOOT_TIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public final class AutonomousConstants {
public static long SHOOT_FORWARD_CYCLE_MS = 1000;
public static long SHOOT_REVERSE_CYCLE_MS = 200;

public static double INTAKE_FORWARD_SPEED = 1.0;
public static double INTAKE_FORWARD_SPEED = 0.9;
public static double INTAKE_REVERSE_SPEED = 0.5;

// Pathing speed scaling for close/back-row intake moves
public static double INTAKE_PATH_SPEED_SCALING = 0.30;
public static double INTAKE_PATH_SPEED_SCALING = 0.21;

// Feeder timings/speeds during autonomous
public static double FEEDER_SPEED = 1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public static final class Back {

public static final class Front {
public static final Pose SHOOT = new Pose(-49.65, -1.28, Math.toRadians(-83.59));
public static final Pose INTAKE_FAR_1 = new Pose(-40.99, -17.66, Math.toRadians(142.06));
public static final Pose INTAKE_FAR_2 = new Pose(-22.61, -33.93, Math.toRadians(140.47));
public static final Pose INTAKE_MID_1 = new Pose(-54.56, -34.25, Math.toRadians(140.66));
public static final Pose INTAKE_MID_2 = new Pose(-38.80, -53.29, Math.toRadians(139.87));
public static final Pose INTAKE_FAR_1 = new Pose(-42.82, -14.32, Math.toRadians(142.06));
public static final Pose INTAKE_FAR_2 = new Pose(-20.43, -31.04, Math.toRadians(140.47));
public static final Pose INTAKE_MID_1 = new Pose(-56.74, -31.18, Math.toRadians(140.66));
public static final Pose INTAKE_MID_2 = new Pose(-35.18, -49.58, Math.toRadians(139.87));
public static final Pose PARK_FAR = new Pose(-31.36, 17.58, Math.toRadians(-41.80));
}
}
Expand Down
Loading
Loading