From 66ffe4fc919d70f612631674ba79c126ca787757 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 8 Feb 2024 17:52:41 -0500 Subject: [PATCH 1/6] piston --- src/main/java/frc/robot/subsystem/Grimpeur.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index 4f595c4..7d6ce03 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -11,6 +11,7 @@ import com.revrobotics.CANSparkLowLevel.MotorType; import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.PneumaticsModuleType; +import edu.wpi.first.wpilibj.Solenoid; import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; @@ -24,8 +25,8 @@ public class Grimpeur extends SubsystemBase { // limit switch final DigitalInput limitdroite = new DigitalInput(Constants.limithaut); final DigitalInput limitgauche = new DigitalInput(Constants.limitbas); - final DoubleSolenoid pistondroite= new DoubleSolenoid(PneumaticsModuleType.CTREPCM, Constants.pistondroiteouvre, Constants.pistondroiteouvre); - final DoubleSolenoid pistondgauche= new DoubleSolenoid(PneumaticsModuleType.CTREPCM, Constants.pistondgaucheouvre, Constants.pistondroiteouvre); + final Solenoid pistondroite= new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondroiteouvre); + final Solenoid pistondgauche = new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondgaucheouvre); //fonction public void droit(double vitesse){ grimpeurd.set(vitesse); @@ -56,12 +57,12 @@ public AHRS gyroscope = new AHRS(); return gyroscope.getPitch(); } public void pistonouvre(){ - pistondroite.set(Value.kForward); - pistondgauche.set(Value.kForward); + pistondroite.get(); + pistondgauche.get(); } public void pistonferme(){ - pistondroite.set(Value.kReverse); - pistondgauche.set(Value.kReverse); + pistondroite.get(); + pistondgauche.get(); } @Override public void periodic() { From a62698d6411d53a558b6906b17601b073cdd3e00 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 8 Feb 2024 18:03:35 -0500 Subject: [PATCH 2/6] piston --- build.gradle | 2 +- src/main/java/frc/robot/command/Pistongrimpeur.java | 4 ++-- src/main/java/frc/robot/subsystem/Grimpeur.java | 12 ++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index c73a804..2348bae 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2024.1.1" + id "edu.wpi.first.GradleRIO" version "2024.2.1" } java { diff --git a/src/main/java/frc/robot/command/Pistongrimpeur.java b/src/main/java/frc/robot/command/Pistongrimpeur.java index 2bb6bbc..93f2da2 100644 --- a/src/main/java/frc/robot/command/Pistongrimpeur.java +++ b/src/main/java/frc/robot/command/Pistongrimpeur.java @@ -22,14 +22,14 @@ public class Pistongrimpeur extends Command { // Called when the command is initially scheduled. @Override public void initialize() { - grimpeur.pistondroiteouvre(); + grimpeur.pistonouvre(); } // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(grimpeur.pistondgaucheouvre()){ + if(grimpeur.piston()){ LED.couleur(0, 0, 255); } } diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index eb41d70..725db90 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -77,13 +77,17 @@ public AHRS gyroscope = new AHRS(); public double getpitch(){ return gyroscope.getPitch(); } - public boolean pistondroiteouvre(){ - return pistondroite.get(); + public void pistonferme(){ + pistondroite.set(true); + pistondgauche.set(true); } - public boolean pistondgaucheouvre(){ + public void pistonouvre(){ + pistondgauche.set(false); + pistondroite.set(false); + } + public boolean piston(){ return pistondgauche.get(); } - @Override public void periodic() { // This method will be called once per scheduler run From ab9fa69e724decc3d5381b489e3a8fbc6d8f15de Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 8 Feb 2024 18:07:16 -0500 Subject: [PATCH 3/6] --- .../java/frc/robot/command/PistonFerme.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/frc/robot/command/PistonFerme.java diff --git a/src/main/java/frc/robot/command/PistonFerme.java b/src/main/java/frc/robot/command/PistonFerme.java new file mode 100644 index 0000000..b4ef3fd --- /dev/null +++ b/src/main/java/frc/robot/command/PistonFerme.java @@ -0,0 +1,38 @@ +// 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.Grimpeur; + +public class PistonFerme extends Command { + private Grimpeur grimpeur; + /** Creates a new PistonFerme. */ + public PistonFerme(Grimpeur grimpeur) { + this.grimpeur = grimpeur; + addRequirements(grimpeur); + // Use addRequirements() here to declare subsystem dependencies. + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + grimpeur.pistonferme(); + } + + // 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 true; + } +} From ce99144cd29f7b746ee4e1e1f729cbde59e5261d Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 8 Feb 2024 18:21:44 -0500 Subject: [PATCH 4/6] --- src/main/java/frc/robot/RobotContainer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 239c7f8..59d1c68 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -31,6 +31,7 @@ import frc.robot.command.Lancer; import frc.robot.command.LancerNote; import frc.robot.command.Lancerampli; import frc.robot.command.Limelight_tracker; +import frc.robot.command.PistonFerme; import frc.robot.command.Pistongrimpeur; // Subsystems import frc.robot.subsystem.Accumulateur; @@ -58,6 +59,7 @@ public class RobotContainer { CommandJoystick joystick = new CommandJoystick(0); CommandXboxController manette = new CommandXboxController(1); //command + PistonFerme pistonFerme = new PistonFerme(grimpeur); Limelight_tracker limelight_tracker = new Limelight_tracker(limelight,drive); Balayer balayer = new Balayer(balayeuse, accumulateur); GuiderHaut guiderHaut = new GuiderHaut(guideur); @@ -72,6 +74,7 @@ public class RobotContainer { public RobotContainer() { NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur)); NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur)); + NamedCommands.registerCommand("piston", new PistonFerme(grimpeur)); autoChooser = AutoBuilder.buildAutoChooser(); CameraServer.startAutomaticCapture(); From 6f12bd08ae1b656b2bd5ad07234e563bf8ff8808 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 8 Feb 2024 18:35:50 -0500 Subject: [PATCH 5/6] --- src/main/java/frc/robot/command/GrimpeurDroit.java | 1 + src/main/java/frc/robot/subsystem/LED.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/command/GrimpeurDroit.java b/src/main/java/frc/robot/command/GrimpeurDroit.java index 0aa2c46..20ff35e 100644 --- a/src/main/java/frc/robot/command/GrimpeurDroit.java +++ b/src/main/java/frc/robot/command/GrimpeurDroit.java @@ -56,6 +56,7 @@ public class GrimpeurDroit extends Command { @Override public void end(boolean interrupted) { grimpeur.droit(0); + grimpeur.pistonouvre(); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/subsystem/LED.java b/src/main/java/frc/robot/subsystem/LED.java index 8bc91cc..27fdba3 100644 --- a/src/main/java/frc/robot/subsystem/LED.java +++ b/src/main/java/frc/robot/subsystem/LED.java @@ -15,11 +15,16 @@ public class LED extends SubsystemBase { AddressableLEDBuffer ledBuffer = new AddressableLEDBuffer(60); public void led(){ led.setData(ledBuffer); - led.start(); - } - public void couleur(int R, int G, int B){ - ledBuffer.setRGB(0, R, G, B); + led.start();} + + public void couleur(int R, int G,int B){ + for (int i = 0; i < ledBuffer.getLength(); i++) { + // Sets the specified LED to the RGB values for red + ledBuffer.setRGB(i, 255, 0, 0);} + } + + @Override public void periodic() { // This method will be called once per scheduler run From afafcab866629716765fc8395a9d23758b55f6d6 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 8 Feb 2024 18:36:48 -0500 Subject: [PATCH 6/6] led --- src/main/java/frc/robot/subsystem/LED.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystem/LED.java b/src/main/java/frc/robot/subsystem/LED.java index 27fdba3..dc7a60b 100644 --- a/src/main/java/frc/robot/subsystem/LED.java +++ b/src/main/java/frc/robot/subsystem/LED.java @@ -12,7 +12,7 @@ public class LED extends SubsystemBase { /** Creates a new LED. */ public LED() {} AddressableLED led = new AddressableLED(9); - AddressableLEDBuffer ledBuffer = new AddressableLEDBuffer(60); + AddressableLEDBuffer ledBuffer = new AddressableLEDBuffer(150); public void led(){ led.setData(ledBuffer); led.start();}