From d48996bf5c0035eb11c9df07607b9791615b2abb Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 7 Feb 2024 19:52:54 -0500 Subject: [PATCH 01/15] --- src/main/java/frc/robot/RobotContainer.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 9280c26..daf473c 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -49,21 +49,21 @@ public class RobotContainer { Grimpeur grimpeur = new Grimpeur(); Guideur guideur = new Guideur(); Lanceur lanceur = new Lanceur(); - Balayer balayer = new Balayer(balayeuse, accumulateur); - GuiderHaut guiderHaut = new GuiderHaut(guideur); - GuiderBas guiderBas = new GuiderBas(guideur); Limelight limelight = new Limelight(); - Lancer lancer = new Lancer(lanceur,limelight); - LancerNote lancernote = new LancerNote(lanceur, accumulateur); - Lancerampli lancerampli = new Lancerampli(lanceur,limelight); + LED LED = new LED(); + Pixy pixy = new Pixy(); CommandJoystick joystick = new CommandJoystick(0); CommandXboxController manette = new CommandXboxController(1); //command + Balayer balayer = new Balayer(balayeuse, accumulateur); + GuiderHaut guiderHaut = new GuiderHaut(guideur); + GuiderBas guiderBas = new GuiderBas(guideur); + Lancer lancer = new Lancer(lanceur,limelight); + LancerNote lancernote = new LancerNote(lanceur, accumulateur); + Lancerampli lancerampli = new Lancerampli(lanceur,limelight); GrimpeurDroit grimpeurDroit = new GrimpeurDroit(grimpeur, manette::getLeftX); GrimpeurGauche grimpeurGauche = new GrimpeurGauche(grimpeur, manette::getLeftY); - LED LED = new LED(); AllumeLED allumeLED = new AllumeLED(LED); - Pixy pixy = new Pixy(); public RobotContainer() { NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur)); NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur)); From d87e306b81fc0216ef1ad634f20da1339dfebbb2 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 7 Feb 2024 20:24:12 -0500 Subject: [PATCH 02/15] --- src/main/java/frc/robot/RobotContainer.java | 10 +++- .../frc/robot/command/Pistongrimpeur.java | 49 +++++++++++++++++++ .../java/frc/robot/subsystem/Grimpeur.java | 4 +- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/main/java/frc/robot/command/Pistongrimpeur.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index daf473c..239c7f8 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -12,10 +12,11 @@ import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.math.MathUtil; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; // Manette - +import edu.wpi.first.wpilibj2.command.WaitCommand; // Manettes import edu.wpi.first.wpilibj2.command.button.CommandJoystick; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; @@ -29,6 +30,8 @@ import frc.robot.command.GuiderHaut; 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.Pistongrimpeur; // Subsystems import frc.robot.subsystem.Accumulateur; import frc.robot.subsystem.Balayeuse; @@ -55,6 +58,7 @@ public class RobotContainer { CommandJoystick joystick = new CommandJoystick(0); CommandXboxController manette = new CommandXboxController(1); //command + Limelight_tracker limelight_tracker = new Limelight_tracker(limelight,drive); Balayer balayer = new Balayer(balayeuse, accumulateur); GuiderHaut guiderHaut = new GuiderHaut(guideur); GuiderBas guiderBas = new GuiderBas(guideur); @@ -64,6 +68,7 @@ public class RobotContainer { GrimpeurDroit grimpeurDroit = new GrimpeurDroit(grimpeur, manette::getLeftX); GrimpeurGauche grimpeurGauche = new GrimpeurGauche(grimpeur, manette::getLeftY); AllumeLED allumeLED = new AllumeLED(LED); + Pistongrimpeur pistongrimpeur = new Pistongrimpeur(grimpeur, LED); public RobotContainer() { NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur)); NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur)); @@ -74,6 +79,8 @@ public class RobotContainer { manette.b().whileTrue(guiderHaut); joystick.button(3).toggleOnTrue(balayer); joystick.button(1).whileTrue(lancernote); + joystick.button(4).whileTrue(new ParallelCommandGroup(lancer,limelight_tracker)); + joystick.button(2).whileTrue(new ParallelCommandGroup(lancerampli,limelight_tracker,guiderHaut)); configureBindings(); drive.setDefaultCommand(new RunCommand(()->{ @@ -83,6 +90,7 @@ public class RobotContainer { grimpeur.droit(manette.getLeftX());} ,grimpeur)); LED.setDefaultCommand(allumeLED); + } private void configureBindings() { diff --git a/src/main/java/frc/robot/command/Pistongrimpeur.java b/src/main/java/frc/robot/command/Pistongrimpeur.java new file mode 100644 index 0000000..56df958 --- /dev/null +++ b/src/main/java/frc/robot/command/Pistongrimpeur.java @@ -0,0 +1,49 @@ +// 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; +import frc.robot.subsystem.LED; + +public class Pistongrimpeur extends Command { + private LED LED; + private Grimpeur grimpeur; + /** Creates a new Pistongrimpeur. */ + public Pistongrimpeur(Grimpeur grimpeur,LED LED) { + this.grimpeur = grimpeur; + this.LED = LED; + addRequirements(grimpeur,LED); + // Use addRequirements() here to declare subsystem dependencies. + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + grimpeur.pistonouvre(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + + if(grimpeur.pistonouvre()){ + LED.couleur(0, 0, 255); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + LED.couleur(0, 0, 0); + grimpeur.pistonferme(); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index e2cbc93..3ba9d85 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -76,13 +76,15 @@ public AHRS gyroscope = new AHRS(); public double getpitch(){ return gyroscope.getPitch(); } - public void pistonouvre(){ + 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); + } @Override public void periodic() { From 66ffe4fc919d70f612631674ba79c126ca787757 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 8 Feb 2024 17:52:41 -0500 Subject: [PATCH 03/15] 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 04/15] 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 05/15] --- .../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 06/15] --- 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 07/15] --- 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 08/15] 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();} From 4dd6964cd1cd0f91df9d29e5aa20101ad17b633e Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Thu, 8 Feb 2024 18:59:08 -0500 Subject: [PATCH 09/15] dashboard --- src/main/java/frc/robot/RobotContainer.java | 7 ++++- .../frc/robot/subsystem/Accumulateur.java | 4 ++- .../java/frc/robot/subsystem/Grimpeur.java | 26 ++++++++----------- .../java/frc/robot/subsystem/Guideur.java | 9 +++++-- .../java/frc/robot/subsystem/Lanceur.java | 4 +++ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 239c7f8..fdd8e5e 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -10,6 +10,8 @@ import com.pathplanner.lib.commands.PathPlannerAuto; import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.math.MathUtil; +import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; @@ -45,6 +47,7 @@ import frc.robot.subsystem.Pixy; public class RobotContainer { + ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); private final SendableChooser autoChooser; Drive drive = new Drive(); Accumulateur accumulateur = new Accumulateur(); @@ -70,6 +73,7 @@ public class RobotContainer { AllumeLED allumeLED = new AllumeLED(LED); Pistongrimpeur pistongrimpeur = new Pistongrimpeur(grimpeur, LED); public RobotContainer() { + dashboard.addCamera("limelight", "limelight","limelight.local:5800"); NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur)); NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur)); autoChooser = AutoBuilder.buildAutoChooser(); @@ -98,6 +102,7 @@ public class RobotContainer { } public Command getAutonomousCommand(){ - return autoChooser.getSelected(); + return autoChooser.getSelected() + ; } } diff --git a/src/main/java/frc/robot/subsystem/Accumulateur.java b/src/main/java/frc/robot/subsystem/Accumulateur.java index 2c43a06..c2e53e2 100644 --- a/src/main/java/frc/robot/subsystem/Accumulateur.java +++ b/src/main/java/frc/robot/subsystem/Accumulateur.java @@ -21,7 +21,9 @@ public class Accumulateur extends SubsystemBase { ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); private GenericEntry vitesse = dashboard.add("vitesseacc", 1) - .getEntry(); + .withSize(1, 1) + .withPosition(4, 3) + .getEntry(); final WPI_TalonSRX Moteuracc2 = new WPI_TalonSRX(Constants.Moteuracc2); final WPI_TalonSRX Moteuracc = new WPI_TalonSRX(Constants.Moteuracc); final DigitalInput photocellacc = new DigitalInput(Constants.photocellacc); diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index 3ba9d85..ba79cfe 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -13,7 +13,9 @@ import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.PneumaticsModuleType; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; +import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; @@ -23,6 +25,10 @@ public class Grimpeur extends SubsystemBase { // moteur ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); + ShuffleboardLayout layout = Shuffleboard.getTab("dashboard") + .getLayout("grimpeur", BuiltInLayouts.kList) + .withSize(2,4) + .withPosition(1,1); final CANSparkMax grimpeurd = new CANSparkMax(Constants.grimpeurd,MotorType.kBrushless); final CANSparkMax grimpeurg = new CANSparkMax(Constants.grimpeurg,MotorType.kBrushless); // limit switch @@ -32,21 +38,11 @@ public class Grimpeur extends SubsystemBase { final DoubleSolenoid pistondgauche= new DoubleSolenoid(PneumaticsModuleType.CTREPCM, Constants.pistondgaucheouvre, Constants.pistondroiteouvre); //fonction public Grimpeur() { - dashboard.add("limitgrimpeurd", droite()) - .withSize(1, 1) - .withPosition(1, 5); - dashboard.add("limitgrimpeurd", droite()) - .withSize(1, 1) - .withPosition(1, 4); - dashboard.add("grimpeurencodeurd", encoderd()) - .withSize(1, 1) - .withPosition(1, 3); - dashboard.add("grimpeurencodeurg", encoderg()) - .withSize(1, 1) - .withPosition(1, 2); - dashboard.add("pitchgyrogrimpeur", getpitch()) - .withSize(1, 1) - .withPosition(1, 1); + layout.addBoolean("limitgrimpeurd", limitdroite::get); + layout.addBoolean("limitgrimpeurg", limitdroite::get); + layout.add("grimpeurencodeurd", encoderd()); + layout.add("grimpeurencodeurg", encoderg()); + layout.add("pitchgyrogrimpeur", getpitch()); } public void droit(double vitesse){ grimpeurd.set(vitesse); diff --git a/src/main/java/frc/robot/subsystem/Guideur.java b/src/main/java/frc/robot/subsystem/Guideur.java index c801259..dd8db40 100644 --- a/src/main/java/frc/robot/subsystem/Guideur.java +++ b/src/main/java/frc/robot/subsystem/Guideur.java @@ -8,6 +8,7 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; @@ -16,12 +17,16 @@ public class Guideur extends SubsystemBase { /** Creates a new Guideur. */ ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); + ShuffleboardLayout layout = Shuffleboard.getTab("dashboard") + .getLayout("grimpeur") + .withSize(2, 2) + .withPosition(1, 3); final WPI_TalonSRX guideur = new WPI_TalonSRX(Constants.guideur); final DigitalInput guideurhaut = new DigitalInput(Constants.guideurhaut); final DigitalInput guideurbas = new DigitalInput(Constants.guideurbas); public Guideur() { - dashboard.add("limitguideurhaut", haut()); - dashboard.add("limitguideurbas", bas()); + dashboard.addBoolean("limitguideurhaut", guideurhaut::get); + dashboard.addBoolean("limitguideurbas", guideurbas::get); } public void guider(double vitesse){ guideur.set(vitesse); diff --git a/src/main/java/frc/robot/subsystem/Lanceur.java b/src/main/java/frc/robot/subsystem/Lanceur.java index b14978d..7b1e61a 100644 --- a/src/main/java/frc/robot/subsystem/Lanceur.java +++ b/src/main/java/frc/robot/subsystem/Lanceur.java @@ -18,9 +18,13 @@ public class Lanceur extends SubsystemBase { ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); private GenericEntry vitesse = dashboard.add("vitesse", 1) + .withSize(1, 1) + .withPosition(3, 3) .getEntry(); private GenericEntry vitesseamp = dashboard.add("vitesseamp", 1) + .withSize(1, 1) + .withPosition(3, 4) .getEntry(); public Lanceur() { From 63cb92107e1f5e321a30e6ec9570de72eb90360d Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Thu, 8 Feb 2024 19:10:04 -0500 Subject: [PATCH 10/15] changements --- src/main/java/frc/robot/RobotContainer.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 976157f..d4ba942 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -13,6 +13,7 @@ import edu.wpi.first.math.MathUtil; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; import edu.wpi.first.wpilibj2.command.RunCommand; @@ -97,7 +98,7 @@ public class RobotContainer { grimpeur.droit(manette.getLeftX());} ,grimpeur)); LED.setDefaultCommand(allumeLED); - + SmartDashboard.putData("autochooser",autoChooser); } private void configureBindings() { @@ -105,7 +106,7 @@ public class RobotContainer { } public Command getAutonomousCommand(){ - return autoChooser.getSelected() - ; + return autoChooser.getSelected(); + } } From 95eb98c8126838ab1d1ea8108d6f51cdfb2e9eb4 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Thu, 8 Feb 2024 19:14:30 -0500 Subject: [PATCH 11/15] mode auto --- src/main/java/frc/robot/RobotContainer.java | 4 +++- src/main/java/frc/robot/subsystem/Grimpeur.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index d4ba942..f2b68f4 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -98,7 +98,9 @@ public class RobotContainer { grimpeur.droit(manette.getLeftX());} ,grimpeur)); LED.setDefaultCommand(allumeLED); - SmartDashboard.putData("autochooser",autoChooser); + dashboard.add("autochooser",autoChooser) + .withSize(2,1) + .withPosition(1,1); } private void configureBindings() { diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index 0f6f014..293bdec 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -29,7 +29,7 @@ public class Grimpeur extends SubsystemBase { ShuffleboardLayout layout = Shuffleboard.getTab("dashboard") .getLayout("grimpeur", BuiltInLayouts.kList) .withSize(2,4) - .withPosition(1,1); + .withPosition(2,1); final CANSparkMax grimpeurd = new CANSparkMax(Constants.grimpeurd,MotorType.kBrushless); final CANSparkMax grimpeurg = new CANSparkMax(Constants.grimpeurg,MotorType.kBrushless); // limit switch From 99f3a8fe2ce3c34a5e1b280cd211a302ab317f12 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Thu, 8 Feb 2024 19:47:36 -0500 Subject: [PATCH 12/15] --- src/main/java/frc/robot/command/Lancer.java | 2 +- src/main/java/frc/robot/command/Lancerampli.java | 2 +- src/main/java/frc/robot/command/Limelight_tracker.java | 1 + src/main/java/frc/robot/subsystem/Drive.java | 10 +++++----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/command/Lancer.java b/src/main/java/frc/robot/command/Lancer.java index 01eb49c..e7fa56d 100644 --- a/src/main/java/frc/robot/command/Lancer.java +++ b/src/main/java/frc/robot/command/Lancer.java @@ -19,7 +19,7 @@ public class Lancer extends Command { this.limelight = limelight; this.lanceur = lanceur; // Use addRequirements() here to declare subsystem dependencies. - addRequirements(lanceur,limelight); + addRequirements(lanceur); } // Called when the command is initially scheduled. diff --git a/src/main/java/frc/robot/command/Lancerampli.java b/src/main/java/frc/robot/command/Lancerampli.java index 4a9b3c8..3e1fe59 100644 --- a/src/main/java/frc/robot/command/Lancerampli.java +++ b/src/main/java/frc/robot/command/Lancerampli.java @@ -17,7 +17,7 @@ public class Lancerampli extends Command { private Limelight limelight; public Lancerampli(Lanceur lanceur,Limelight limelight) { // Use addRequirements() here to declare subsystem dependencies. - addRequirements(lanceur, limelight); + addRequirements(lanceur); this.limelight = limelight; this.lanceur = lanceur; } diff --git a/src/main/java/frc/robot/command/Limelight_tracker.java b/src/main/java/frc/robot/command/Limelight_tracker.java index 78d0f91..9b42d82 100644 --- a/src/main/java/frc/robot/command/Limelight_tracker.java +++ b/src/main/java/frc/robot/command/Limelight_tracker.java @@ -29,6 +29,7 @@ public class Limelight_tracker extends Command { if (tracker.getv()){ drive.drive(0,0, tracker.getx()); + } else{ drive.drive(0, 0, 0); diff --git a/src/main/java/frc/robot/subsystem/Drive.java b/src/main/java/frc/robot/subsystem/Drive.java index 7770387..76da4b1 100644 --- a/src/main/java/frc/robot/subsystem/Drive.java +++ b/src/main/java/frc/robot/subsystem/Drive.java @@ -32,6 +32,11 @@ public class Drive extends SubsystemBase { } public Drive() { + try { + this.swerveDrive = new SwerveParser(swerveJsonDirectory).createSwerveDrive(2); + } catch (IOException e) { + e.printStackTrace(); + } AutoBuilder.configureHolonomic(swerveDrive::getPose, swerveDrive::resetOdometry, swerveDrive::getRobotVelocity, swerveDrive::setChassisSpeeds, new HolonomicPathFollowerConfig( new PIDConstants(5,0,0), new PIDConstants(5,0,0), 4.5, 0.275, @@ -43,11 +48,6 @@ public class Drive extends SubsystemBase { } return false; }, this); - try { - this.swerveDrive = new SwerveParser(swerveJsonDirectory).createSwerveDrive(2); - } catch (IOException e) { - e.printStackTrace(); - } } public SwerveModulePosition[] distance(){ From d503dc61276ccdb64b559c95a9c7b7779d0291a5 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Thu, 8 Feb 2024 19:53:38 -0500 Subject: [PATCH 13/15] --- src/main/java/frc/robot/RobotContainer.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index f2b68f4..974b246 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -67,8 +67,7 @@ public class RobotContainer { Limelight_tracker limelight_tracker = new Limelight_tracker(limelight,drive); Balayer balayer = new Balayer(balayeuse, accumulateur); GuiderHaut guiderHaut = new GuiderHaut(guideur); - GuiderBas guiderBas = new GuiderBas(guideur); - Lancer lancer = new Lancer(lanceur,limelight); + Lancer lancer = new Lancer(lanceur,limelight); LancerNote lancernote = new LancerNote(lanceur, accumulateur); Lancerampli lancerampli = new Lancerampli(lanceur,limelight); GrimpeurDroit grimpeurDroit = new GrimpeurDroit(grimpeur, manette::getLeftX); @@ -83,10 +82,10 @@ public class RobotContainer { autoChooser = AutoBuilder.buildAutoChooser(); CameraServer.startAutomaticCapture(); - manette.a().whileTrue(guiderBas); - manette.b().whileTrue(guiderHaut); - joystick.button(3).toggleOnTrue(balayer); - joystick.button(1).whileTrue(lancernote); + manette.a().whileTrue(new GuiderBas(guideur)); + manette.b().whileTrue(new GuiderHaut(guideur)); + joystick.button(3).toggleOnTrue(new Balayer(balayeuse, accumulateur)); + joystick.button(1).whileTrue(new LancerNote(lanceur, accumulateur)); joystick.button(4).whileTrue(new ParallelCommandGroup(lancer,limelight_tracker)); joystick.button(2).whileTrue(new ParallelCommandGroup(lancerampli,limelight_tracker,guiderHaut)); From 6490a6137800a4caedcabb5437be6b5262687b1c Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Thu, 8 Feb 2024 19:55:16 -0500 Subject: [PATCH 14/15] --- src/main/java/frc/robot/RobotContainer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 974b246..d9eb65f 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -88,7 +88,6 @@ public class RobotContainer { joystick.button(1).whileTrue(new LancerNote(lanceur, accumulateur)); joystick.button(4).whileTrue(new ParallelCommandGroup(lancer,limelight_tracker)); joystick.button(2).whileTrue(new ParallelCommandGroup(lancerampli,limelight_tracker,guiderHaut)); - configureBindings(); drive.setDefaultCommand(new RunCommand(()->{ drive.drive(-MathUtil.applyDeadband(joystick.getY(),0.2), MathUtil.applyDeadband(-joystick.getX(),0.2), MathUtil.applyDeadband(-joystick.getZ(), 0.2)); From db3c800ae17d20f9f0456e785bb2d49eab6658e5 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Thu, 8 Feb 2024 20:16:02 -0500 Subject: [PATCH 15/15] --- simgui-ds.json | 9 ++++ simgui.json | 53 ++++++++++++++++++++- src/main/java/frc/robot/RobotContainer.java | 5 +- 3 files changed, 62 insertions(+), 5 deletions(-) diff --git a/simgui-ds.json b/simgui-ds.json index 73cc713..1fa3b25 100644 --- a/simgui-ds.json +++ b/simgui-ds.json @@ -88,5 +88,14 @@ "buttonCount": 0, "povCount": 0 } + ], + "robotJoysticks": [ + { + "guid": "030000006d04000015c2000000000000" + }, + { + "guid": "78696e70757401000000000000000000", + "useGamepad": true + } ] } diff --git a/simgui.json b/simgui.json index 4da2b3d..5febc02 100644 --- a/simgui.json +++ b/simgui.json @@ -1,12 +1,61 @@ { + "HALProvider": { + "DIO": { + "window": { + "visible": true + } + } + }, "NTProvider": { "types": { "/FMSInfo": "FMSInfo", + "/Shuffleboard/dashboard/autochooser": "String Chooser", "/SmartDashboard/Field": "Field2d", "/SmartDashboard/Pigeon IMU [0]": "Gyro" + }, + "windows": { + "/SmartDashboard/Field": { + "bottom": 1476, + "height": 8.210550308227539, + "left": 150, + "right": 2961, + "top": 79, + "width": 16.541748046875, + "window": { + "visible": true + } + } } }, - "NetworkTables Info": { - "visible": true + "NetworkTables": { + "transitory": { + "SmartDashboard": { + "Field": { + "open": true + }, + "open": true + } + } + }, + "NetworkTables View": { + "visible": false + }, + "Plot": { + "Plot <0>": { + "plots": [ + { + "backgroundColor": [ + 0.0, + 0.0, + 0.0, + 0.8500000238418579 + ], + "height": 332 + } + ], + "window": { + "visible": false + } + } } } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index d9eb65f..9461c4a 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -64,7 +64,6 @@ public class RobotContainer { 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); Lancer lancer = new Lancer(lanceur,limelight); @@ -86,8 +85,8 @@ public class RobotContainer { manette.b().whileTrue(new GuiderHaut(guideur)); joystick.button(3).toggleOnTrue(new Balayer(balayeuse, accumulateur)); joystick.button(1).whileTrue(new LancerNote(lanceur, accumulateur)); - joystick.button(4).whileTrue(new ParallelCommandGroup(lancer,limelight_tracker)); - joystick.button(2).whileTrue(new ParallelCommandGroup(lancerampli,limelight_tracker,guiderHaut)); + 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),new GuiderHaut(guideur))); configureBindings(); drive.setDefaultCommand(new RunCommand(()->{ drive.drive(-MathUtil.applyDeadband(joystick.getY(),0.2), MathUtil.applyDeadband(-joystick.getX(),0.2), MathUtil.applyDeadband(-joystick.getZ(), 0.2));