betabot-2023/src/main/java/frc/robot/RobotContainer.java
samuel desharnais c021192516 gcjvh n
2022-11-23 19:48:58 -05:00

107 lines
4.9 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.wpilibj.smartdashboard.SmartDashboard;
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;
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;
import frc.robot.commands.Activershaker;
import frc.robot.commands.DesactiverBlockeur;
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 Activer_poussoir Activer_poussoir = new Activer_poussoir(poussoir);
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(Activer_poussoir);
JoystickButton rightbumper = new JoystickButton(manette, XboxController.Button.kLeftBumper.value);
rightbumper.whileHeld(Pistonshaker);
JoystickButton buttonY = new JoystickButton(manette, XboxController.Button.kY.value);
buttonY.whenPressed(DesactiverBlockeur, 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(SmartDashboard.getNumber("temps reculer", 1)),
new TournerGauche(basePilotable).withTimeout(SmartDashboard.getNumber("temps tourne gauche1",1)),
new Avancer(basePilotable).withTimeout(SmartDashboard.getNumber("temps avencer1",1)),
new TournerDroite(basePilotable).withTimeout(SmartDashboard.getNumber("temps tourne droite1",1)),
new Avancer(basePilotable).withTimeout(SmartDashboard.getNumber("temps avancer2",1)),
new TournerGauche(basePilotable).withTimeout(SmartDashboard.getNumber("temps tourne gauche2",1)),
new Avancer(basePilotable).withTimeout(SmartDashboard.getNumber("temps avancer3",1)),
new TournerDroite(basePilotable).withTimeout(SmartDashboard.getNumber("temps tourne droite 2",1)),
new Avancer(basePilotable).withTimeout(SmartDashboard.getNumber("temps avancer4",1)),
new DesactiverBlockeur(poussoir).withTimeout(SmartDashboard.getNumber("temps du b1",0.8)),
new Activer_poussoir(poussoir).withTimeout(SmartDashboard.getNumber("temps pousser1",1)),
new Activershaker(pistonshaker).withTimeout(SmartDashboard.getNumber("temps du b2",1)),
new Activer_poussoir(poussoir).withTimeout(SmartDashboard.getNumber("temps pousser2",1)));
}
}