betabot-2023/src/main/java/frc/robot/RobotContainer.java
Antoine PerreaultE 9e78c089be dasd
2022-11-23 19:40:04 -05:00

112 lines
4.5 KiB
Java

// 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.math.estimator.KalmanFilter;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.XboxController.Button;
import edu.wpi.first.wpilibj2.command.Command;
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;
<<<<<<< HEAD
import frc.robot.commands.Activer_poussoir;
=======
<<<<<<< HEAD
import frc.robot.commands.DesactiverBlockeur;
import frc.robot.commands.Reculer;
import frc.robot.commands.TournerDroite;
import frc.robot.commands.TournerGauche;
import frc.robot.commands.Activershaker;
import frc.robot.commands.Avancer;
=======
>>>>>>> db39b5c3db06eed46b45655b80bb22a24e971bb2
import frc.robot.commands.Activershaker;
import frc.robot.commands.DesactiverBlockeur;
>>>>>>> 3d2fed7d28e2c16a03399281bc03d1cf3df4f6d1
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() {
// 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(BoutonA);
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);
}
/**
* 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 SequentialCommandGroup(
new Reculer(basePilotable).withTimeout(0.5),
new TournerGauche(basePilotable).withTimeout(0.5),
new Avancer(basePilotable).withTimeout(0.5),
new TournerDroite(basePilotable).withTimeout(0.5),
new Avancer(basePilotable).withTimeout(0.5),
new TournerGauche(basePilotable).withTimeout(0.5),
new Avancer(basePilotable).withTimeout(0.5),
new TournerDroite(basePilotable).withTimeout(0.5),
new Avancer(basePilotable).withTimeout(0.5),
new Activer_poussoir(poussoir).withTimeout(0.3),
new Activershaker(pistonshaker)
);
}
}