Skip to content

Add basic driver controls#55

Merged
aidnem merged 29 commits intomainfrom
49-add-basic-driver-controls
Feb 26, 2026
Merged

Add basic driver controls#55
aidnem merged 29 commits intomainfrom
49-add-basic-driver-controls

Conversation

@aidnem
Copy link
Copy Markdown
Contributor

@aidnem aidnem commented Feb 11, 2026

Adds driver controls and a coordinateRobotActions method which:

  • updates match state
  • Handles intake & climber actions together (to avoid extending in 2 directions at once)
  • Determines if vision can be trusted
  • Runs shot calculator for smart or manual modes and determines if we have a "real" shot or are aiming for the closest possible shot when an actual shot is impossible
  • Determines when to run the spindexer/balltower to only shoot when we'll make the shot

@aidnem aidnem linked an issue Feb 11, 2026 that may be closed by this pull request
4 tasks
@aidnem aidnem marked this pull request as ready for review February 24, 2026 18:33
@avidraccoon avidraccoon requested a review from Copilot February 24, 2026 18:33
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 pull request adds basic driver control functionality for teleop operation, establishing a coordination layer that manages robot actions based on controller inputs. The PR implements manual and smart autonomy modes, shooting controls, intake deployment coordination, and hood stowing logic for navigating under field obstacles.

Changes:

  • Added CoordinationLayer class to coordinate subsystem actions based on driver/operator inputs with support for manual and smart autonomy modes
  • Implemented driver and operator controller bindings for intake, shooting, climbing, and autonomy mode switching
  • Added utility classes (EnhancedLine2d, OptionalUtil, AllianceUtil) and subsystem state checking methods (isAimedCorrectly, isAtGoalVelocity, isStowed)

Reviewed changes

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

Show a summary per file
File Description
EnhancedLine2d.java New utility class for 2D line intersection detection to support trench collision detection
OptionalUtil.java New utility class providing helper methods for working with multiple Optional values
AllianceUtil.java Added getOppAlliance() method to get the opposing alliance
TurretSubsystem.java Added isAimedCorrectly() method to check if turret is at goal heading
ShooterSubsystem.java Added coast state, velocity getters, stopShooter(), and isAtGoalVelocity() methods
ShooterState.java Added CoastState for coasting the shooter to a stop
IntakeSubsystem.java Added isStowed() method to check if intake is within frame perimeter
HoodSubsystem.java Added setShouldStowForTrench(), getCurrentAngle(), and isAimedCorrectly() methods
MatchState.java Renamed auto override parameters to weWonAuto/weLostAuto for clarity
CoordinationLayer.java Major refactor: added button loop, state machines for extension coordination, manual/smart mode switching, shot aiming, and hood stowing logic
RobotContainer.java Updated to use CoordinationLayer for bindings and vision localizer initialization
ControllerSetup.java Removed intake and match state bindings (moved to CoordinationLayer)
ShotCalculations.java Modified calculateShotFromMap to always return a shot (clamped if out of range) with isReal flag
VisionConstants.java Added disconnectedDebounceTime for vision connection debouncing
TurretConstants.java Added turretSetpointEpsilon for determining when turret is at target
ShooterConstants.java Added shooterVelocitySetpointEpsilon for velocity tolerance checking
ManualModeConstants.java New constants class for manual mode shooting parameters
JsonConstants.java Added manualModeConstants loading and tuning server route
IntakeConstants.java Added stowThresholdAngle for determining when intake is stowed
IndexerConstants.java Removed indexerDemoMode flag, added indexingVelocity constant
HopperConstants.java Removed hopperDemoMode flag, added indexingVelocity constant
HoodConstants.java Added hoodSetpointEpsilon and timeToStowHood constants
FieldLocations.java Added getManualHubShootingPosition() method
FieldLocationInstance.java Added manualHubShootingPosition field
FieldConstants.java Added oppInnerCenterPoint() method for opponent hub center
AllianceBasedFieldConstants.java New class providing alliance-based field location accessors
controllers-xbox.json Added comprehensive driver and operator bindings for all teleop controls
VisionConstants.json Added disconnectedDebounceTime configuration
ManualModeConstants.json New JSON configuration for manual mode constants
IntakeConstants.json Added stowThresholdAngle configuration
HopperConstants.json Removed hopperDemoMode configuration
FeatureFlags.json Enabled runHood flag

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/frc/robot/CoordinationLayer.java Outdated
Comment thread src/main/java/frc/robot/CoordinationLayer.java
Comment thread src/main/java/frc/robot/CoordinationLayer.java Outdated
Comment thread src/main/java/frc/robot/CoordinationLayer.java
Comment thread src/main/java/frc/robot/util/AllianceUtil.java Outdated
Comment thread src/main/java/frc/robot/subsystems/shooter/ShooterSubsystem.java Outdated
Comment thread src/main/java/frc/robot/subsystems/shooter/ShooterSubsystem.java Outdated
Comment thread src/main/java/frc/robot/CoordinationLayer.java Outdated
Comment thread src/main/java/frc/robot/CoordinationLayer.java
Comment thread src/main/java/frc/robot/CoordinationLayer.java Outdated
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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/frc/robot/CoordinationLayer.java
Comment thread src/main/java/frc/robot/CoordinationLayer.java Outdated
Comment thread src/main/java/frc/robot/util/AllianceUtil.java Outdated
double D = l.d.cross(dneg);

