From 4dd6964cd1cd0f91df9d29e5aa20101ad17b633e Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Thu, 8 Feb 2024 18:59:08 -0500 Subject: [PATCH] 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() {