From f1406f0db044d260162b58ff0907a0379b3e8c8c Mon Sep 17 00:00:00 2001 From: Antoine <2443335@carrefour.cegepvicto.ca> Date: Wed, 30 Oct 2024 19:27:41 -0400 Subject: [PATCH 1/3] limelight avec tourelle --- src/main/java/frc/robot/Commands/FollowAprilTag.java | 6 +++--- src/main/java/frc/robot/Subsystems/Lanceur.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/Commands/FollowAprilTag.java b/src/main/java/frc/robot/Commands/FollowAprilTag.java index 86ce2bd..89fd4e0 100644 --- a/src/main/java/frc/robot/Commands/FollowAprilTag.java +++ b/src/main/java/frc/robot/Commands/FollowAprilTag.java @@ -32,11 +32,11 @@ public class FollowAprilTag extends Command { if (enlignement.getv()==1) { - drive.drive(0, 0, enlignement.getx()/30); + lanceur.tourelRotation(0,0, enlignement.getx()/30); } else { - drive.drive(0, 0, 0); + lanceur.tourelRotation(0, 0, 0); } } @@ -44,7 +44,7 @@ public class FollowAprilTag extends Command { // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - drive.drive(0, 0, 0); + lanceur.tourelRotation(0, 0, 0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/Subsystems/Lanceur.java b/src/main/java/frc/robot/Subsystems/Lanceur.java index 7d73f1d..ecb14c8 100644 --- a/src/main/java/frc/robot/Subsystems/Lanceur.java +++ b/src/main/java/frc/robot/Subsystems/Lanceur.java @@ -36,8 +36,8 @@ public class Lanceur extends SubsystemBase { public void lance(double vitesse){ lanceur1.set(vitesse); } - public void tourelRotation(double vitesse){ - tourelle.set(vitesse); + public void tourelRotation(double x, double y, double rotation){ + tourelle.set(rotation); } public double distancetourel(){ return(tourelle.getEncoder().getPosition()); From 4ece4131260c318ec15bd52d02dfc7c9c7d0a863 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 30 Oct 2024 19:37:02 -0400 Subject: [PATCH 2/3] DASHBOARD LANCEUR --- src/main/java/frc/robot/Subsystems/Lanceur.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/Subsystems/Lanceur.java b/src/main/java/frc/robot/Subsystems/Lanceur.java index cd9a27e..27fec5c 100644 --- a/src/main/java/frc/robot/Subsystems/Lanceur.java +++ b/src/main/java/frc/robot/Subsystems/Lanceur.java @@ -12,17 +12,24 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkLowLevel.MotorType; - - +import edu.wpi.first.networktables.GenericEntry; +import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Lanceur extends SubsystemBase { /** Creates a new Lanceur. */ public Lanceur() {} + ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); final WPI_TalonSRX lanceur1 = new WPI_TalonSRX(0); final WPI_TalonSRX lanceur2 = new WPI_TalonSRX(1); final CANSparkMax tourelle = new CANSparkMax(2, MotorType.kBrushed); + private GenericEntry vitesse = + dashboard.add("vitesselanceur", 0.2) + .withSize(0,0) + .withPosition(1, 4) + .getEntry(); public void encodeur(double distance){ lanceur1.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative); lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative); @@ -34,6 +41,9 @@ public class Lanceur extends SubsystemBase { lanceur1.set(vitesse); lanceur2.set(-vitesse); } + public void lance(){ + lance(vitesse.getDouble(0.2)); + } public void tourelRotation(double vitesse){ tourelle.set(vitesse); } From 41972998080829aa6e2d15d31313ee7ae33a633d Mon Sep 17 00:00:00 2001 From: Antoine <2443335@carrefour.cegepvicto.ca> Date: Wed, 30 Oct 2024 19:54:39 -0400 Subject: [PATCH 3/3] =?UTF-8?q?m=C3=A9nage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/frc/robot/Commands/Desaccumuler.java | 7 +------ src/main/java/frc/robot/Commands/FollowAprilTag.java | 4 ---- src/main/java/frc/robot/Commands/Lancer.java | 5 ----- src/main/java/frc/robot/LimelightHelpers.java | 2 -- src/main/java/frc/robot/Subsystems/Accumulateur.java | 6 ------ src/main/java/frc/robot/Subsystems/Drive.java | 4 ---- src/main/java/frc/robot/Subsystems/Lanceur.java | 1 - src/main/java/frc/robot/Subsystems/Limelight3G.java | 2 +- 8 files changed, 2 insertions(+), 29 deletions(-) diff --git a/src/main/java/frc/robot/Commands/Desaccumuler.java b/src/main/java/frc/robot/Commands/Desaccumuler.java index 68a79f7..e3899e5 100644 --- a/src/main/java/frc/robot/Commands/Desaccumuler.java +++ b/src/main/java/frc/robot/Commands/Desaccumuler.java @@ -3,7 +3,6 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot.Commands; - import edu.wpi.first.wpilibj2.command.Command; import frc.robot.Subsystems.Accumulateur; @@ -15,25 +14,21 @@ public class Desaccumuler extends Command { addRequirements(accumulateur); // Use addRequirements() here to declare subsystem dependencies. } - // 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() { accumulateur.desaccumule(0.1); } - // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { accumulateur.desaccumule(0); } - // Returns true when the command should end. @Override public boolean isFinished() { diff --git a/src/main/java/frc/robot/Commands/FollowAprilTag.java b/src/main/java/frc/robot/Commands/FollowAprilTag.java index 89fd4e0..a44d9ec 100644 --- a/src/main/java/frc/robot/Commands/FollowAprilTag.java +++ b/src/main/java/frc/robot/Commands/FollowAprilTag.java @@ -3,9 +3,7 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot.Commands; - import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.Subsystems.Drive; import frc.robot.Subsystems.Lanceur; import frc.robot.Subsystems.Limelight3G; @@ -18,7 +16,6 @@ public class FollowAprilTag extends Command { // Use addRequirements() here to declare subsystem dependencies. this.lanceur = lanceur; this.enlignement = enlignement; - addRequirements(lanceur, enlignement); } @@ -46,7 +43,6 @@ public class FollowAprilTag extends Command { public void end(boolean interrupted) { lanceur.tourelRotation(0, 0, 0); } - // Returns true when the command should end. @Override public boolean isFinished() { diff --git a/src/main/java/frc/robot/Commands/Lancer.java b/src/main/java/frc/robot/Commands/Lancer.java index f55e58a..fa2258c 100644 --- a/src/main/java/frc/robot/Commands/Lancer.java +++ b/src/main/java/frc/robot/Commands/Lancer.java @@ -3,7 +3,6 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot.Commands; - import edu.wpi.first.wpilibj2.command.Command; import frc.robot.Subsystems.Lanceur; @@ -15,25 +14,21 @@ public class Lancer extends Command { addRequirements(lanceur); // Use addRequirements() here to declare subsystem dependencies. } - // Called when the command is initially scheduled. @Override public void initialize() { lanceur.PIDlanceur(0, 0, 0); } - // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { lanceur.lance(0.5); } - // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { lanceur.lance(0); } - // Returns true when the command should end. @Override public boolean isFinished() { diff --git a/src/main/java/frc/robot/LimelightHelpers.java b/src/main/java/frc/robot/LimelightHelpers.java index efdfeb5..6af0031 100644 --- a/src/main/java/frc/robot/LimelightHelpers.java +++ b/src/main/java/frc/robot/LimelightHelpers.java @@ -16,14 +16,12 @@ import edu.wpi.first.math.geometry.Translation3d; import edu.wpi.first.math.util.Units; import edu.wpi.first.math.geometry.Rotation3d; import edu.wpi.first.math.geometry.Translation2d; - import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Map; import java.util.concurrent.CompletableFuture; - import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Shape; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/frc/robot/Subsystems/Accumulateur.java b/src/main/java/frc/robot/Subsystems/Accumulateur.java index adb2996..f7ba6af 100644 --- a/src/main/java/frc/robot/Subsystems/Accumulateur.java +++ b/src/main/java/frc/robot/Subsystems/Accumulateur.java @@ -3,15 +3,11 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot.Subsystems; - - import edu.wpi.first.networktables.GenericEntry; 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 com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; public class Accumulateur extends SubsystemBase { @@ -19,7 +15,6 @@ public class Accumulateur extends SubsystemBase { public Accumulateur() {dashboard.addBoolean("photocellacc", this::limitswitch) .withSize(1, 1) .withPosition(0, 1); - } ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); @@ -44,7 +39,6 @@ public class Accumulateur extends SubsystemBase { public void desaccumule(){ desaccumule(vitesse.getDouble(0.9)); } - @Override public void periodic() { // This method will be called once per scheduler run diff --git a/src/main/java/frc/robot/Subsystems/Drive.java b/src/main/java/frc/robot/Subsystems/Drive.java index 076ada3..cfa2936 100644 --- a/src/main/java/frc/robot/Subsystems/Drive.java +++ b/src/main/java/frc/robot/Subsystems/Drive.java @@ -3,12 +3,9 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot.Subsystems; - import java.io.File; import java.io.IOException; - import com.ctre.phoenix6.hardware.Pigeon2; - import edu.wpi.first.math.geometry.Translation2d; import edu.wpi.first.math.kinematics.SwerveModulePosition; import edu.wpi.first.wpilibj.Filesystem; @@ -16,7 +13,6 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; import swervelib.SwerveDrive; import swervelib.parser.SwerveParser; - public class Drive extends SubsystemBase { SwerveDrive swerveDrive; diff --git a/src/main/java/frc/robot/Subsystems/Lanceur.java b/src/main/java/frc/robot/Subsystems/Lanceur.java index b5fd79d..47ceb13 100644 --- a/src/main/java/frc/robot/Subsystems/Lanceur.java +++ b/src/main/java/frc/robot/Subsystems/Lanceur.java @@ -34,7 +34,6 @@ public class Lanceur extends SubsystemBase { lanceur1.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative); lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative); lanceur1.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1); - } public void masterslave(){ lanceur2.follow(lanceur1); diff --git a/src/main/java/frc/robot/Subsystems/Limelight3G.java b/src/main/java/frc/robot/Subsystems/Limelight3G.java index de2ad2a..2fdba8f 100644 --- a/src/main/java/frc/robot/Subsystems/Limelight3G.java +++ b/src/main/java/frc/robot/Subsystems/Limelight3G.java @@ -9,9 +9,9 @@ import edu.wpi.first.net.PortForwarder; import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableInstance; + public class Limelight3G extends SubsystemBase { NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight"); - NetworkTableEntry tx = table.getEntry("tx"); NetworkTableEntry ty = table.getEntry("ty"); NetworkTableEntry pipeline = table.getEntry("pipeline");