diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index ce8b1e7..11ac9c5 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,9 +4,11 @@ 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 frc.robot.commands.ActiverBlockeur; @@ -16,6 +18,9 @@ import frc.robot.commands.DesactiverBlockeur; import frc.robot.subsystems.BasePilotable; import frc.robot.subsystems.Pistonshaker; import frc.robot.subsystems.Poussoir; +import edu.wpi.first.wpilibj2.command.button.JoystickButton; + + /** * This class is where the bulk of the robot should be declared. Since Command-based is a @@ -53,7 +58,15 @@ public class RobotContainer { * 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() {} + private void configureButtonBindings() { + JoystickButton buttonA = new JoystickButton(manette, XboxController.Button.kA.value); + buttonA.whileHeld(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. diff --git a/src/main/java/frc/robot/commands/Avancer.java b/src/main/java/frc/robot/commands/Avancer.java new file mode 100644 index 0000000..b669a57 --- /dev/null +++ b/src/main/java/frc/robot/commands/Avancer.java @@ -0,0 +1,40 @@ +// 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.commands; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.BasePilotable; + +public class Avancer extends CommandBase { + private BasePilotable basePilotable; + /** Creates a new Avancer. */ + public Avancer(BasePilotable basePilotable) { + basePilotable = new BasePilotable(); + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + basePilotable.drive(0.5, 0.5, 0); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + basePilotable.drive(0, 0, 0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/BoutonA.java b/src/main/java/frc/robot/commands/BoutonA.java new file mode 100644 index 0000000..5490290 --- /dev/null +++ b/src/main/java/frc/robot/commands/BoutonA.java @@ -0,0 +1,32 @@ +// 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.commands; + +import edu.wpi.first.wpilibj2.command.CommandBase; + +public class BoutonA extends CommandBase { + /** Creates a new boutonY. */ + public BoutonA() { + // Use addRequirements() here to declare subsystem dependencies. + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() {} + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) {} + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/Reculer.java b/src/main/java/frc/robot/commands/Reculer.java new file mode 100644 index 0000000..8923870 --- /dev/null +++ b/src/main/java/frc/robot/commands/Reculer.java @@ -0,0 +1,41 @@ +// 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.commands; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.BasePilotable; + +public class Reculer extends CommandBase { + private BasePilotable basePilotable; + /** Creates a new Reculer. */ + public Reculer(BasePilotable basePilotable) { + basePilotable = new BasePilotable(); + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + basePilotable.drive(-0.5, -0.5, 0); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + basePilotable.drive(0, 0, 0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/TournerDroite.java b/src/main/java/frc/robot/commands/TournerDroite.java new file mode 100644 index 0000000..ef211a6 --- /dev/null +++ b/src/main/java/frc/robot/commands/TournerDroite.java @@ -0,0 +1,41 @@ +// 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.commands; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.BasePilotable; + +public class TournerDroite extends CommandBase { + private BasePilotable basePilotable; + /** Creates a new Tourner. */ + public TournerDroite(BasePilotable basePilotable) { + basePilotable = new BasePilotable(); + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + basePilotable.drive(0, 0, 0.5); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + basePilotable.drive(0, 0, 0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/TournerGauche.java b/src/main/java/frc/robot/commands/TournerGauche.java new file mode 100644 index 0000000..04e7b40 --- /dev/null +++ b/src/main/java/frc/robot/commands/TournerGauche.java @@ -0,0 +1,39 @@ +// 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.commands; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.BasePilotable; + +public class TournerGauche extends CommandBase { + private BasePilotable basePilotable; + /** Creates a new TournerGauche. */ + public TournerGauche(BasePilotable basePilotable) { + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + basePilotable.drive(0, 0, -0.5); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + basePilotable.drive(0, 0, 0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +}