From a984da52fd4e46c241d4ff41e2534b3975eb8258 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 22 Feb 2024 18:01:10 -0500 Subject: [PATCH] Commit --- src/main/java/frc/robot/RobotContainer.java | 3 +- .../java/frc/robot/command/LancerTrape.java | 53 +++++++++++++++++++ .../java/frc/robot/subsystem/Lanceur.java | 3 ++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/main/java/frc/robot/command/LancerTrape.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index d2584fc..401822b 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -28,6 +28,7 @@ import frc.robot.command.GuiderHaut; import frc.robot.command.Lancer; import frc.robot.command.LancerAmp; import frc.robot.command.LancerNote; +import frc.robot.command.LancerTrape; import frc.robot.command.Lancerampli; import frc.robot.command.Limelight_tracker; import frc.robot.command.PistonFerme; @@ -93,7 +94,7 @@ public class RobotContainer { joystick.button(5).whileTrue(new LancerAmp(lanceur, accumulateur)); joystick.button(4).whileTrue(new ParallelCommandGroup(new Lancer(lanceur,limelight),new Limelight_tracker(limelight,drive))); joystick.button(2).whileTrue(new ParallelCommandGroup(new Lancerampli(lanceur,limelight),new Limelight_tracker(limelight,drive))); - + joystick.button(6).whileTrue(new LancerTrape(lanceur, accumulateur)); // deplacement configureBindings(); drive.setDefaultCommand(new RunCommand(()->{ diff --git a/src/main/java/frc/robot/command/LancerTrape.java b/src/main/java/frc/robot/command/LancerTrape.java new file mode 100644 index 0000000..3a7a0c5 --- /dev/null +++ b/src/main/java/frc/robot/command/LancerTrape.java @@ -0,0 +1,53 @@ +// 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.command; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystem.Accumulateur; +import frc.robot.subsystem.Lanceur; + +public class LancerTrape extends Command { + private Lanceur lancer; + private Accumulateur accumulateur; + /** Creates a new LancerNote. */ + public LancerTrape(Lanceur lancer, Accumulateur accumulateur) { + this.lancer = lancer; + this.accumulateur = accumulateur; + addRequirements(lancer); + // Use addRequirements() here to declare subsystem dependencies. + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + lancer.pid(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + double vitesse = 0.8; + lancer.Lancertrape(); + if(lancer.vitesse(vitesse)>vitesse){ + accumulateur.Accumuler(); + } + else{ + accumulateur.Accumuler(0); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + lancer.lancer(0); + accumulateur.Accumuler(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystem/Lanceur.java b/src/main/java/frc/robot/subsystem/Lanceur.java index 830a3cc..c377812 100644 --- a/src/main/java/frc/robot/subsystem/Lanceur.java +++ b/src/main/java/frc/robot/subsystem/Lanceur.java @@ -86,6 +86,9 @@ public class Lanceur extends SubsystemBase { } public void lancerspeaker(){ lancer(vitesse.getDouble(0.8)); + } + public void Lancertrape(){ + lancer(vitesse.getDouble(0.8)); } public void lanceramp(){ lancer(vitesseamp.getDouble(0.1));