Search in sources :

Example 1 with InstantCommand

use of edu.wpi.first.wpilibj2.command.InstantCommand in project 2022RapidReact by momentumfrc.

the class RobotContainer method configureButtonBindings.

/**
 * Used to define button->command mappings.
 */
private void configureButtonBindings() {
    // ---------------------------------- Intake ----------------------------------
    this.intakeFwd.apply(button -> {
        button.whenPressed(new InstantCommand(this::beginIntake, this.intakeSubsystem)).whenHeld(new RunCommand(() -> this.runIntake(false), this.intakeSubsystem)).whenReleased(new RunCommand(this::endIntake, this.intakeSubsystem));
    });
    this.intakeRev.apply(button -> {
        button.whenPressed(new InstantCommand(this::beginIntake, this.intakeSubsystem)).whenHeld(new RunCommand(() -> this.runIntake(true), this.intakeSubsystem)).whenReleased(new RunCommand(this::endIntake, this.intakeSubsystem));
    });
    // ---------------------------------- Shooter ---------------------------------
    this.shoot.apply(button -> {
        button.whenHeld(new RunCommand(this::shoot, this.shooterSubsystem)).whenReleased(new InstantCommand(this::stopShooting, this.shooterSubsystem));
    });
}
Also used : InstantCommand(edu.wpi.first.wpilibj2.command.InstantCommand) RunCommand(edu.wpi.first.wpilibj2.command.RunCommand)

Example 2 with InstantCommand

use of edu.wpi.first.wpilibj2.command.InstantCommand in project 2022RobotCode by AusTINCANsProgrammingTeam.

the class RobotContainer method configureButtonBindings.

// Use this method to define your button->command mappings. Buttons can be
// created by
// instantiating a {@link GenericHID} or one of its subclasses ({@link
// edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing
// it to a {@link
// edu.wpi.first.wpilibj2.command.button.JoystickButton}.
private void configureButtonBindings() {
    controllerCheck();
    // Intake / CDS
    if (intakeForwardCommand != null && outtakeCommand != null) {
        // takes ball in
        buttons[Constants.RTriggerButton].whileHeld(intakeForwardCommand);
        // spits ball out
        buttons[Constants.RBumper].whileHeld(outtakeCommand);
    }
    if (shooterSubsystem != null && shooterHeldLow != null && shooterHeldAuto != null) {
        // Auto Aim Shot
        buttons[Constants.LTriggerButton].whileHeld(shooterHeldAuto.beforeStarting(() -> {
            shooterSubsystem.setAimMode(Constants.AimModes.TARMAC);
        }, shooterSubsystem));
        // Fender Shot
        buttons[Constants.LBumper].whileHeld(shooterHeldLow.beforeStarting(() -> {
            shooterSubsystem.setAimMode(Constants.AimModes.LOW);
        }, shooterSubsystem));
    }
    if (axisCount1 == 0 && buttonCount1 == 0) {
        // Shooter
        if (shooterSubsystem != null && shooterHeldAuto != null) {
            buttons[Constants.backButton].whenPressed(shooterHeldAuto);
            buttons[Constants.LJoystickButton].whenPressed(new InstantCommand(shooterSubsystem::cycleAimModeNext, shooterSubsystem));
            buttons[Constants.RJoystickButton].whenPressed(new InstantCommand(shooterSubsystem::cycleAimModePrevious, shooterSubsystem));
        }
        // Limelight
        if (limelightAlign != null) {
            buttons[Constants.startButton].whenPressed(limelightAlign);
        }
        // ClimbSubysystem has no binding because there are not enuf axises
        if (climbSubsystem != null) {
        }
        System.out.printf("Using Testing One-controller button mappings");
    } else {
        if (climbSubsystem != null) {
            buttons2[Constants.startButton].whenPressed(ClimbEnabling);
        }
        if (outtakeCommand != null && CDSForwardCommand != null) {
            buttons[Constants.RTriggerButton].whileHeld(CDSForwardCommand);
            buttons2[Constants.RBumper].whileHeld(outtakeCommand);
        }
        System.out.printf("Using Competition Two-controller button mappings");
    }
}
Also used : InstantCommand(edu.wpi.first.wpilibj2.command.InstantCommand)

Example 3 with InstantCommand

use of edu.wpi.first.wpilibj2.command.InstantCommand in project toothless by flamingchickens1540.

the class FeatherClient method configureController.

/**
 * Configures button bindings on an xbox controller
 *
 * @param controller xbox controller
 */
public static void configureController(XboxController controller) {
    // coop:button(Y,Over,pilot)
    new JoystickButton(controller, XboxController.Button.kY.value).whenPressed(new InstantCommand(() -> setLastShotResult(ShotResult.OVER)));
    // coop:button(X,OK,pilot)
    new JoystickButton(controller, XboxController.Button.kX.value).whenPressed(new InstantCommand(() -> setLastShotResult(ShotResult.OK)));
    // coop:button(B,Bounced,pilot)
    new JoystickButton(controller, XboxController.Button.kB.value).whenPressed(new InstantCommand(() -> setLastShotResult(ShotResult.BOUNCED)));
    // coop:button(A,Under,pilot)
    new JoystickButton(controller, XboxController.Button.kA.value).whenPressed(new InstantCommand(() -> setLastShotResult(ShotResult.UNDER)));
    // coop:button(Start,Unknown,pilot)
    new JoystickButton(controller, XboxController.Button.kStart.value).whenPressed(new InstantCommand(() -> setLastShotResult(ShotResult.UNKNOWN)));
    // coop:button(Back,Undo,pilot)
    new JoystickButton(controller, XboxController.Button.kBack.value).whenPressed(new InstantCommand(() -> undoSetLastShotResult()));
}
Also used : JoystickButton(edu.wpi.first.wpilibj2.command.button.JoystickButton) InstantCommand(edu.wpi.first.wpilibj2.command.InstantCommand)

