Skip to content

Add scoring autonomous #1

Merged
awdev1 merged 5 commits intomasterfrom
scoring
Mar 20, 2026
Merged

Add scoring autonomous #1
awdev1 merged 5 commits intomasterfrom
scoring

Conversation

@awdev1
Copy link
Collaborator

@awdev1 awdev1 commented Mar 13, 2026

This pull request introduces a new autonomous operation mode called AutoTest2 for the robot, implementing a multi-
This pull request introduces a new autonomous operation mode for the robot by adding the AutoTest2 class. The new op mode implements a multi-stage autonomous routine that leverages path following, flywheel launching, and intake mechanisms for ball handling. The code includes state management, hardware initialization, and telemetry updates to support the autonomous sequence.

New autonomous routine implementation:

  • Added AutoTest2 class in org.firstinspires.ftc.teamcode.OpModes.Autos, which defines a multi-stage autonomous sequence using path following and ball launching mechanisms.
  • Implemented path state management via the updatePathState() method, controlling robot actions like path following, flywheel spinning, launcher firing, and intake operation based on the current state and timing.

Path and hardware integration:

  • Integrated path following using Follower, PathChain, and Bezier paths, with trajectory definitions for shooting, picking up balls, and gate operations.
  • Initialized and configured hardware components (flywheel1, flywheel2, launcher, intake) in the init() method, including motor directions and modes.

