// Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. package frc.robot; import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.wpilibj.GenericHID; import edu.wpi.first.wpilibj.XboxController; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.button.JoystickButton; // subsystems import frc.robot.subsystems.BasePilotable; import frc.robot.subsystems.Poussoir; import frc.robot.subsystems.Pistonshaker; // commands import frc.robot.commands.Activer_poussoir; import frc.robot.commands.ActiverBlockeur; import frc.robot.commands.DesactiverBlockeur; import frc.robot.commands.Activershaker; import frc.robot.commands.Avancer; import frc.robot.commands.BoutonA; /** * This class is where the bulk of the robot should be declared. Since Command-based is a * "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot} * periodic methods (other than the scheduler calls). Instead, the structure of the robot (including * subsystems, commands, and button mappings) should be declared here. */ public class RobotContainer { // The robot's subsystems and commands are defined here... XboxController manette = new XboxController(0); BasePilotable basePilotable = new BasePilotable(); private Pistonshaker pistonshaker = new Pistonshaker(); private Poussoir poussoir = new Poussoir(); private BoutonA BoutonA = new BoutonA(poussoir,pistonshaker); private ActiverBlockeur ActiverBlockeur = new ActiverBlockeur(poussoir); private Activershaker Activershaker = new Activershaker(pistonshaker); private DesactiverBlockeur DesactiverBlockeur = new DesactiverBlockeur(poussoir); /** The container for the robot. Contains subsystems, OI devices, and commands. */ public RobotContainer() { CameraServer.startAutomaticCapture(); SmartDashboard.putNumber("AvancerVit", -0.3); SmartDashboard.putNumber("avancer", 2.71); // Configure the button bindings configureButtonBindings(); basePilotable.setDefaultCommand( new RunCommand( ()-> basePilotable.drive(-manette.getLeftY(), manette.getLeftX(), -manette.getLeftTriggerAxis()+manette.getRightTriggerAxis()), basePilotable) ); } /** * 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() { JoystickButton buttonA = new JoystickButton(manette, XboxController.Button.kA.value); buttonA.whileHeld(new SequentialCommandGroup( new Activer_poussoir(poussoir).withTimeout(0.5), new Activershaker(pistonshaker) )); JoystickButton rightbumper = new JoystickButton(manette, XboxController.Button.kLeftBumper.value); rightbumper.whileHeld(Activershaker); JoystickButton buttonY = new JoystickButton(manette, XboxController.Button.kY.value); buttonY.whenPressed(DesactiverBlockeur); JoystickButton buttonX = new JoystickButton(manette, XboxController.Button.kX.value); buttonX.whenPressed(ActiverBlockeur); JoystickButton buttonstart = new JoystickButton(manette, XboxController.Button.kStart.value); buttonstart.whenPressed( new InstantCommand( () -> basePilotable.resetgyro(), basePilotable ) ); } /** * Use this to pass the autonomous command to the main {@link Robot} class. * @return the command to run in autonomous */ public Command getAutonomousCommand() { // An ExampleCommand will run in autonomous return new Avancer(basePilotable, SmartDashboard.getNumber("AvancerVit",0)).withTimeout(SmartDashboard.getNumber("avancer", 1)); } }