From 7a5705baa0306720ace75922d77d5afdab17b476 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 7 Feb 2024 19:38:43 -0500 Subject: [PATCH 1/3] --- 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 2/3] 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 9f93a2159b7d4f0db45dfbb95c3f64021f7b1d54 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 7 Feb 2024 19:50:57 -0500 Subject: [PATCH 3/3] --- 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