Telemetry and control:

  • Added telemetry output in the loop() method to monitor timers, state, flywheel velocities, and readiness, aiding debugging and performance tracking during autonomous operation. (F77f5771stage path-following and shooting routine. The code sets up complex path chains using Bezier curves and lines, manages flywheel and launcher control for shooting, and coordinates the robot's mechanisms through a state machine.

Key additions and features:

Autonomous Path Following and State Machine:

  • Implements a state machine in updatePathState() to control the robot's movement, shooting, and ball pickup sequence, coordinating path transitions and timing for each action.
  • Defines multiple robot poses and uses Bezier paths to move between shooting, pickup, and gate positions, leveraging the Follower and PathChain classes for smooth trajectory following.

Flywheel and Launcher Control:

  • Adds methods to spin up, monitor, and stop the flywheels, ensuring they reach target velocity before firing balls. Controls the launcher and intake motors to execute timed shooting sequences.
  • Introduces constants for flywheel velocity, launcher power, and timing durations to facilitate tuning and consistent operation.

Initialization and Telemetry:

  • Sets up hardware mapping for all motors, initializes the follower and timers, and resets all mechanisms at the start and stop of the op mode.
  • Provides

@awdev1 awdev1 requested a review from Copilot March 13, 2026 05:28
@awdev1 awdev1 self-assigned this Mar 13, 2026
@github-actions
Copy link

This PR was automatically closed because it adds new files.

If this is intentional, comment /not-a-mistake once to reopen it.

@github-actions github-actions bot closed this Mar 13, 2026
@awdev1 awdev1 changed the title chore: add auto but scoring edition Add scoring autonomous Mar 13, 2026
@awdev1
Copy link
Collaborator Author

awdev1 commented Mar 13, 2026

Reopening since this is a false close /not-a-mistake

@awdev1 awdev1 reopened this Mar 13, 2026
@github-actions
Copy link

This PR was automatically closed because it adds new files.

If this is intentional, comment /not-a-mistake once to reopen it.

@github-actions github-actions bot closed this Mar 13, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new FTC autonomous OpMode (AutoTest2) implementing a multi-stage path-following routine with flywheel spin-up and timed multi-ball firing controlled by a state machine.

Changes:

  • Introduces AutoTest2 OpMode with multiple PathChains (line/Bezier) for shooting → pickup → gate → shooting cycles.
  • Adds flywheel velocity control with “ready” detection and timeouts, plus timed launcher firing steps.
  • Adds telemetry for path state/timing and flywheel velocities.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.build();
shootToPickup = follower.pathBuilder()
.addPath(new BezierLine(shootPose, ballPickup1))
.setLinearHeadingInterpolation(ballPickup1.getHeading(), ballPickup1.getHeading())
flywheel2 = hardwareMap.get(DcMotorEx.class, "flywheel2");
launcher = hardwareMap.get(DcMotorEx.class, "Launcher");
launcher.setDirection(DcMotorSimple.Direction.REVERSE);
flywheel1.setDirection(DcMotorSimple.Direction.REVERSE);
Comment on lines +220 to +231
public void start() {
pathTimer.resetTimer();
opModeTimer.resetTimer();
pathState = 0;
stopFlywheels();
launcher.setPower(0.0);
}
@Override
public void stop() {
stopFlywheels();
launcher.setPower(0.0);
}
Comment on lines +7 to +16
import com.pedropathing.paths.Path;
import com.pedropathing.paths.PathChain;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.pedropathing.util.Timer;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorEx;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.hardware.HardwareMap;

Comment on lines +205 to +223
pathTimer = new Timer();
opModeTimer = new Timer();
follower = Constants.createFollower(hardwareMap);
pathBuilder();
follower.setPose(startPose);
flywheel1 = hardwareMap.get(DcMotorEx.class, "flywheel1");
flywheel2 = hardwareMap.get(DcMotorEx.class, "flywheel2");
launcher = hardwareMap.get(DcMotorEx.class, "Launcher");
launcher.setDirection(DcMotorSimple.Direction.REVERSE);
flywheel1.setDirection(DcMotorSimple.Direction.REVERSE);
flywheel1.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
flywheel2.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
intake = hardwareMap.get(DcMotorEx.class, "Intake");
stopFlywheels();
}
public void start() {
pathTimer.resetTimer();
opModeTimer.resetTimer();
pathState = 0;
@awdev1 awdev1 reopened this Mar 13, 2026
@awdev1 awdev1 removed the mistake-pr label Mar 13, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new FTC autonomous OpMode (AutoTest2) implementing a multi-stage routine that combines Pedro Pathing trajectories with a flywheel/launcher/intake state machine, plus adds (currently disabled) GitHub Actions workflows for “mistake PR” auto-close/reopen handling.

Changes:

  • Added AutoTest2 autonomous OpMode with path chains, timers, mechanism control, and telemetry.
  • Implemented a timed multi-shot firing sequence integrated into the autonomous state machine.
  • Added three disabled GitHub Actions workflow definitions related to auto-closing and re-opening “mistake” PRs.

Reviewed changes

Copilot reviewed 1 out of 4 changed files in this pull request and generated 4 comments.

File Description
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/OpModes/Autos/AutoTest2.java New autonomous OpMode with Pedro Pathing trajectories and a timed state machine for shooting/intake.
.github/workflows/reopen-once.yml.disabled Disabled workflow to allow PR author to reopen a “mistake-pr” once via a comment command.
.github/workflows/mistake-pr.yml.disabled Disabled workflow to auto-label/close PRs that add new files.
.github/workflows/disable-auto-reopen-after-second-close.yml.disabled Disabled workflow to permanently disable auto-reopen after a second close.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
break;
case 2:
if (flywheelsAtSpeed() || pathTimer.getElapsedTimeSeconds() >= FLYWHEEL_READY_TIMEOUT) {
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this transition, the code proceeds to the shooting state even when the robot hasn't reached shootPose (it can advance solely on the 5s timeout). That can result in firing while off-position. Consider requiring atPose(shootPose, ...) before entering the firing states, and handling timeouts by aborting/replanning (or explicitly gating firing on being at pose).

Suggested change
if (flywheelsAtSpeed() || pathTimer.getElapsedTimeSeconds() >= FLYWHEEL_READY_TIMEOUT) {
if (follower.atPose(shootPose, 2, 2)
&& (flywheelsAtSpeed() || pathTimer.getElapsedTimeSeconds() >= FLYWHEEL_READY_TIMEOUT)) {

Copilot uses AI. Check for mistakes.
Comment on lines +150 to +152
if (!follower.isBusy() || follower.atPose(shootPose, 2, 2) || pathTimer.getElapsedTimeSeconds() > 5) {
pathTimer.resetTimer();
pathState = 11;
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition advances to the second firing sequence if the follower is no longer busy OR on timeout, even if the robot isn't actually within tolerance of shootPose. That can cause shots to be taken from an unintended position. Consider only entering the firing states once atPose(shootPose, ...) is true, and treat !isBusy()/timeouts as error handling paths rather than green-lighting shooting.

Suggested change
if (!follower.isBusy() || follower.atPose(shootPose, 2, 2) || pathTimer.getElapsedTimeSeconds() > 5) {
pathTimer.resetTimer();
pathState = 11;
if (follower.atPose(shootPose, 2, 2)) {
// Reached the desired shooting pose: proceed to firing sequence
pathTimer.resetTimer();
pathState = 11;
} else if (!follower.isBusy() || pathTimer.getElapsedTimeSeconds() > 5) {
// Error/timeout: follower stopped or timed out without reaching shootPose.
// Abort firing to avoid shooting from an unintended position.
stopFlywheels();
launcher.setPower(0);

Copilot uses AI. Check for mistakes.
pathState = 17;
}
break;
case 17:
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the final shot, the state machine stops the flywheels but never stops the intake motor. Since intake is set to -1 earlier and not changed afterward, it will keep running indefinitely in state 17 until the OpMode ends. If the routine is complete here, stop the intake (and optionally the follower) when entering the terminal state.

Suggested change
case 17:
case 17:
intake.setPower(0.0);

Copilot uses AI. Check for mistakes.
Comment on lines +89 to +116
case 2:
if (flywheelsAtSpeed() || pathTimer.getElapsedTimeSeconds() >= FLYWHEEL_READY_TIMEOUT) {
launcher.setPower(LAUNCHER_POWER);
pathTimer.resetTimer();
pathState = 3;
}
break;
case 3:
if (pathTimer.getElapsedTimeSeconds() >= FIRE_DURATION) {
launcher.setPower(0);
pathTimer.resetTimer();
pathState = 4;
}
break;
case 4:
if (pathTimer.getElapsedTimeSeconds() >= PAUSE_DURATION) {
launcher.setPower(LAUNCHER_POWER);
pathTimer.resetTimer();
pathState = 5;
}
break;
case 5:
if (pathTimer.getElapsedTimeSeconds() >= FIRE_DURATION) {
launcher.setPower(0);
pathTimer.resetTimer();
pathState = 6;
}
break;
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The firing sequence is implemented by a long run of nearly identical states (2–7 and again 11–16). This duplication makes tuning risky (power/timing changes must be kept in sync in multiple places) and increases the chance of inconsistent behavior. Consider refactoring into a helper that steps through N shots using a counter (or an array of shot/ pause durations) to reduce duplicated state logic.

Copilot uses AI. Check for mistakes.
@awdev1 awdev1 merged commit be82bf8 into master Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants