Skip to content

Commit

Permalink
Comp can be dirty.
Browse files Browse the repository at this point in the history
at least auto works.
  • Loading branch information
PatribotsProgramming committed Apr 5, 2024
1 parent 79f3398 commit aa0af84
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public void disabledExit() {
@Override
public void autonomousInit() {
// Update "constants"
Monologue.updateAll();
DriveConstants.MAX_SPEED_METERS_PER_SECOND = AutoConstants.MAX_SPEED_METERS_PER_SECOND;
Robot.gameMode = GameMode.AUTONOMOUS;
robotContainer.onEnabled();
Expand Down
39 changes: 34 additions & 5 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,15 @@ public RobotContainer() {
() -> driver.getLeftTrigger() || (!OIConstants.SINGLE_DRIVER_MODE && operator.getLeftBumper())
)
);

BooleanSupplier autoDecisionMaker;
if (FieldConstants.IS_SIMULATION) {
autoDecisionMaker = driver::getYButton;
} else {
autoDecisionMaker = colorSensor::hasNote;
}
pathPlannerStorage = new PathPlannerStorage(autoDecisionMaker, swerve, limelight3);

pathPlannerStorage = new PathPlannerStorage(colorSensor::hasNote, swerve, limelight3);
initializeComponents();
prepareNamedCommands();

Expand Down Expand Up @@ -734,15 +741,37 @@ public void updateNTGains() {
}

private void prepareNamedCommands() {
// TODO: prepare to shoot while driving (w1 - c1)
NamedCommands.registerCommand("Intake", pieceControl.intakeAuto());
NamedCommands.registerCommand("ToIndexer", pieceControl.intakeUntilNote());
// If you can fix this formatting I salute you
NamedCommands.registerCommand("ToIndexer",
Commands.either(
pieceControl.intakeUntilNote(),
Commands.waitUntil(driver::getYButton),
() -> !FieldConstants.IS_SIMULATION
)
);
NamedCommands.registerCommand("StopIntake", pieceControl.stopIntakeAndIndexer());
NamedCommands.registerCommand("StopAll", pieceControl.stopAllMotors());
NamedCommands.registerCommand("PrepareShooter", shooterCmds.prepareFireCommandAuto(swerve::getPose));
NamedCommands.registerCommand("Shoot", pieceControl.noteToShoot(swerve::getPose, swerve::getRobotRelativeVelocity));
NamedCommands.registerCommand("ShootInstantly", pieceControl.noteToShootUsingSensor(swerve::getPose, swerve::getRobotRelativeVelocity));
NamedCommands.registerCommand("ShootInstantlyWhenReady", Commands.waitSeconds(.4).andThen(pieceControl.noteToShootUsingSensorWhenReady(swerve::getPose, swerve::getRobotRelativeVelocity)));
NamedCommands.registerCommand("ShootInstantly",
Commands.either(
pieceControl.noteToShootUsingSensor(swerve::getPose, swerve::getRobotRelativeVelocity),
Commands.waitUntil(() -> !driver.getYButton()),
() -> !FieldConstants.IS_SIMULATION
)
);
// This one too, what a necessary nightmare :(
NamedCommands.registerCommand("ShootInstantlyWhenReady",
Commands.waitSeconds(.4)
.andThen(
Commands.either(
pieceControl.noteToShootUsingSensorWhenReady(swerve::getPose, swerve::getRobotRelativeVelocity),
Commands.waitUntil(() -> !driver.getYButton()),
() -> !FieldConstants.IS_SIMULATION
)
)
);
NamedCommands.registerCommand("ShootWhenReady", pieceControl.shootPreload());
NamedCommands.registerCommand("RaiseElevator", elevator.toTopCommand());
NamedCommands.registerCommand("LowerElevator", elevator.toBottomCommand());
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/frc/robot/subsystems/Swerve.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ public Rotation2d getGyroRotation2d() {
return this.gyroRotation2d;
}

public boolean insideOwnWing() {
return Robot.isBlueAlliance()
? getPose().getX() < FieldConstants.BLUE_WING_X
: getPose().getX() > FieldConstants.RED_WING_X;
}

public SwerveDrivePoseEstimator getPoseEstimator() {
return poseEstimator;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/util/auto/PathPlannerStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ private Command generateNonObjectDetectionCommand(int i, int endingNote, boolean
.onlyIf(() -> !colorSensorSupplier.getAsBoolean())))
.andThen(NamedCommands.getCommand("ShootInstantlyWhenReady"))
.deadlineWith(NamedCommands.getCommand("PrepareSWD"))
.raceWith(Commands.waitUntil(() -> !colorSensorSupplier.getAsBoolean() && swerve.insideOwnWing()))

.andThen(
Commands.race(
Commands.sequence(
Expand Down

0 comments on commit aa0af84

Please sign in to comment.