From 65f18d233a3da26d0e4da4b3b6308977846dcf87 Mon Sep 17 00:00:00 2001 From: Soupborsh <100529201+Soupborsh@users.noreply.github.com> Date: Sat, 25 Oct 2025 12:19:05 +0500 Subject: [PATCH 1/4] Fix direction typo(change right to left) Robot actually goes to the left(and documentation says so) but the code comments and driver hub text mistakenly call that it goes to the right leading to confusion. This fixes this typo. --- .../org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java index 9f5d275f03ff..c50907c3aa71 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java @@ -617,7 +617,7 @@ public void loop() { /** * This is the LateralZeroPowerAccelerationTuner autonomous follower OpMode. This runs the robot - * to the right until a specified velocity is achieved. Then, the robot cuts power to the motors, setting + * to the left until a specified velocity is achieved. Then, the robot cuts power to the motors, setting * them to zero power. The deceleration, or negative acceleration, is then measured until the robot * stops. The accelerations across the entire time the robot is slowing down is then averaged and * that number is then printed. This is used to determine how the robot will decelerate in the @@ -644,7 +644,7 @@ public void init() {} /** This initializes the drive motors as well as the Panels telemetry. */ @Override public void init_loop() { - telemetryM.debug("The robot will run to the right until it reaches " + VELOCITY + " inches per second."); + telemetryM.debug("The robot will run to the left until it reaches " + VELOCITY + " inches per second."); telemetryM.debug("Then, it will cut power from the drivetrain and roll to a stop."); telemetryM.debug("Make sure you have enough room."); telemetryM.debug("After stopping, the lateral zero power acceleration (natural deceleration) will be displayed."); From 47c3e3108338f54c306873965de598ecca913610 Mon Sep 17 00:00:00 2001 From: Adi V <70706316+adi-varshney@users.noreply.github.com> Date: Sat, 27 Dec 2025 02:19:19 -0500 Subject: [PATCH 2/4] Enforce one-time reopen for mistake PRs and disable auto-reopen after second close (#43) * Add workflows to auto-close, reopen, and lock PRs Introduces three GitHub Actions workflows: one to automatically close PRs that add new files and label them as 'mistake-pr', another to allow the PR author to reopen such PRs once via a comment, and a third to permanently lock PRs after a second closure. These workflows help enforce repository contribution policies and streamline PR management. * exclude .github chnages from mistake PR auto-close * Update mistake-pr.yml * Fix reopen guard and permanently lock PR after second close * Fix duplicate comments, copied file detection, and finalize mistake PR logic * Fix reopen state guard and prevent locking merged PRs * Make reopen retry-safe and ignore merged PRs * test: add file to trigger mistake-pr * Revert "test: add file to trigger mistake-pr" This reverts commit c77f92c3d8e234d154d2f5b57731d6a009fef03a. * Improve PR locking and mistake detection workflows Enhances the GitHub Actions workflows to better handle permanently locked PRs and mistake PR detection. Adds explicit comments and stricter enforcement for PRs that are reopened after being locked, and improves messaging and logic for automatically closing PRs that add new files. * Add admin override and improve PR lock workflows Introduces an admin override workflow to allow maintainers to bypass the mistake-PR lock on pull requests. Updates existing workflows to support the new 'admin-overridden' label, refines logic for locking and reopening PRs, and improves comments and label handling for clarity and robustness. * Make PR lock and comment idempotent in workflow Update the lock-after-second-close workflow to only add a lock comment and lock the PR if it is not already locked. This prevents duplicate comments and redundant lock actions on already locked PRs. * Remove lock labels on admin override workflow Adds logic to remove 'reopen-locked', 'reopen-used', and 'mistake-pr' labels when an admin override is applied, allowing admins to bypass permanent locks. Updates the override comment to reflect label cleanup. * Revert "Admin override" * Refactor PR mistake handling workflows Simplifies and clarifies the logic for auto-closing, reopening, and permanently locking pull requests that add new files. Updates workflows to reduce race conditions, improve comments, and ensure correct label handling. Switches to pull_request_target for better permission handling and streamlines the process for detecting and managing mistake PRs. * Replace PR lock workflow with disable auto-reopen workflow Removed the workflow that permanently locks PRs after a second close and added a new workflow that disables automatic reopening after a second close. The new workflow adds a label and comment to indicate that auto-reopen is disabled, but does not lock the PR, allowing continued discussion and manual reopening by maintainers. * Refactor PR lock workflows and remove admin override Deleted the admin-override workflow and streamlined the logic and messaging in mistake-pr, reopen-once, and disable-auto-reopen-after-second-close workflows. Improved clarity, reduced redundancy, and updated job/step names for consistency. The admin override feature is no longer available; only maintainers can manually reopen PRs after auto-reopen is disabled. --- ...disable-auto-reopen-after-second-close.yml | 45 ++++++++++ .github/workflows/mistake-pr.yml | 67 +++++++++++++++ .github/workflows/reopen-once.yml | 84 +++++++++++++++++++ 3 files changed, 196 insertions(+) create mode 100644 .github/workflows/disable-auto-reopen-after-second-close.yml create mode 100644 .github/workflows/mistake-pr.yml create mode 100644 .github/workflows/reopen-once.yml diff --git a/.github/workflows/disable-auto-reopen-after-second-close.yml b/.github/workflows/disable-auto-reopen-after-second-close.yml new file mode 100644 index 000000000000..13bcb232ded4 --- /dev/null +++ b/.github/workflows/disable-auto-reopen-after-second-close.yml @@ -0,0 +1,45 @@ +name: Disable auto-reopen after second close + +on: + pull_request: + types: [closed] + +permissions: + issues: write + pull-requests: write + +jobs: + disable: + runs-on: ubuntu-latest + steps: + - name: Disable automatic reopen + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + + // Ignore merged PRs + if (pr.merged) return; + + const labels = pr.labels.map(l => l.name); + + // Only act if it was previously reopened once + if (!labels.includes('reopen-used')) return; + + // Mark auto-reopen as permanently disabled + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + labels: ['reopen-locked'] + }); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: + "This PR was reopened once and then closed again.\n\n" + + "Automatic reopening via `/not-a-mistake` is now disabled.\n" + + "Maintainers may still reopen this PR manually if needed." + }); diff --git a/.github/workflows/mistake-pr.yml b/.github/workflows/mistake-pr.yml new file mode 100644 index 000000000000..b398dd7467c7 --- /dev/null +++ b/.github/workflows/mistake-pr.yml @@ -0,0 +1,67 @@ +name: Auto-close mistake PRs + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + issues: write + pull-requests: write + +jobs: + detect: + runs-on: ubuntu-latest + steps: + - name: Detect mistake PR + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + const labels = pr.labels.map(l => l.name); + + // Skip if auto-reopen is disabled or already used + if (labels.includes('reopen-used') || labels.includes('reopen-locked')) { + return; + } + + // Get changed files + const files = await github.paginate( + github.rest.pulls.listFiles, + { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + } + ); + + // Detect newly added OR copied files + const hasNewFiles = files.some( + f => f.status === 'added' || f.status === 'copied' + ); + + if (!hasNewFiles) return; + + // Label as mistake PR + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + labels: ['mistake-pr'] + }); + + // Explain and close + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: + "This PR was automatically closed because it adds new files.\n\n" + + "If this is intentional, comment `/not-a-mistake` **once** to reopen it." + }); + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + state: 'closed' + }); diff --git a/.github/workflows/reopen-once.yml b/.github/workflows/reopen-once.yml new file mode 100644 index 000000000000..637869768784 --- /dev/null +++ b/.github/workflows/reopen-once.yml @@ -0,0 +1,84 @@ +name: Reopen mistake PR once + +on: + issue_comment: + types: [created] + +permissions: + issues: write + pull-requests: write + +jobs: + reopen: + runs-on: ubuntu-latest + steps: + - name: Handle /not-a-mistake + uses: actions/github-script@v7 + with: + script: | + const comment = context.payload.comment; + const issue = context.payload.issue; + + if (!issue.pull_request) return; + if (comment.body.trim() !== '/not-a-mistake') return; + + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: issue.number + }); + + const labels = pr.data.labels.map(l => l.name); + + // Only PR author may use this + if (comment.user.login !== pr.data.user.login) { + return; + } + + // Must be closed and labeled mistake-pr + if (pr.data.state !== 'closed') return; + if (!labels.includes('mistake-pr')) return; + + // Auto-reopen already disabled + if (labels.includes('reopen-used') || labels.includes('reopen-locked')) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + body: + "Automatic reopening is disabled for this PR.\n\n" + + "A maintainer may still reopen it manually if needed." + }); + return; + } + + // Mark reopen as used FIRST (prevents race) + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + labels: ['reopen-used'] + }); + + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + name: 'mistake-pr' + }); + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: issue.number, + state: 'open' + }); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + body: + "PR reopened.\n\n" + + "If this PR is closed again, automatic reopening will be disabled." + }); From 4e4c1b3bded776db49320254769d839337e2f847 Mon Sep 17 00:00:00 2001 From: Ashay <83087832+saa938@users.noreply.github.com> Date: Sun, 28 Dec 2025 17:39:40 -0800 Subject: [PATCH 3/4] Update Tuning.java --- .../org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java index cfc16aa2ec8f..629d9a14285e 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java @@ -22,6 +22,7 @@ import com.pedropathing.paths.*; import com.pedropathing.telemetry.SelectableOpMode; import com.pedropathing.util.*; +import static com.pedropathing.math.MathFunctions.quadraticFit; import com.qualcomm.robotcore.eventloop.opmode.OpMode; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; import com.qualcomm.robotcore.hardware.DcMotorEx; @@ -856,7 +857,7 @@ public void loop() { } case DONE: { - double[] coeffs = MathFunctions.QuadraticRegression.quadraticFit(data); + double[] coeffs = quadraticFit(data); telemetryM.debug("Tuning Complete"); telemetryM.debug("kFriction (kQ)", coeffs[1]); From 81d362a06ce560d05d7286e9c70202fb34943ff0 Mon Sep 17 00:00:00 2001 From: Ashay <83087832+saa938@users.noreply.github.com> Date: Tue, 30 Dec 2025 11:42:24 -0800 Subject: [PATCH 4/4] more iterations for predictive braking tuner --- .../org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java index 9af7b0e092c3..dd875994999e 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/Tuning.java @@ -737,7 +737,7 @@ public void loop() { */ class PredictiveBrakingTuner extends OpMode { private static final double[] TEST_POWERS = - {1, 1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2}; + {1, 1, 1, 0.9, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2}; private static final int DRIVE_TIME_MS = 1000; private static final int BRAKE_WAIT_MS = 500;