Example 4 with InstantCommand

use of edu.wpi.first.wpilibj2.command.InstantCommand in project CodeCloset2022 by FRC7540.

the class RobotContainer method configureButtonBindings.

private void configureButtonBindings() {
    // (May switch InstantCommand to RunCommand, if this doesn't work.)
    new JoystickButton(m_operatorController, Button.kY.value).whenHeld(new AutoShoot(m_tower), false);
    new JoystickButton(m_operatorController, Button.kX.value).whenHeld(new AutoIntake(m_tower, m_intake), false);
    new JoystickButton(m_operatorController, Button.kA.value).whenPressed(new LowerFeeder(m_intake), true);
    new JoystickButton(m_operatorController, Button.kB.value).whenPressed(new RaiseFeeder(m_intake), true);
    new JoystickButton(m_driverController, Button.kX.value).whenPressed(new StopFeeder(m_intake), false);
    new JoystickButton(m_operatorController, Button.kStart.value).whenPressed(new InstantCommand(() -> setCommandScheduler(false)), false);
    new JoystickButton(m_operatorController, Button.kBack.value).whenPressed(new InstantCommand(() -> setCommandScheduler(true)), false);
}
Also used : JoystickButton(edu.wpi.first.wpilibj2.command.button.JoystickButton) InstantCommand(edu.wpi.first.wpilibj2.command.InstantCommand) RaiseFeeder(frc.robot.commands.RaiseFeeder) AutoIntake(frc.robot.commands.AutoIntake) LowerFeeder(frc.robot.commands.LowerFeeder) AutoShoot(frc.robot.commands.AutoShoot) StopFeeder(frc.robot.commands.StopFeeder)

Example 5 with InstantCommand

use of edu.wpi.first.wpilibj2.command.InstantCommand in project 2022-competition by A05annex.

the class RobotContainer method configureButtonBindings.

/**
 * Use this method to define your button->command mappings. Buttons can be created by
 * instantiating a {@link GenericHID} or one of its subclasses ({@link
 * edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing it to a {@link
 * edu.wpi.first.wpilibj2.command.button.JoystickButton}.
 */
private void configureButtonBindings() {
    // Reset the NavX field relativity
    m_xboxBack.whenPressed(new InstantCommand(m_navx::initializeHeadingAndNav));
    m_xboxX.whenPressed(new CollectorJerkCommand());
    m_xboxB.whenPressed(new ShooterCommand(ShooterSubsystem.AUTO_BALL_FRONT, ShooterSubsystem.AUTO_BALL_REAR));
    m_xboxY.whenPressed(new ShooterSetSpeedCommand());
    // m_xboxA.whenPressed(new ShooterCommand(ShooterSubsystem.DUMP_SPEED_FRONT, ShooterSubsystem.DUMP_SPEED_REAR));
    m_xboxA.whenPressed(new DoubleShootCommand(ShooterSubsystem.AUTO_BALL_FRONT, ShooterSubsystem.AUTO_BALL_REAR));
}
Also used : InstantCommand(edu.wpi.first.wpilibj2.command.InstantCommand)

Aggregations

InstantCommand (edu.wpi.first.wpilibj2.command.InstantCommand)28 JoystickButton (edu.wpi.first.wpilibj2.command.button.JoystickButton)11 PIDController (edu.wpi.first.math.controller.PIDController)4 Command (edu.wpi.first.wpilibj2.command.Command)4 RunCommand (edu.wpi.first.wpilibj2.command.RunCommand)4 ProfiledPIDController (edu.wpi.first.math.controller.ProfiledPIDController)3 Trigger (edu.wpi.first.wpilibj2.command.button.Trigger)3 PPSwerveControllerCommand (com.pathplanner.lib.commands.PPSwerveControllerCommand)2 RamseteController (edu.wpi.first.math.controller.RamseteController)2 TrapezoidProfile (edu.wpi.first.math.trajectory.TrapezoidProfile)2 ParallelCommandGroup (edu.wpi.first.wpilibj2.command.ParallelCommandGroup)2 RamseteCommand (edu.wpi.first.wpilibj2.command.RamseteCommand)2 SequentialCommandGroup (edu.wpi.first.wpilibj2.command.SequentialCommandGroup)2 WaitCommand (edu.wpi.first.wpilibj2.command.WaitCommand)2 POVButton (edu.wpi.first.wpilibj2.command.button.POVButton)2 AutoShoot (frc.robot.commands.AutoShoot)2 LowerFeeder (frc.robot.commands.LowerFeeder)2 DrivetrainSubsystem (org.snobotv2.examples.base.subsystems.DrivetrainSubsystem)2 ToggleZeroTurretHood (com.lightningrobotics.voidrobot.commands.ToggleZeroTurretHood)1 SimpleMotorFeedforward (edu.wpi.first.math.controller.SimpleMotorFeedforward)1