Skip to content

Fix#3

Merged
Superbro525Alt merged 11 commits into
2026-mergefrom
fix
Feb 6, 2026
Merged

Fix#3
Superbro525Alt merged 11 commits into
2026-mergefrom
fix

Conversation

@Superbro525Alt
Copy link
Copy Markdown
Member

@Superbro525Alt Superbro525Alt commented Feb 6, 2026

#2 first

Copilot AI review requested due to automatic review settings February 6, 2026 09:34
Copy link
Copy Markdown

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

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;
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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();

Copilot uses AI. Check for mistakes.
Comment on lines +156 to +157
// EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.AUTOPATH_MODE);
EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.TEST_MODE);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
// EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.AUTOPATH_MODE);
EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.TEST_MODE);
EnumSet<BehaviourFlag> out = EnumSet.of(BehaviourFlag.AUTOPATH_MODE);

Copilot uses AI. Check for mistakes.
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) {
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
if (x < minBand && x > maxBand) {
if (x < minBand || x > maxBand) {

Copilot uses AI. Check for mistakes.
Comment on lines +77 to +85
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);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Comment on lines +140 to +145
// PhoenixUtil.refreshAll();
// tryUntilOk(
// 5,
// () ->
// motor.setPosition(
// absolutePosition.getValueAsDouble() / GEAR_RATIO + ZERO_DEGREE_OFFSET));
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +40
public static final double FORWARD_LIMIT_ROTATIONS = 100;
public static final double REVERSE_LIMIT_ROTATIONS = -100;
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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

Copilot uses AI. Check for mistakes.
@Superbro525Alt Superbro525Alt merged commit ff94ac6 into 2026-merge Feb 6, 2026
2 checks passed
@Superbro525Alt Superbro525Alt deleted the fix branch February 6, 2026 10:11
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.

2 participants