Skip to content

Commit 2f92390

Browse files
committed
fix ppautocommand requirements
1 parent 8b1e612 commit 2f92390

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/main/java/org/carlmontrobotics/lib199/path/SwerveDriveInterface.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,15 @@ public default Command createPPAutoCommand(List<PathPlannerTrajectory> trajector
118118
requirements = Arrays.copyOf(requirements, requirements.length + 1);
119119
requirements[requirements.length - 1] = this;
120120
requirements = Arrays.stream(requirements).distinct().toArray(Subsystem[]::new);
121+
final Subsystem[] finalRequirements = requirements; // Make this final so it can be used in the anonymous inner class
121122
PIDController[] pidControllers = Arrays.stream(getPIDConstants()).map(constants -> new PIDController(constants[0], constants[1], constants[2])).toArray(PIDController[]::new);
122123
pidControllers[2].enableContinuousInput(-Math.PI, Math.PI);
123124
// Use SwerveAutoBuilder because required argument for base auto builder "DrivetrainType" is protected
124125
return new SwerveAutoBuilder(this::getPose, this::setPose, null, null, null, null, eventMap, true) {
125126
@Override
126127
public CommandBase followPath(PathPlannerTrajectory trajectory) {
127128
// AutoBuilder will convert this to work with events
128-
return new PPSwerveControllerCommand(trajectory, poseSupplier, getKinematics(), pidControllers[0], pidControllers[1], pidControllers[2], SwerveDriveInterface.this::drive, true, SwerveDriveInterface.this);
129+
return new PPSwerveControllerCommand(trajectory, poseSupplier, getKinematics(), pidControllers[0], pidControllers[1], pidControllers[2], SwerveDriveInterface.this::drive, true, finalRequirements /* This will propagate the requirements to the final command via SequentialCommandGroup */);
129130
};
130131
}.followPathGroupWithEvents(trajectory);
131132
}

0 commit comments

Comments
 (0)