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));
});
}
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");
}
}
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()));
}
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);
}
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));
}
Aggregations