Skip to content

Add hub reactivation return warning to driver feedback#34

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-controller-rumble-on-return
Draft

Add hub reactivation return warning to driver feedback#34
Copilot wants to merge 3 commits intomainfrom
copilot/add-controller-rumble-on-return

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

When the robot is outside the alliance zone during an inactive hub window, drivers need advance notice to route back before hub scoring becomes available again. This change adds a conservative return-time estimate and surfaces it as driver feedback instead of requiring manual time/position judgment.

  • Return-time estimation

    • Added HubShiftUtil helpers to estimate time back to the alliance-zone scoring side from the robot’s current pose.
    • The estimate is alliance-aware and routes through the nearest open trench-side lane, rather than assuming a straight-line path through the hub/bump.
    • Applies a conservative speed fraction plus extra slack for imperfect manual driving.
  • Driver feedback

    • Added a pulsed controller rumble when the remaining inactive hub time is less than or equal to the estimated return time.
    • Only warns during teleop and only while the hub is currently inactive.
  • Dashboard / logging outputs

    • Publishes:
      • HubShift/ReturnToAllianceZoneWarning
      • HubShift/EstimatedReturnTimeSec
      • HubShift/TimeUntilHubActiveSec
    • Mirrors the same values to AdvantageKit logs for visibility during tuning and match review.
  • Implementation shape

    • Kept hub timing/path estimation in HubShiftUtil.
    • Kept controller and dashboard wiring in RobotContainer.
double estimatedReturnTime =
    HubShiftUtil.getEstimatedReturnToAllianceZoneTime(
        drive.getPose(), drive.getMaxLinearSpeedMetersPerSec());

boolean returnWarningActive =
    HubShiftUtil.shouldWarnReturnToAllianceZone(
        drive.getPose(), drive.getMaxLinearSpeedMetersPerSec());

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 3015rangerrobotics.github.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • frcmaven.wpi.edu
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • maven.ctr-electronics.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • maven.photonvision.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Create a command in robot container or hub shift util that rumbles the controller when it's time to drive back into the alliance zone. The way this should work is as follows:

When the driver goes out of the alliance zone (past the starting line tape), they can't score. So, before the drivers alliance hub becomes active again it should calculate the time it takes to drive back to the center line (specifically the area near the trench or bump, since the robot can't phase through the hub) from the robots position. So, if they are across the field it'll calculate how long it takes to drive back plus a bit more for imperfect driving or paths, and buzz the controller or have a smart dashboard bool or something.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 11, 2026 19:31
Co-authored-by: GrumpyBud <109627078+GrumpyBud@users.noreply.github.com>
Co-authored-by: GrumpyBud <109627078+GrumpyBud@users.noreply.github.com>
Copilot AI changed the title [WIP] Add controller rumble for alliance zone return Add hub reactivation return warning to driver feedback Mar 11, 2026
@GrumpyBud GrumpyBud requested a review from Copilot March 11, 2026 19:41
Copy link
Copy Markdown
Contributor

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 driver feedback to help ensure the robot can return to the alliance-zone scoring side before the hub becomes active again, by estimating return time from current pose and warning (dashboard + controller rumble) when time is getting short.

Changes:

  • Added alliance-aware estimated return-to-alliance-zone time calculation in HubShiftUtil.
  • Added teleop-only “return warning” boolean + related timings to SmartDashboard and AdvantageKit logs.
  • Added pulsed controller rumble when the inactive time remaining is less than or equal to the estimated return time.

Reviewed changes

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

File Description
src/main/java/frc/robot/util/HubShiftUtil.java Adds conservative return-time estimation and a helper to decide when to warn during inactive hub windows.
src/main/java/frc/robot/RobotContainer.java Wires warning state to dashboard/log outputs and controller rumble pulsing.

Comment on lines +226 to +231
// Approximate the manual path as a lateral move into the nearest open lane followed by a
// straight drive back across the alliance-zone line.
double returnDistance =
Math.abs(allianceRelativePose.getY() - returnTarget.getY())
+ Math.max(0.0, allianceRelativePose.getX() - returnTarget.getX());
shortestReturnDistance = Math.min(shortestReturnDistance, returnDistance);
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The return-distance model (lateral move at current X, then straight back to the alliance-zone line) can significantly underestimate the true path when the robot is near the hub/bump X extent, because a pure lateral segment at that X may intersect hub/bump geometry. That makes the warning potentially late even though the method is intended to be conservative. Consider routing via an intermediate waypoint with X cleared past the hub/bump (or adding an X-clearance term when the pose is within the hub/bump footprint) before computing the lateral segment.

Copilot uses AI. Check for mistakes.
Comment on lines +387 to +394
var shiftInfo = HubShiftUtil.getShiftedShiftInfo();
var robotPose = drive.getPose();
double maxDriveSpeedMetersPerSec = drive.getMaxLinearSpeedMetersPerSec();
double estimatedReturnTime =
HubShiftUtil.getEstimatedReturnToAllianceZoneTime(robotPose, maxDriveSpeedMetersPerSec);
boolean returnWarningActive =
HubShiftUtil.shouldWarnReturnToAllianceZone(robotPose, maxDriveSpeedMetersPerSec);
double timeUntilHubActive = shiftInfo.active() ? 0.0 : shiftInfo.remainingTime();
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

shiftInfo is computed here, but HubShiftUtil.shouldWarnReturnToAllianceZone(...) recomputes getShiftedShiftInfo() internally. Consider changing shouldWarnReturnToAllianceZone to accept the already-computed ShiftInfo (or remaining inactive time) to avoid duplicate work and ensure both dashboard/logging and rumble decisions are based on the exact same shift snapshot.

Copilot uses AI. Check for mistakes.
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.

3 participants