From 8c7dc5ab8763ef39c85f885aa416d9f1b96ed031 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 29 Jan 2024 19:13:09 -0500 Subject: [PATCH 1/4] grimpeur --- .../java/frc/robot/command/GrimpeurHaut.java | 35 +++++++++++++++++-- .../java/frc/robot/subsystem/Grimpeur.java | 7 +++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/command/GrimpeurHaut.java b/src/main/java/frc/robot/command/GrimpeurHaut.java index 840c475..a14a6fb 100644 --- a/src/main/java/frc/robot/command/GrimpeurHaut.java +++ b/src/main/java/frc/robot/command/GrimpeurHaut.java @@ -18,17 +18,46 @@ public class GrimpeurHaut extends Command { // Called when the command is initially scheduled. @Override - public void initialize() {} + public void initialize() { + grimpeur.resetencodeurd(); + grimpeur.resetencodeurg(); + } // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - + if(grimpeur.droite()){ + grimpeur.resetencodeurd(); + } + else if(grimpeur.gauche()){ + grimpeur.resetencodeurg(); + } + else if(grimpeur.encoderd()>261){ + grimpeur.droit(0); + } + else if(grimpeur.getpitch()<-15){ + grimpeur.droit(0.6); + grimpeur.gauche(-0.6); + } + else if(grimpeur.getpitch()>15){ + grimpeur.gauche(0.6); + grimpeur.droit(-0.6); + } + else if(grimpeur.encoderg()>261){ + grimpeur.gauche(0.6); + } + else{ + grimpeur.gauche(0); + grimpeur.gauche(0); + } } // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + grimpeur.droit(0); + grimpeur.gauche(0); + } // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/subsystem/Grimpeur.java b/src/main/java/frc/robot/subsystem/Grimpeur.java index ed02bda..4f595c4 100644 --- a/src/main/java/frc/robot/subsystem/Grimpeur.java +++ b/src/main/java/frc/robot/subsystem/Grimpeur.java @@ -45,7 +45,12 @@ public void resetencodeurd(){ public void resetencodeurg(){ grimpeurg.getEncoder().setPosition(0); } - +public double encoderd(){ + return grimpeurd.getEncoder().getPosition(); +} +public double encoderg(){ + return grimpeurg.getEncoder().getPosition(); +} public AHRS gyroscope = new AHRS(); public double getpitch(){ return gyroscope.getPitch(); From 88e4a0b885cc5732f0e773e2dcc106141f4a3677 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 29 Jan 2024 19:28:59 -0500 Subject: [PATCH 2/4] grimpeur --- .../java/frc/robot/command/GrimpeurBas.java | 51 +++++++++++++++++++ .../java/frc/robot/command/GrimpeurHaut.java | 25 +++++---- 2 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 src/main/java/frc/robot/command/GrimpeurBas.java diff --git a/src/main/java/frc/robot/command/GrimpeurBas.java b/src/main/java/frc/robot/command/GrimpeurBas.java new file mode 100644 index 0000000..47b2a53 --- /dev/null +++ b/src/main/java/frc/robot/command/GrimpeurBas.java @@ -0,0 +1,51 @@ +// 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 GrimpeurBas extends Command { + private Grimpeur grimpeur; + /** Creates a new GrimpeurBas. */ + public GrimpeurBas(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.resetencodeurd(); + grimpeur.resetencodeurg(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + if(grimpeur.droite()){ + grimpeur.resetencodeurd(); + grimpeur.gauche(0); + } + if(grimpeur.gauche()){ + grimpeur.resetencodeurg(); + grimpeur.gauche(0); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + grimpeur.droit(0); + grimpeur.gauche(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/command/GrimpeurHaut.java b/src/main/java/frc/robot/command/GrimpeurHaut.java index a14a6fb..2fbe288 100644 --- a/src/main/java/frc/robot/command/GrimpeurHaut.java +++ b/src/main/java/frc/robot/command/GrimpeurHaut.java @@ -26,29 +26,32 @@ public class GrimpeurHaut extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(grimpeur.droite()){ - grimpeur.resetencodeurd(); - } - else if(grimpeur.gauche()){ - grimpeur.resetencodeurg(); - } - else if(grimpeur.encoderd()>261){ + + if(grimpeur.encoderd()>261 ){ grimpeur.droit(0); } else if(grimpeur.getpitch()<-15){ grimpeur.droit(0.6); - grimpeur.gauche(-0.6); + } else if(grimpeur.getpitch()>15){ - grimpeur.gauche(0.6); grimpeur.droit(-0.6); } - else if(grimpeur.encoderg()>261){ + else{ + grimpeur.droit(0); + } + if(grimpeur.encoderg()>261 ){ + grimpeur.gauche(0); + } + else if(grimpeur.getpitch()<-15){ grimpeur.gauche(0.6); + + } + else if(grimpeur.getpitch()>15){ + grimpeur.gauche(-0.6); } else{ grimpeur.gauche(0); - grimpeur.gauche(0); } } From 074e91a4dc8b93af650663f433929ef41ec8cdbc Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Mon, 29 Jan 2024 19:36:18 -0500 Subject: [PATCH 3/4] grimpeur --- ...impeurHaut.java => GrimpeurHautDroit.java} | 22 ++------ .../frc/robot/command/GrimpeurHautGauche.java | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+), 18 deletions(-) rename src/main/java/frc/robot/command/{GrimpeurHaut.java => GrimpeurHautDroit.java} (78%) create mode 100644 src/main/java/frc/robot/command/GrimpeurHautGauche.java diff --git a/src/main/java/frc/robot/command/GrimpeurHaut.java b/src/main/java/frc/robot/command/GrimpeurHautDroit.java similarity index 78% rename from src/main/java/frc/robot/command/GrimpeurHaut.java rename to src/main/java/frc/robot/command/GrimpeurHautDroit.java index 2fbe288..324501f 100644 --- a/src/main/java/frc/robot/command/GrimpeurHaut.java +++ b/src/main/java/frc/robot/command/GrimpeurHautDroit.java @@ -7,10 +7,10 @@ package frc.robot.command; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystem.Grimpeur; -public class GrimpeurHaut extends Command { +public class GrimpeurHautDroit extends Command { private Grimpeur grimpeur; /** Creates a new GrimpeurHaut. */ - public GrimpeurHaut(Grimpeur grimpeur) { + public GrimpeurHautDroit(Grimpeur grimpeur) { this.grimpeur = grimpeur; addRequirements(grimpeur); // Use addRequirements() here to declare subsystem dependencies. @@ -31,35 +31,21 @@ public class GrimpeurHaut extends Command { grimpeur.droit(0); } else if(grimpeur.getpitch()<-15){ - grimpeur.droit(0.6); + grimpeur.droit(-0.6); } else if(grimpeur.getpitch()>15){ - grimpeur.droit(-0.6); + grimpeur.droit(0.6); } else{ grimpeur.droit(0); } - if(grimpeur.encoderg()>261 ){ - grimpeur.gauche(0); - } - else if(grimpeur.getpitch()<-15){ - grimpeur.gauche(0.6); - - } - else if(grimpeur.getpitch()>15){ - grimpeur.gauche(-0.6); - } - else{ - grimpeur.gauche(0); - } } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { grimpeur.droit(0); - grimpeur.gauche(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/command/GrimpeurHautGauche.java b/src/main/java/frc/robot/command/GrimpeurHautGauche.java new file mode 100644 index 0000000..2bd6593 --- /dev/null +++ b/src/main/java/frc/robot/command/GrimpeurHautGauche.java @@ -0,0 +1,55 @@ +// 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 GrimpeurHautGauche extends Command { + private Grimpeur grimpeur; + /** Creates a new GrimpeurHautGauche. */ + public GrimpeurHautGauche(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.resetencodeurd(); + grimpeur.resetencodeurg(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + if(grimpeur.encoderg()>261 ){ + grimpeur.gauche(0); + } + else if(grimpeur.getpitch()<-15){ + grimpeur.gauche(0.6); + + } + else if(grimpeur.getpitch()>15){ + grimpeur.gauche(-0.6); + } + else{ + grimpeur.gauche(0); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + grimpeur.gauche(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} From 3c25b4b39b19962f4670c633fa640363fb4d390f Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 30 Jan 2024 18:16:02 -0500 Subject: [PATCH 4/4] n --- .../java/frc/robot/subsystem/Limelight.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/subsystem/Limelight.java b/src/main/java/frc/robot/subsystem/Limelight.java index e26d582..9fb068b 100644 --- a/src/main/java/frc/robot/subsystem/Limelight.java +++ b/src/main/java/frc/robot/subsystem/Limelight.java @@ -4,20 +4,31 @@ package frc.robot.subsystem; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +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 { /** Creates a new Limelight. */ public Limelight() { - boolean tv = LimelightHelpers.getTV("No_name"); + NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight"); + NetworkTableEntry tx = table.getEntry("tx"); + NetworkTableEntry ty = table.getEntry("ty"); + NetworkTableEntry ta = table.getEntry("ta"); + + double x = tx.getDouble(0.0); + double y = ty.getDouble(0.0); + double area = ta.getDouble(0.0); + + SmartDashboard.putNumber("LimelightX", x); + SmartDashboard.putNumber("LimelightY", y); + SmartDashboard.putNumber("LimelightArea", area); - double tx = LimelightHelpers.getTX("No_name"); - double ty = LimelightHelpers.getTY("No_name"); - double ta = LimelightHelpers.getTA("No_name"); }