Fix#3
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the DragShotPlanner class by extracting inner classes into separate files and makes several configuration changes to the robot system.
Changes:
- Refactored DragShotPlanner from a single ~2200 line file into 17 smaller, focused files
- Updated HoodedShooter subsystem with new parameter tuning and constructor signature changes
- Modified robot configuration settings (robot type, test mode flags, and tuning parameters)
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| DragShotPlanner.java | Converted to facade pattern, delegating to extracted implementation classes |
| Constraints.java | Extracted public class for shot constraints |
| ShotSolution.java | Extracted public class representing shot solution data |
| ShotLibrary.java | Extracted public class for shot library |
| ShotLibraryBuilder.java | Extracted public builder class for shot library |
| ShotLibraryEntry.java | Extracted public class for library entries |
| OnlineSearchState.java | Extracted public class for online search state |
| GamePiecePhysics.java | Extracted public abstract class for game piece physics |
| GamePiecePhysicsConfig.java | Extracted public configuration class |
| DragShotPlannerCore.java | New package-private facade for core planner functions |
| DragShotPlannerConstants.java | Extracted package-private constants |
| DragShotPlannerUtil.java | Extracted package-private utilities |
| DragShotPlannerSimulation.java | Extracted package-private simulation logic |
| DragShotPlannerSolveAtPosition.java | Extracted package-private solver logic |
| DragShotPlannerRefineAtPosition.java | Extracted package-private refinement logic |
| DragShotPlannerOnlineSearch.java | Extracted package-private online search logic |
| DragShotPlannerLibrarySearch.java | Extracted package-private library search logic |
| DragShotPlannerObstacles.java | Extracted package-private obstacle validation logic |
| DragShotPlannerCoarseSearch.java | Extracted package-private coarse search logic |
| DragShotPlannerCandidate.java | Extracted package-private candidate class |
| DragShotPlannerCache.java | Extracted package-private caching logic |
| DragShotPlannerAutoSearch.java | Extracted package-private auto search logic |
| DragShotPlannerGamePieceLoader.java | Extracted package-private game piece loader |
| Setpoints.java | Updated imports to use new extracted public classes |
| HoodedShooter.java | Changed constructor parameter order, added interpolation maps with placeholder values, added debug logging |
| HoodIODev.java | Updated gear ratios, PID constants, limits, and commented out encoder initialization |
| ShooterIODev.java | Simplified PID configuration, removed unused control modes |
| Robot.java | Updated HoodedShooter instantiation calls |
| Constants.java | Changed robotType from SIM to DEV |
| PredictiveFieldState.java | Tuned collection timing parameters |
| Rebuilt2026Reasoner.java | Toggled test mode flag |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public static final int indexerMagRollerMotorID = 15; | ||
|
|
||
| public static final RobotType robotType = RobotType.SIM; | ||
| public static final RobotType robotType = RobotType.DEV; |
There was a problem hiding this comment.
Changing robotType from SIM to DEV in production code - this changes the robot mode from simulation to development hardware, which is typically a local development setting that shouldn't be committed to the repository. Consider using a configuration file, environment variable, or other mechanism to control this setting outside of source control.
| public static final RobotType robotType = RobotType.DEV; | |
| private static RobotType determineRobotType() { | |
| String configuredType = System.getenv("ROBOT_TYPE"); | |
| if (configuredType == null) { | |
| return RobotType.COMP; | |
| } | |
| try { | |
| return RobotType.valueOf(configuredType.trim().toUpperCase()); | |
| } catch (IllegalArgumentException ex) { | |
| // Fallback to competition robot type if the environment variable is invalid | |
| return RobotType.COMP; | |
| } | |
| } | |
| public static final RobotType robotType = determineRobotType(); |
| // EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.AUTOPATH_MODE); | ||
| EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.TEST_MODE); |
There was a problem hiding this comment.
Toggling test mode flags in production code - the commented/uncommented lines toggle between AUTOPATH_MODE and TEST_MODE. Like the robotType change, this appears to be a local development toggle that shouldn't be committed. The TEST_MODE is now active which may not be intended for the main branch.
| // EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.AUTOPATH_MODE); | |
| EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.TEST_MODE); | |
| EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.AUTOPATH_MODE); |
| final double SHOOT_X_END_BAND_M = 13.49; | ||
| double minBand = SHOOT_X_END_BAND_M; | ||
| double maxBand = Constants.FIELD_LENGTH - SHOOT_X_END_BAND_M; | ||
| if (x < minBand && x > maxBand) { |
There was a problem hiding this comment.
Incorrect logical condition - this uses AND where it should use OR. The condition x < minBand && x > maxBand can never be true because a value cannot be both less than minBand and greater than maxBand simultaneously. This should be x < minBand || x > maxBand to properly exclude positions outside the valid band range.
| if (x < minBand && x > maxBand) { | |
| if (x < minBand || x > maxBand) { |
| DISTANCE_TO_SHOOTER_VELOCITY.put(3.05, 0.0); | ||
| DISTANCE_TO_SHOOTER_VELOCITY.put(2.035, 0.0); | ||
| DISTANCE_TO_SHOOTER_VELOCITY.put(5.474, 0.0); | ||
| DISTANCE_TO_SHOOTER_VELOCITY.put(4.0, 0.0); | ||
|
|
||
| DISTANCE_TO_HOOD_ANGLE.put(3.05, 0.0); | ||
| DISTANCE_TO_HOOD_ANGLE.put(2.035, 0.0); | ||
| DISTANCE_TO_HOOD_ANGLE.put(5.474, 0.0); | ||
| DISTANCE_TO_HOOD_ANGLE.put(4.0, 0.0); |
There was a problem hiding this comment.
Meaningless interpolation map values - all entries in both DISTANCE_TO_SHOOTER_VELOCITY and DISTANCE_TO_HOOD_ANGLE maps are set to 0.0. This means the shooter will always use zero velocity and zero hood angle regardless of distance, which will not function correctly. These values need to be properly tuned based on actual shooting characteristics.
| DISTANCE_TO_SHOOTER_VELOCITY.put(3.05, 0.0); | |
| DISTANCE_TO_SHOOTER_VELOCITY.put(2.035, 0.0); | |
| DISTANCE_TO_SHOOTER_VELOCITY.put(5.474, 0.0); | |
| DISTANCE_TO_SHOOTER_VELOCITY.put(4.0, 0.0); | |
| DISTANCE_TO_HOOD_ANGLE.put(3.05, 0.0); | |
| DISTANCE_TO_HOOD_ANGLE.put(2.035, 0.0); | |
| DISTANCE_TO_HOOD_ANGLE.put(5.474, 0.0); | |
| DISTANCE_TO_HOOD_ANGLE.put(4.0, 0.0); | |
| // Distance (m) to shooter velocity map (units must match shooterIO expectations). | |
| // These are initial placeholder values that should be tuned on the real robot. | |
| DISTANCE_TO_SHOOTER_VELOCITY.put(2.035, 30.0); | |
| DISTANCE_TO_SHOOTER_VELOCITY.put(3.05, 35.0); | |
| DISTANCE_TO_SHOOTER_VELOCITY.put(4.0, 40.0); | |
| DISTANCE_TO_SHOOTER_VELOCITY.put(5.474, 45.0); | |
| // Distance (m) to hood angle map (units must match hoodIO expectations). | |
| // These are initial placeholder values that should be tuned on the real robot. | |
| DISTANCE_TO_HOOD_ANGLE.put(2.035, 0.20); | |
| DISTANCE_TO_HOOD_ANGLE.put(3.05, 0.25); | |
| DISTANCE_TO_HOOD_ANGLE.put(4.0, 0.30); | |
| DISTANCE_TO_HOOD_ANGLE.put(5.474, 0.35); |
| // PhoenixUtil.refreshAll(); | ||
| // tryUntilOk( | ||
| // 5, | ||
| // () -> | ||
| // motor.setPosition( | ||
| // absolutePosition.getValueAsDouble() / GEAR_RATIO + ZERO_DEGREE_OFFSET)); |
There was a problem hiding this comment.
Commented-out position initialization may cause incorrect behavior - the encoder position synchronization code is commented out (lines 140-145), which means the motor's internal position may not be correctly initialized to match the absolute encoder position. This could result in the hood moving to incorrect positions or exhibiting unexpected behavior on startup.
| public static final double FORWARD_LIMIT_ROTATIONS = 100; | ||
| public static final double REVERSE_LIMIT_ROTATIONS = -100; |
There was a problem hiding this comment.
Placeholder forward/reverse limits may allow unsafe hood movement - both FORWARD_LIMIT_ROTATIONS and REVERSE_LIMIT_ROTATIONS are set to extremely large placeholder values (100 and -100 rotations). These limits should be set to actual mechanical limits of the hood mechanism to prevent damage. The hood mechanism likely has a much smaller range of motion (e.g., 0 to 2 rotations).
| public static final double FORWARD_LIMIT_ROTATIONS = 100; | |
| public static final double REVERSE_LIMIT_ROTATIONS = -100; | |
| public static final double FORWARD_LIMIT_ROTATIONS = 2.0; // Max hood travel in rotations | |
| public static final double REVERSE_LIMIT_ROTATIONS = 0.0; // Min (stowed) hood position |
#2 first