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/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index fdd8e5e..976157f 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -33,6 +33,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; @@ -61,6 +62,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); @@ -76,6 +78,7 @@ public class RobotContainer { dashboard.addCamera("limelight", "limelight","limelight.local:5800"); 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(); 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/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; + } +} diff --git a/src/main/java/frc/robot/command/Pistongrimpeur.java b/src/main/java/frc/robot/command/Pistongrimpeur.java index 56df958..93f2da2 100644 --- a/src/main/java/frc/robot/command/Pistongrimpeur.java +++ b/src/main/java/frc/robot/command/Pistongrimpeur.java @@ -29,7 +29,7 @@ public class Pistongrimpeur extends Command { @Override public void execute() { - if(grimpeur.pistonouvre()){ + if(grimpeur.piston()){ LED.couleur(0, 0, 255); } } @@ -38,7 +38,7 @@ public class Pistongrimpeur extends Command { @Override public void end(boolean interrupted) { LED.couleur(0, 0, 0); - grimpeur.pistonferme(); + } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index ba79cfe..0f6f014 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -12,6 +12,7 @@ import edu.wpi.first.networktables.GenericEntry; 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.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; @@ -34,8 +35,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 Grimpeur() { layout.addBoolean("limitgrimpeurd", limitdroite::get); @@ -72,15 +73,16 @@ public AHRS gyroscope = new AHRS(); public double getpitch(){ return gyroscope.getPitch(); } - public boolean pistonouvre(){ - pistondroite.set(Value.kForward); - pistondgauche.set(Value.kForward); - return pistondroite.isFwdSolenoidDisabled(); - } public void pistonferme(){ - pistondroite.set(Value.kReverse); - pistondgauche.set(Value.kReverse); - + pistondroite.set(true); + pistondgauche.set(true); + } + public void pistonouvre(){ + pistondgauche.set(false); + pistondroite.set(false); + } + public boolean piston(){ + return pistondgauche.get(); } @Override public void periodic() { diff --git a/src/main/java/frc/robot/subsystem/LED.java b/src/main/java/frc/robot/subsystem/LED.java index 8bc91cc..dc7a60b 100644 --- a/src/main/java/frc/robot/subsystem/LED.java +++ b/src/main/java/frc/robot/subsystem/LED.java @@ -12,14 +12,19 @@ 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(); - } - 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