diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 1dcfcba..4305007 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -316,13 +316,7 @@ public Robot() { feeder.setDefaultCommand(Commands.startEnd(feeder::stop, () -> {}, feeder).withName("Stop")); intake.setDefaultCommand(intake.getDefaultCommand()); launcher.setDefaultCommand( - launcher - .initializeHoodCommand() - .andThen( - new RunCommand( - () -> launcher.aim(GameState.getTarget(drive.getPose()).getTranslation()), - launcher) - .withName("Aim at hub"))); + Commands.startEnd(launcher::stop, () -> {}, launcher).withName("Stop")); } /** This function is called periodically during all modes. */ @@ -541,20 +535,10 @@ public boolean getFieldRelativeInput() { // Desaturate turret and advance feeder zorroDriver.AIn(loop).whileTrue(createDesaturateAndShootCommand(controller)); - // Launcher + // Launcher: dial-enabled off the field, always on once connected to the FMS Trigger launcherEnabled = zorroDriver.axisGreaterThan(Axis.kLeftDial.value, 0.5, loop).debounce(0.1); - launcherEnabled - .or(() -> DriverStation.isFMSAttached()) - .whileTrue( - launcher - .initializeHoodCommand() - .andThen( - new RunCommand( - () -> - launcher.aim(GameState.getTarget(drive.getPose()).getTranslation()), - launcher) - .withName("Aim at hub"))); + launcherEnabled.or(() -> DriverStation.isFMSAttached()).whileTrue(aimAtHubCommand()); // Intake zorroDriver.HIn(loop).whileTrue(intake.getDeployCommand()); @@ -562,6 +546,20 @@ public boolean getFieldRelativeInput() { return controller; } + /** + * Builds the launcher's "aim at hub" command: initializes the hood, then continuously tracks the + * hub target. Requires the launcher subsystem. + */ + private Command aimAtHubCommand() { + return launcher + .initializeHoodCommand() + .andThen( + new RunCommand( + () -> launcher.aim(GameState.getTarget(drive.getPose()).getTranslation()), + launcher) + .withName("Aim at hub")); + } + public DriverController bindXboxDriver(int port, EventLoop loop) { var xboxDriver = new CommandXboxController(port); @@ -672,6 +670,9 @@ public boolean getFieldRelativeInput() { // Intake xboxDriver.rightBumper(loop).whileTrue(intake.getDeployCommand()); + // Launcher: no dial to gate it on this controller, so aim unconditionally + new Trigger(loop, () -> true).whileTrue(aimAtHubCommand()); + return controller; } @@ -718,6 +719,9 @@ public boolean getFieldRelativeInput() { .onTrue( Commands.runOnce(() -> DriveCommands.resetDriverForward(drive)).ignoringDisable(true)); + // Launcher: no dial to gate it on this controller, so aim unconditionally + new Trigger(loop, () -> true).whileTrue(aimAtHubCommand()); + return controller; }