From 1b6663c9771e55d16b3c50134c6dfb15f33c5b48 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 6 Feb 2024 19:57:49 -0500 Subject: [PATCH 01/10] Limelight --- src/main/java/frc/robot/subsystem/Limelight.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystem/Limelight.java b/src/main/java/frc/robot/subsystem/Limelight.java index 9fb068b..176616d 100644 --- a/src/main/java/frc/robot/subsystem/Limelight.java +++ b/src/main/java/frc/robot/subsystem/Limelight.java @@ -9,6 +9,7 @@ import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.LimelightHelpers; @@ -16,14 +17,26 @@ public class Limelight extends SubsystemBase { /** Creates a new Limelight. */ public Limelight() { - NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight"); + NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight"); + NetworkTableInstance.getDefault().getTable("limelight").getEntry("Tv").getDouble(0); + NetworkTableInstance.getDefault().getTable("limelight").getEntry("getpipe").getDouble(1); + NetworkTableInstance.getDefault().getTable("limelight").getEntry("").getDoubleArray(new double[6]); + + NetworkTableEntry tx = table.getEntry("tx"); NetworkTableEntry ty = table.getEntry("ty"); NetworkTableEntry ta = table.getEntry("ta"); + NetworkTableEntry botpose = table.getEntry("pose"); + NetworkTableEntry getpipe = table.getEntry(getName()); double x = tx.getDouble(0.0); double y = ty.getDouble(0.0); double area = ta.getDouble(0.0); + double pose = botpose.getDouble(area); + + + + SmartDashboard.putNumber("LimelightX", x); SmartDashboard.putNumber("LimelightY", y); From da4342e4565537ce773302a1918078fcce14aaa2 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 7 Feb 2024 18:05:24 -0500 Subject: [PATCH 02/10] j --- .../java/frc/robot/subsystem/Limelight.java | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/main/java/frc/robot/subsystem/Limelight.java b/src/main/java/frc/robot/subsystem/Limelight.java index 176616d..49291b3 100644 --- a/src/main/java/frc/robot/subsystem/Limelight.java +++ b/src/main/java/frc/robot/subsystem/Limelight.java @@ -14,37 +14,39 @@ import frc.robot.LimelightHelpers; public class Limelight extends SubsystemBase { - /** Creates a new Limelight. */ - public Limelight() { - NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight"); - NetworkTableInstance.getDefault().getTable("limelight").getEntry("Tv").getDouble(0); - NetworkTableInstance.getDefault().getTable("limelight").getEntry("getpipe").getDouble(1); - NetworkTableInstance.getDefault().getTable("limelight").getEntry("").getDoubleArray(new double[6]); - NetworkTableEntry tx = table.getEntry("tx"); NetworkTableEntry ty = table.getEntry("ty"); NetworkTableEntry ta = table.getEntry("ta"); - NetworkTableEntry botpose = table.getEntry("pose"); - NetworkTableEntry getpipe = table.getEntry(getName()); + NetworkTableEntry pipeline = table.getEntry("pipeline"); + NetworkTableEntry tv = table.getEntry("tv"); + NetworkTableEntry camMode = table.getEntry("camMode"); - double x = tx.getDouble(0.0); - double y = ty.getDouble(0.0); - double area = ta.getDouble(0.0); - double pose = botpose.getDouble(area); - - - + + /** Creates a new Limelight. */ + public Limelight() { + } + public double getx(){ + return tx.getDouble(0); + } + public double gety(){ + return ty.getDouble(0); + } + public double geta() { + return ta.getDouble(0); + } + public boolean getv(){ + return tv.getBoolean(false); + } + public double getpipeline(){ + return pipeline.getDouble(0); + } + public double getcamMode(){ + return camMode.getDouble(0); + } - SmartDashboard.putNumber("LimelightX", x); - SmartDashboard.putNumber("LimelightY", y); - SmartDashboard.putNumber("LimelightArea", area); - -} - - @Override public void periodic() { // This method will be called once per scheduler run From fcac077def5428d03df7ebe38df76a15dfdd40a2 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 7 Feb 2024 18:35:35 -0500 Subject: [PATCH 03/10] subsystem limelight --- src/main/java/frc/robot/subsystem/Limelight.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/subsystem/Limelight.java b/src/main/java/frc/robot/subsystem/Limelight.java index 49291b3..97831af 100644 --- a/src/main/java/frc/robot/subsystem/Limelight.java +++ b/src/main/java/frc/robot/subsystem/Limelight.java @@ -9,8 +9,6 @@ import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.wpilibj2.command.SubsystemBase; -import frc.robot.LimelightHelpers; - public class Limelight extends SubsystemBase { @@ -22,10 +20,11 @@ public class Limelight extends SubsystemBase { NetworkTableEntry pipeline = table.getEntry("pipeline"); NetworkTableEntry tv = table.getEntry("tv"); NetworkTableEntry camMode = table.getEntry("camMode"); + NetworkTableEntry tid = table.getEntry("tid"); - /** Creates a new Limelight. */ public Limelight() { + } public double getx(){ @@ -40,11 +39,14 @@ public class Limelight extends SubsystemBase { public boolean getv(){ return tv.getBoolean(false); } - public double getpipeline(){ - return pipeline.getDouble(0); + public void setpipeline(){ + pipeline.setNumber(0); } - public double getcamMode(){ - return camMode.getDouble(0); + public void setcamMode(){ + camMode.setNumber(0); + } + public double getTid(){ + return tid.getDouble(0); } @Override From 9f4ae69d9acc5939da8a05e2494bac20af2aef09 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 7 Feb 2024 19:37:35 -0500 Subject: [PATCH 04/10] Commande tracker april tag --- .../java/frc/robot/command/GuiderHaut.java | 2 +- .../java/frc/robot/command/LancerNote.java | 1 + .../frc/robot/command/Limelight_tracker.java | 49 +++++++++++++++++++ .../java/frc/robot/subsystem/Limelight.java | 6 +-- 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/main/java/frc/robot/command/Limelight_tracker.java diff --git a/src/main/java/frc/robot/command/GuiderHaut.java b/src/main/java/frc/robot/command/GuiderHaut.java index 1eb052e..74719ca 100644 --- a/src/main/java/frc/robot/command/GuiderHaut.java +++ b/src/main/java/frc/robot/command/GuiderHaut.java @@ -40,6 +40,6 @@ public class GuiderHaut extends Command { // Returns true when the command should end. @Override public boolean isFinished() { - return guideur.haut()==true; +return guideur.haut()==true; } } diff --git a/src/main/java/frc/robot/command/LancerNote.java b/src/main/java/frc/robot/command/LancerNote.java index d653184..133492b 100644 --- a/src/main/java/frc/robot/command/LancerNote.java +++ b/src/main/java/frc/robot/command/LancerNote.java @@ -15,6 +15,7 @@ public class LancerNote extends Command { public LancerNote(Lanceur lancer, Accumulateur accumulateur) { this.lancer = lancer; this.accumulateur = accumulateur; + addRequirements(lancer); // Use addRequirements() here to declare subsystem dependencies. } diff --git a/src/main/java/frc/robot/command/Limelight_tracker.java b/src/main/java/frc/robot/command/Limelight_tracker.java new file mode 100644 index 0000000..78d0f91 --- /dev/null +++ b/src/main/java/frc/robot/command/Limelight_tracker.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.Drive; +import frc.robot.subsystem.Limelight; + +public class Limelight_tracker extends Command { + /** Creates a new Limelight_tracker. */ + private Limelight tracker; + private Drive drive; + + public Limelight_tracker(Limelight tracker, Drive drive) { + this.drive = drive; + this.tracker = tracker; + addRequirements(tracker,drive); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + + if (tracker.getv()){ + drive.drive(0,0, tracker.getx()); + } + else{ + drive.drive(0, 0, 0); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + drive.drive(0, 0, 0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystem/Limelight.java b/src/main/java/frc/robot/subsystem/Limelight.java index 97831af..ab2358f 100644 --- a/src/main/java/frc/robot/subsystem/Limelight.java +++ b/src/main/java/frc/robot/subsystem/Limelight.java @@ -27,15 +27,15 @@ public class Limelight extends SubsystemBase { } - public double getx(){ + public double getx(){ return tx.getDouble(0); } public double gety(){ return ty.getDouble(0); } - public double geta() { + /* public double geta() { return ta.getDouble(0); - } + }*/ public boolean getv(){ return tv.getBoolean(false); } From 7a5705baa0306720ace75922d77d5afdab17b476 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 7 Feb 2024 19:38:43 -0500 Subject: [PATCH 05/10] --- src/main/java/frc/robot/Constants.java | 3 +-- src/main/java/frc/robot/RobotContainer.java | 1 + .../frc/robot/subsystem/Accumulateur.java | 4 ++-- .../java/frc/robot/subsystem/Grimpeur.java | 23 ++++++++++++++++++- .../java/frc/robot/subsystem/Guideur.java | 9 ++++++-- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 21e30aa..1206c23 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -45,8 +45,7 @@ public class Constants { // Limit switch public static int guideurhaut = 0; public static int guideurbas = 1; - public static int limitacc = 2; - public static int limitacc2 = 3; + public static int photocellacc = 2; public static int limithaut = 4; public static int limitbas = 5; diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 3fb4b54..7b50586 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -54,6 +54,7 @@ public class RobotContainer { Lancerampli lancerampli = new Lancerampli(lanceur); CommandJoystick joystick = new CommandJoystick(0); CommandXboxController manette = new CommandXboxController(1); + //command GrimpeurDroit grimpeurDroit = new GrimpeurDroit(grimpeur, manette::getLeftX); GrimpeurGauche grimpeurGauche = new GrimpeurGauche(grimpeur, manette::getLeftY); public RobotContainer() { diff --git a/src/main/java/frc/robot/subsystem/Accumulateur.java b/src/main/java/frc/robot/subsystem/Accumulateur.java index 82ade1e..2c43a06 100644 --- a/src/main/java/frc/robot/subsystem/Accumulateur.java +++ b/src/main/java/frc/robot/subsystem/Accumulateur.java @@ -24,7 +24,7 @@ public class Accumulateur extends SubsystemBase { .getEntry(); final WPI_TalonSRX Moteuracc2 = new WPI_TalonSRX(Constants.Moteuracc2); final WPI_TalonSRX Moteuracc = new WPI_TalonSRX(Constants.Moteuracc); - final DigitalInput limitacc = new DigitalInput(Constants.limitacc); + final DigitalInput photocellacc = new DigitalInput(Constants.photocellacc); public void Deaccumuler(double vitesse){ Moteuracc2.set(vitesse); @@ -34,7 +34,7 @@ public class Accumulateur extends SubsystemBase { Moteuracc.setInverted(true); } public boolean limitswitch(){ - return limitacc.get(); + return photocellacc.get(); } public Accumulateur() { diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index 4f595c4..e2cbc93 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -8,9 +8,12 @@ import com.kauailabs.navx.frc.AHRS; import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkLowLevel.MotorType; +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.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; @@ -18,7 +21,8 @@ import frc.robot.Constants; public class Grimpeur extends SubsystemBase { /** Creates a new Acrocheur. */ // moteur - public Grimpeur() {} + + ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); final CANSparkMax grimpeurd = new CANSparkMax(Constants.grimpeurd,MotorType.kBrushless); final CANSparkMax grimpeurg = new CANSparkMax(Constants.grimpeurg,MotorType.kBrushless); // limit switch @@ -27,6 +31,23 @@ public class Grimpeur extends SubsystemBase { final DoubleSolenoid pistondroite= new DoubleSolenoid(PneumaticsModuleType.CTREPCM, Constants.pistondroiteouvre, Constants.pistondroiteouvre); 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); + } 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 359a04c..c801259 100644 --- a/src/main/java/frc/robot/subsystem/Guideur.java +++ b/src/main/java/frc/robot/subsystem/Guideur.java @@ -7,17 +7,22 @@ package frc.robot.subsystem; 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.ShuffleboardTab; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; public class Guideur extends SubsystemBase { /** Creates a new Guideur. */ - public Guideur() {} + ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); 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()); + } public void guider(double vitesse){ guideur.set(vitesse); } From 039f8f53929833b0eebd544e65aa923bcf85e1bb Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 7 Feb 2024 19:50:38 -0500 Subject: [PATCH 06/10] Limelight --- src/main/java/frc/robot/command/Lancer.java | 9 +++++++-- src/main/java/frc/robot/command/Lancerampli.java | 14 +++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/command/Lancer.java b/src/main/java/frc/robot/command/Lancer.java index de4314e..01eb49c 100644 --- a/src/main/java/frc/robot/command/Lancer.java +++ b/src/main/java/frc/robot/command/Lancer.java @@ -9,14 +9,17 @@ package frc.robot.command; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystem.Lanceur; +import frc.robot.subsystem.Limelight; public class Lancer extends Command { /** Creates a new Lanceur. */ + private Limelight limelight; private Lanceur lanceur; - public Lancer(Lanceur lanceur) { + public Lancer(Lanceur lanceur,Limelight limelight) { + this.limelight = limelight; this.lanceur = lanceur; // Use addRequirements() here to declare subsystem dependencies. - addRequirements(lanceur); + addRequirements(lanceur,limelight); } // Called when the command is initially scheduled. @@ -26,7 +29,9 @@ public class Lancer extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { + if(limelight.getv()){ lanceur.lancerspeaker(); + } } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/command/Lancerampli.java b/src/main/java/frc/robot/command/Lancerampli.java index 450c87a..4a9b3c8 100644 --- a/src/main/java/frc/robot/command/Lancerampli.java +++ b/src/main/java/frc/robot/command/Lancerampli.java @@ -9,15 +9,16 @@ package frc.robot.command; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystem.Lanceur; +import frc.robot.subsystem.Limelight; public class Lancerampli extends Command { /** Creates a new Lanceur. */ - private Lanceur lanceur; - - public Lancerampli(Lanceur lanceur) { + private Limelight limelight; + public Lancerampli(Lanceur lanceur,Limelight limelight) { // Use addRequirements() here to declare subsystem dependencies. - addRequirements(lanceur); + addRequirements(lanceur, limelight); + this.limelight = limelight; this.lanceur = lanceur; } @@ -28,7 +29,10 @@ public class Lancerampli extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - lanceur.lanceramp(); + if(limelight.getv()){ + lanceur.lanceramp(); + } + } // Called once the command ends or is interrupted. From 847e3fd97de7b4e15b26bcf043b6b050f07fd340 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 7 Feb 2024 19:50:42 -0500 Subject: [PATCH 07/10] button1 --- src/main/java/frc/robot/RobotContainer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 4ba1d18..d480aeb 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -70,6 +70,7 @@ public class RobotContainer { manette.a().whileTrue(guiderBas); manette.b().whileTrue(guiderHaut); joystick.button(3).toggleOnTrue(balayer); + joystick.button(1).whileTrue(lancernote); configureBindings(); drive.setDefaultCommand(new RunCommand(()->{ From 9f93a2159b7d4f0db45dfbb95c3f64021f7b1d54 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 7 Feb 2024 19:50:57 -0500 Subject: [PATCH 08/10] --- src/main/java/frc/robot/RobotContainer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index f1ad8ec..a490def 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -37,6 +37,7 @@ import frc.robot.subsystem.Grimpeur; import frc.robot.subsystem.Guideur; import frc.robot.subsystem.LED; import frc.robot.subsystem.Lanceur; +import frc.robot.subsystem.Limelight; import frc.robot.subsystem.Pixy; @@ -51,9 +52,10 @@ public class RobotContainer { Balayer balayer = new Balayer(balayeuse, accumulateur); GuiderHaut guiderHaut = new GuiderHaut(guideur); GuiderBas guiderBas = new GuiderBas(guideur); - Lancer lancer = new Lancer(lanceur); + Limelight limelight = new Limelight(); + Lancer lancer = new Lancer(lanceur,limelight); LancerNote lancernote = new LancerNote(lanceur, accumulateur); - Lancerampli lancerampli = new Lancerampli(lanceur); + Lancerampli lancerampli = new Lancerampli(lanceur,limelight); CommandJoystick joystick = new CommandJoystick(0); CommandXboxController manette = new CommandXboxController(1); //command From d48996bf5c0035eb11c9df07607b9791615b2abb Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 7 Feb 2024 19:52:54 -0500 Subject: [PATCH 09/10] --- 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 10/10] --- 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() {