Class TrenchZoneConfig
All coordinates are in field (blue-alliance) frame. Each hub has two trenches (north and south), giving four zones total. The X boundaries cover
the hub width with a buffer, and the Y boundaries split at the hub center so the correct trench center Y is used for waypoints. Each zone's
trenchCenterYMeters is derived from the AprilTags at the trench opening (e.g., tags 22/23 for the blue north trench at y=7.411). The
heading rule is purely directional: 180 degrees for +X travel, 0 degrees for -X travel.
-
Nested Class Summary
Nested classes/interfaces inherited from class frc.robot.shared.config.AbstractConfig
AbstractConfig.ComponentPoseConfig -
Field Summary
FieldsModifier and TypeFieldDescriptiondoubleBuffer distance in meters added outside the zone boundary when computing entry and exit waypoints.booleanWhether this trench zone is active.doubleMaximum X-coordinate of the trench zone in meters (field coordinates).doubleMaximum Y-coordinate of the trench zone in meters (field coordinates).doubleMinimum X-coordinate of the trench zone in meters (field coordinates).doubleMinimum Y-coordinate of the trench zone in meters (field coordinates).doubleY-coordinate of the trench center in meters (field coordinates), derived from the AprilTags centered on the trench opening. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.math.geometry.Pose2dcomputeEntryWaypoint(edu.wpi.first.math.geometry.Pose2d start, edu.wpi.first.math.geometry.Pose2d target) Computes the entry waypoint just outside the trench zone on the side closest to the starting position.edu.wpi.first.math.geometry.Pose2dcomputeExitWaypoint(edu.wpi.first.math.geometry.Pose2d start, edu.wpi.first.math.geometry.Pose2d target) Computes the exit waypoint just outside the trench zone on the side closest to the target position.doubleReads the tunable buffer distance in meters.booleanReads whether this trench zone is enabled.doubleReads the tunable maximum X-coordinate of the zone in meters.doubleReads the tunable maximum Y-coordinate of the zone in meters.doubleReads the tunable minimum X-coordinate of the zone in meters.doubleReads the tunable minimum Y-coordinate of the zone in meters.doubleReads the tunable trench center Y-coordinate in meters.booleanintersectsLineSegment(edu.wpi.first.math.geometry.Pose2d start, edu.wpi.first.math.geometry.Pose2d target) Tests whether the straight-line segment from one pose to another intersects this trench zone rectangle.Methods inherited from class frc.robot.shared.config.AbstractConfig
getDashboardPrefix, initializeNestedDashboardPrefixes, readTunableBoolean, readTunableDegrees, readTunableDegreesAsRadians, readTunableNumber, readTunableString, setDashboardPrefix
-
Field Details
-
enabled
public boolean enabledWhether this trench zone is active.Disabled zones are skipped during intersection checks.
-
minXMeters
public double minXMetersMinimum X-coordinate of the trench zone in meters (field coordinates). -
maxXMeters
public double maxXMetersMaximum X-coordinate of the trench zone in meters (field coordinates). -
minYMeters
public double minYMetersMinimum Y-coordinate of the trench zone in meters (field coordinates). -
maxYMeters
public double maxYMetersMaximum Y-coordinate of the trench zone in meters (field coordinates). -
trenchCenterYMeters
public double trenchCenterYMetersY-coordinate of the trench center in meters (field coordinates), derived from the AprilTags centered on the trench opening.Both entry and exit waypoints use this Y value so the robot lines up with the center of the trench passage.
-
bufferMeters
public double bufferMetersBuffer distance in meters added outside the zone boundary when computing entry and exit waypoints.The entry waypoint is placed this far outside the zone edge so the robot finishes its heading correction before physically entering the trench. A value of 0.5 meters gives roughly half a robot length of margin.
-
-
Constructor Details
-
TrenchZoneConfig
public TrenchZoneConfig()
-
-
Method Details
-
getEnabled
public boolean getEnabled()Reads whether this trench zone is enabled.- Returns:
trueif the zone should be checked during intersection tests
-
getMinXMeters
public double getMinXMeters()Reads the tunable minimum X-coordinate of the zone in meters.- Returns:
- minimum X boundary in meters
-
getMaxXMeters
public double getMaxXMeters()Reads the tunable maximum X-coordinate of the zone in meters.- Returns:
- maximum X boundary in meters
-
getMinYMeters
public double getMinYMeters()Reads the tunable minimum Y-coordinate of the zone in meters.- Returns:
- minimum Y boundary in meters
-
getMaxYMeters
public double getMaxYMeters()Reads the tunable maximum Y-coordinate of the zone in meters.- Returns:
- maximum Y boundary in meters
-
getTrenchCenterYMeters
public double getTrenchCenterYMeters()Reads the tunable trench center Y-coordinate in meters.- Returns:
- trench center Y in meters
-
getBufferMeters
public double getBufferMeters()Reads the tunable buffer distance in meters.- Returns:
- buffer distance outside the zone edge in meters
-
intersectsLineSegment
public boolean intersectsLineSegment(edu.wpi.first.math.geometry.Pose2d start, edu.wpi.first.math.geometry.Pose2d target) Tests whether the straight-line segment from one pose to another intersects this trench zone rectangle.Uses the Cohen-Sutherland line-clipping algorithm to test a line segment against the axis-aligned bounding box. This is a conservative heuristic: false positives (the line crosses the zone but the PathPlanner AD* pathfinder routes around) cause a harmless detour through the entry/exit waypoints, while false negatives are dangerous. Size the zones generously to minimize false negatives.
- Parameters:
start- starting pose in field coordinates (typically the robot's current odometry pose)target- target pose in field coordinates (already alliance-flipped)- Returns:
trueif the line segment from start to target crosses this zone
-
computeEntryWaypoint
public edu.wpi.first.math.geometry.Pose2d computeEntryWaypoint(edu.wpi.first.math.geometry.Pose2d start, edu.wpi.first.math.geometry.Pose2d target) Computes the entry waypoint just outside the trench zone on the side closest to the starting position.The waypoint is placed at the zone's X-edge (plus buffer) on the start side, at the configured trench center Y derived from the AprilTags centered on the trench opening. The heading is set to the required trench heading based on travel direction: 180 degrees for +X travel, 0 degrees for -X travel.
- Parameters:
start- starting pose in field coordinatestarget- target pose in field coordinates- Returns:
- entry waypoint pose with the required heading for trench traversal
-
computeExitWaypoint
public edu.wpi.first.math.geometry.Pose2d computeExitWaypoint(edu.wpi.first.math.geometry.Pose2d start, edu.wpi.first.math.geometry.Pose2d target) Computes the exit waypoint just outside the trench zone on the side closest to the target position.The waypoint is placed at the zone's X-edge (plus buffer) on the target side, at the configured trench center Y so the robot exits aligned with the trench passage. The heading matches the entry heading so the robot maintains a consistent orientation through the entire trench transit.
- Parameters:
start- starting pose in field coordinatestarget- target pose in field coordinates- Returns:
- exit waypoint pose with the required heading for trench traversal
-