// Use Cramer’s rule
if (D == 0.0) {
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The comparison uses exact equality (==) for floating-point numbers, which is generally unreliable due to floating-point precision issues. Consider using a small epsilon for comparison instead, such as Math.abs(D) < EPSILON.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@godmar is this necessary? I feel like if it's very very small, that just means the lines are super close to parallel right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes. I think that's fine here. If D is very small (close to zero), then dividing by it will be very large, so the test params.[st] < 1.0 should fail; this would be true even if were positive infinity.
The check == 0.0 guards against getting NaN here.

Comment thread src/main/java/frc/robot/CoordinationLayer.java
Comment thread src/main/java/frc/robot/CoordinationLayer.java Outdated
Comment thread src/main/java/frc/robot/subsystems/shooter/ShooterSubsystem.java
Comment thread src/main/java/frc/robot/subsystems/shooter/ShooterSubsystem.java Outdated
@aidnem aidnem requested review from avidraccoon and godmar February 24, 2026 22:23
make every subsystem write a graph viz of its state machine when in sim
Copy link
Copy Markdown
Contributor

@godmar godmar left a comment

Choose a reason for hiding this comment

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

I didn't see anything obviously wrong. This will evolve further anyhow.

Comment thread src/main/java/frc/robot/constants/JsonConstants.java Outdated
* When the turret heading is within turretSetpointEpsilon of its goal heading, it is considered
* to be "at the target"
*/
public final Angle turretSetpointEpsilon = Degrees.of(1.0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if the turrent never makes it this close? Should there be a timeout?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hopefully the shooter will always make it this close. We could add a timeout but I think if it's acceptable to shoot outside of this range then it means we need a wider range.

driveController.setD(gains.kD());
DRIVE_KV = gains.kV();
System.out.println("setDriveGains called with " + gains);
// Don't actually update gains as it causes awful drive performance in sim.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't forget to uncomment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we might want to just leave these as they are, unless we're going to retune the physical sim constants of drive to make it behave properly. If you enable setting the gains in sim, it makes the steer wheels unable to target their setpoint properly and they oscillate indefinitely.

Comment thread src/main/java/frc/robot/subsystems/hood/HoodSubsystem.java Outdated
Comment thread src/main/java/frc/robot/util/OptionalUtil.java Outdated
// location for a manual mode shot if we ever have to run "no turret"
&& turret.map(TurretSubsystem::isAimedCorrectly).orElse(true));

if (canShoot) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Am I reading this logic right that that hopper and indexer won't be activated until the robot is aiming at the target? This will add delay, won't it?

Should we turn the indexer at least on before that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We might want to start running the indexer a bit sooner. The problem is, based on shop testing tonight, the indexer was grabbing fuel by itself without ever running hopper. It managed to shoot 4 before I had time to turn the hopper on.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We might want to start running the indexer a bit sooner. The problem is, based on shop testing tonight, the indexer was grabbing fuel by itself without ever running hopper. It managed to shoot 4 before I had time to turn the hopper on.

Nice.

@aidnem aidnem requested a review from godmar February 26, 2026 03:02
@aidnem aidnem merged commit 2aa5353 into main Feb 26, 2026
3 checks passed
@PChild PChild deleted the 49-add-basic-driver-controls branch April 14, 2026 16:24
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.

Add basic driver controls to coordination layer

3 participants