Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -541,27 +535,31 @@ 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());

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

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Loading