diff --git a/src/main/java/frc/robot/command/Lancer.java b/src/main/java/frc/robot/command/Lancer.java index 0fdc5eb..2d62c50 100644 --- a/src/main/java/frc/robot/command/Lancer.java +++ b/src/main/java/frc/robot/command/Lancer.java @@ -12,14 +12,11 @@ import frc.robot.subsystem.Lanceur; public class Lancer extends Command { /** Creates a new Lanceur. */ - - private Lanceur lancer; - private Lanceur lancer2; - private Lanceur lancer3; - private Lanceur lancer4; + private Lanceur lanceur; public Lancer() { + this.lanceur = lanceur; // Use addRequirements() here to declare subsystem dependencies. - addRequirements(lancer,lancer2,lancer3,lancer4); + addRequirements(lanceur); } // Called when the command is initially scheduled. @@ -29,13 +26,13 @@ public class Lancer extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - lancer.lancer(0.3); + lanceur.lancer(0.3); } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - lancer.lancer(0); + lanceur.lancer(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/command/LancerNote.java b/src/main/java/frc/robot/command/LancerNote.java new file mode 100644 index 0000000..76fed0d --- /dev/null +++ b/src/main/java/frc/robot/command/LancerNote.java @@ -0,0 +1,44 @@ +// 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 LancerNote extends Command { + private Lanceur lancer; + private Accumulateur accumulateur; + /** Creates a new LancerNote. */ + public LancerNote(Lanceur lancer, Accumulateur accumulateur) { + this.lancer = lancer; + this.accumulateur = accumulateur; + // 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() { + double vitesse = 100; + lancer.lancer(vitesse); + if(lancer.vitesse(vitesse)>vitesse){ + accumulateur.Accumuler(0.6); + } + } + + // 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/command/Lancerampli.java b/src/main/java/frc/robot/command/Lancerampli.java index f3588b9..ef4ed14 100644 --- a/src/main/java/frc/robot/command/Lancerampli.java +++ b/src/main/java/frc/robot/command/Lancerampli.java @@ -13,13 +13,12 @@ import frc.robot.subsystem.Lanceur; public class Lancerampli extends Command { /** Creates a new Lanceur. */ - private Lanceur lancer; - private Lanceur lancer2; - private Lanceur lancer3; - private Lanceur lancer4; + private Lanceur lanceur; + public Lancerampli() { // Use addRequirements() here to declare subsystem dependencies. - addRequirements(lancer,lancer2,lancer3,lancer4); + addRequirements(lanceur); + this.lanceur = lanceur; } // Called when the command is initially scheduled. @@ -29,13 +28,13 @@ public class Lancerampli extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - lancer.lancer(0.1); + lanceur.lancer(0.1); } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - lancer.lancer(0); + lanceur.lancer(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/subsystem/Lanceur.java b/src/main/java/frc/robot/subsystem/Lanceur.java index 9edc79b..ddae36a 100644 --- a/src/main/java/frc/robot/subsystem/Lanceur.java +++ b/src/main/java/frc/robot/subsystem/Lanceur.java @@ -25,6 +25,9 @@ public class Lanceur extends SubsystemBase { } public void lancer(double vitesse){ lancer.set(vitesse); + } + public double vitesse(double vitesse){ + return lancer.getEncoder().getVelocity(); } public void lanceur(){ lancer2.follow(lancer);