From 2a484b6f11d12ad59e17b0635b09241d62659523 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Tue, 31 Oct 2023 18:40:44 -0400 Subject: [PATCH] encodeur acc --- .../java/frc/robot/commands/Deaccumuler.java | 4 +-- .../java/frc/robot/commands/Reaccumuler.java | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/main/java/frc/robot/commands/Reaccumuler.java diff --git a/src/main/java/frc/robot/commands/Deaccumuler.java b/src/main/java/frc/robot/commands/Deaccumuler.java index 5342314..c87df83 100644 --- a/src/main/java/frc/robot/commands/Deaccumuler.java +++ b/src/main/java/frc/robot/commands/Deaccumuler.java @@ -16,7 +16,7 @@ public class Deaccumuler extends CommandBase { } // Called when the command is initially scheduled. @Override - public void initialize() {} + public void initialize() {accumulateur.Reset();} // Called every time the scheduler runs while the command is scheduled. @Override @@ -31,6 +31,6 @@ public class Deaccumuler extends CommandBase { // Returns true when the command should end. @Override public boolean isFinished() { - return false; + return (accumulateur.distance()< 1024); } } diff --git a/src/main/java/frc/robot/commands/Reaccumuler.java b/src/main/java/frc/robot/commands/Reaccumuler.java new file mode 100644 index 0000000..0c19887 --- /dev/null +++ b/src/main/java/frc/robot/commands/Reaccumuler.java @@ -0,0 +1,36 @@ +// 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.Accumulateur; + +public class Reaccumuler extends CommandBase { + private Accumulateur accumulateur; + /** Creates a new Lancer. */ + public Reaccumuler(Accumulateur accumulateur) { + this.accumulateur = accumulateur; + addRequirements(accumulateur); + } + // Called when the command is initially scheduled. + @Override + public void initialize() {accumulateur.Reset();} + + // 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 (accumulateur.distance()< -256); + } +}