Add hub reactivation return warning to driver feedback#34
Add hub reactivation return warning to driver feedback#34
Conversation
Co-authored-by: GrumpyBud <109627078+GrumpyBud@users.noreply.github.com>
Co-authored-by: GrumpyBud <109627078+GrumpyBud@users.noreply.github.com>
There was a problem hiding this comment.
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. |
| // 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); |
There was a problem hiding this comment.
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.
| 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(); |
There was a problem hiding this comment.
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.
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
HubShiftUtilhelpers to estimate time back to the alliance-zone scoring side from the robot’s current pose.Driver feedback
Dashboard / logging outputs
HubShift/ReturnToAllianceZoneWarningHubShift/EstimatedReturnTimeSecHubShift/TimeUntilHubActiveSecImplementation shape
HubShiftUtil.RobotContainer.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/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/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/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/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
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.