From 4b9bfc7309f051dbbe72fc9f811ff8f563eb9e63 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Tue, 11 Apr 2023 17:21:18 -0400 Subject: [PATCH 01/12] fh nm --- src/main/java/frc/robot/RobotContainer.java | 2 +- src/main/java/frc/robot/commands/GratteBaisser.java | 1 - src/main/java/frc/robot/commands/GratteMonte.java | 2 +- src/main/java/frc/robot/commands/Gyro.java | 3 +-- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 2bbc6ca..60a6be2 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,7 +4,7 @@ package frc.robot; import java.util.Map; -import java.util.function.DoubleSupplier; + import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.networktables.GenericEntry; diff --git a/src/main/java/frc/robot/commands/GratteBaisser.java b/src/main/java/frc/robot/commands/GratteBaisser.java index 9d1292f..9beb149 100644 --- a/src/main/java/frc/robot/commands/GratteBaisser.java +++ b/src/main/java/frc/robot/commands/GratteBaisser.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.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.Gratte; diff --git a/src/main/java/frc/robot/commands/GratteMonte.java b/src/main/java/frc/robot/commands/GratteMonte.java index 553e5e0..2e6dd22 100644 --- a/src/main/java/frc/robot/commands/GratteMonte.java +++ b/src/main/java/frc/robot/commands/GratteMonte.java @@ -5,7 +5,7 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; + import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.Gratte; diff --git a/src/main/java/frc/robot/commands/Gyro.java b/src/main/java/frc/robot/commands/Gyro.java index 0917326..7874235 100644 --- a/src/main/java/frc/robot/commands/Gyro.java +++ b/src/main/java/frc/robot/commands/Gyro.java @@ -4,8 +4,7 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; -import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; + import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.BasePilotable; From 6a9b699de13adc2cb91dd845b39730246689a073 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Tue, 11 Apr 2023 17:23:38 -0400 Subject: [PATCH 02/12] gfnb --- src/main/java/frc/robot/subsystems/BasePilotable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/BasePilotable.java b/src/main/java/frc/robot/subsystems/BasePilotable.java index a1e4c68..a5d5b91 100644 --- a/src/main/java/frc/robot/subsystems/BasePilotable.java +++ b/src/main/java/frc/robot/subsystems/BasePilotable.java @@ -17,7 +17,7 @@ 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; -import frc.robot.commands.bras.Bougerbras; + public class BasePilotable extends SubsystemBase { final CANSparkMax avantdroit = new CANSparkMax(Constants.avantdroit, MotorType.kBrushless); From bded54b8c5df038b78cb45006827ca4bac42a5c4 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Tue, 11 Apr 2023 17:44:41 -0400 Subject: [PATCH 03/12] gfhg jha --- src/main/java/frc/robot/RobotContainer.java | 10 +++++----- src/main/java/frc/robot/commands/bras/Bougerbras.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 24fa703..4e80b9f 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -64,7 +64,7 @@ public class RobotContainer { GenericEntry reculerdistances = layoutauto.addPersistent("reculerdistancesortir", -66).getEntry(); GenericEntry reculerdistanceb = layoutauto.addPersistent("reculerdistancebalance", -31).getEntry(); GenericEntry avancerdistance = layoutauto.addPersistent("avancer", 35).getEntry(); - + // subsystems BasePilotable basePilotable = new BasePilotable(); Gratte gratte = new Gratte(); @@ -110,8 +110,8 @@ public class RobotContainer { private void configureBindings() { // manette 1 manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince)); - manette1.x().onTrue(brakeOuvre); - manette1.b().onTrue(brakeFerme); + manette2.a().onTrue(brakeOuvre); + manette2.b().onTrue(brakeFerme); manette1.leftBumper().whileTrue(aprilTag); manette1.rightBumper().whileTrue(tape); manette1.povUp().whileTrue(creerCommandBras(51, -37)); @@ -126,8 +126,8 @@ public class RobotContainer { manette2.leftBumper().whileTrue(cone); manette2.y().whileTrue(gyro); manette2.start().onTrue(new InstantCommand(basePilotable::resetGyro)); - manette2.a().whileTrue(gratteMonte); - manette2.b().whileTrue(gratteBaisser); + manette1.b().whileTrue(gratteMonte); + manette1.x().whileTrue(gratteBaisser); } private Command creerCommandBras(double distancePivot, double distanceBras) { diff --git a/src/main/java/frc/robot/commands/bras/Bougerbras.java b/src/main/java/frc/robot/commands/bras/Bougerbras.java index 6390c94..d807832 100644 --- a/src/main/java/frc/robot/commands/bras/Bougerbras.java +++ b/src/main/java/frc/robot/commands/bras/Bougerbras.java @@ -28,11 +28,11 @@ public class Bougerbras extends CommandBase { @Override public void execute() { if(brasTelescopique.distance()>distance+0.5 ) { - brasTelescopique.AvanceRecule(-0.3); + brasTelescopique.AvanceRecule(-0.35); } else if(brasTelescopique.distance() Date: Tue, 11 Apr 2023 17:51:17 -0400 Subject: [PATCH 04/12] gyro fix --- src/main/java/frc/robot/commands/Gyro.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/commands/Gyro.java b/src/main/java/frc/robot/commands/Gyro.java index 5d6b948..e6b1598 100644 --- a/src/main/java/frc/robot/commands/Gyro.java +++ b/src/main/java/frc/robot/commands/Gyro.java @@ -25,11 +25,11 @@ public class Gyro extends CommandBase { public void execute() { if(basePilotable.getpitch()>6) { - basePilotable.drive(0.4*basePilotable.getpitch()/12, 0); + basePilotable.drive(0.3*basePilotable.getpitch()/12, 0); } else if(basePilotable.getpitch()<-6) { - basePilotable.drive(0.4*basePilotable.getpitch()/12, 0); + basePilotable.drive(0.3*basePilotable.getpitch()/12, 0); } else { From cd47b7709057cc8ff40f1041b31a7adbc756193e Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Tue, 11 Apr 2023 17:54:18 -0400 Subject: [PATCH 05/12] yrtvuhj --- src/main/java/frc/robot/RobotContainer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index c4aff39..265cf7d 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -40,6 +40,8 @@ import frc.robot.commands.GratteMonte; import frc.robot.commands.Gyro; import frc.robot.commands.Reculer; import frc.robot.commands.Tape; +import frc.robot.commands.bras.Bougerbras; +import frc.robot.commands.bras.Bougerpivot; import frc.robot.commands.bras.BrasManuel; import frc.robot.commands.bras.DescendrePivotBras; import frc.robot.commands.bras.FermePince; @@ -149,6 +151,8 @@ public class RobotContainer { Map.entry(aumilieux, creerCommandBras(9, -14)), Map.entry(enbas, creerCommandBras(44, -17)), Map.entry(nulpart, creerCommandBras(0, 0))), chooser::getSelected), + creerCommandBras(49, 40).unless(() -> chooser.getSelected().equals(enhaut)), + creerCommandBras(51, 40).unless(() -> chooser.getSelected().equals(enhaut)), new OuvrePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), Commands.waitSeconds(1), new FermePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), From ba7d79882ae3dcfa8fbd7bdecc9e92e498f0530d Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Tue, 11 Apr 2023 17:57:05 -0400 Subject: [PATCH 06/12] terygvjh --- src/main/java/frc/robot/RobotContainer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 265cf7d..4a6ba99 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -151,8 +151,8 @@ public class RobotContainer { Map.entry(aumilieux, creerCommandBras(9, -14)), Map.entry(enbas, creerCommandBras(44, -17)), Map.entry(nulpart, creerCommandBras(0, 0))), chooser::getSelected), - creerCommandBras(49, 40).unless(() -> chooser.getSelected().equals(enhaut)), - creerCommandBras(51, 40).unless(() -> chooser.getSelected().equals(enhaut)), + creerCommandBras(49, -40).unless(() -> chooser.getSelected().equals(enhaut)), + creerCommandBras(51, -40).unless(() -> chooser.getSelected().equals(enhaut)), new OuvrePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), Commands.waitSeconds(1), new FermePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), From 8da3ff39b2de78ad36c0c63cc05dac56007bda91 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Wed, 12 Apr 2023 17:15:48 -0400 Subject: [PATCH 07/12] dhgvjb --- src/main/java/frc/robot/RobotContainer.java | 15 ++++++++------- src/main/java/frc/robot/commands/Avancer.java | 1 + src/main/java/frc/robot/commands/Reculer.java | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 4a6ba99..7273303 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -17,6 +17,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; @@ -67,6 +68,7 @@ public class RobotContainer { GenericEntry reculerdistances = layoutauto.addPersistent("reculerdistancesortir", -66).getEntry(); GenericEntry reculerdistanceb = layoutauto.addPersistent("reculerdistancebalance", -31).getEntry(); GenericEntry avancerdistance = layoutauto.addPersistent("avancer", 35).getEntry(); + GenericEntry avancerforce = layoutauto.addPersistent("avancerforce", 0.4).getEntry(); // subsystems BasePilotable basePilotable = new BasePilotable(); Gratte gratte = new Gratte(); @@ -148,17 +150,16 @@ public class RobotContainer { new SequentialCommandGroup( Commands.select(Map.ofEntries( Map.entry(enhaut, creerCommandBras(51, -40)), - Map.entry(aumilieux, creerCommandBras(9, -14)), - Map.entry(enbas, creerCommandBras(44, -17)), + Map.entry(aumilieux, creerCommandBras(45, -13)), + Map.entry(enbas, creerCommandBras(12, -9)), Map.entry(nulpart, creerCommandBras(0, 0))), chooser::getSelected), - creerCommandBras(49, -40).unless(() -> chooser.getSelected().equals(enhaut)), - creerCommandBras(51, -40).unless(() -> chooser.getSelected().equals(enhaut)), + //creerCommandBras(50, -40).unless(() -> !chooser.getSelected().equals(enhaut)), + //creerCommandBras(51, -40).unless(() -> !chooser.getSelected().equals(enhaut)), new OuvrePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), Commands.waitSeconds(1), new FermePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), - creerCommandBras(0, 0).unless(() -> chooser.getSelected().equals(nulpart)), - Commands.waitSeconds(1), - Commands.either(reculers, reculerb, () -> autosortir.getBoolean(true)), + new ParallelCommandGroup (creerCommandBras(0, 0).unless(() -> chooser.getSelected().equals(nulpart)), + Commands.either(reculers, reculerb, () -> autosortir.getBoolean(true))), new Avancer(basePilotable, () -> avancerdistance.getDouble(0)).unless(() -> !autosortir.getBoolean(true) || !autobalance.getBoolean(false)), Commands.either(gyro, Commands.none(), () -> autobalance.getBoolean(true)))) .andThen(brakeOuvre); diff --git a/src/main/java/frc/robot/commands/Avancer.java b/src/main/java/frc/robot/commands/Avancer.java index f7d37a1..c0cc3cf 100644 --- a/src/main/java/frc/robot/commands/Avancer.java +++ b/src/main/java/frc/robot/commands/Avancer.java @@ -7,6 +7,7 @@ package frc.robot.commands; import java.util.function.DoubleSupplier; +import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.BasePilotable; diff --git a/src/main/java/frc/robot/commands/Reculer.java b/src/main/java/frc/robot/commands/Reculer.java index 903b216..51e81b2 100644 --- a/src/main/java/frc/robot/commands/Reculer.java +++ b/src/main/java/frc/robot/commands/Reculer.java @@ -30,7 +30,7 @@ public class Reculer extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - basePilotable.drive(-0.4,0); + basePilotable.drive(-0.45,0); } // Called once the command ends or is interrupted. From c90f8d12ea0e82e9ff98bae4973a5fb9c7797180 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Wed, 12 Apr 2023 17:21:35 -0400 Subject: [PATCH 08/12] yrjxcvukjbk --- src/main/java/frc/robot/RobotContainer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 7273303..9942932 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -41,8 +41,7 @@ import frc.robot.commands.GratteMonte; import frc.robot.commands.Gyro; import frc.robot.commands.Reculer; import frc.robot.commands.Tape; -import frc.robot.commands.bras.Bougerbras; -import frc.robot.commands.bras.Bougerpivot; + import frc.robot.commands.bras.BrasManuel; import frc.robot.commands.bras.DescendrePivotBras; import frc.robot.commands.bras.FermePince; From 94ac975b75ef3e74c4fe8407e7cc2806cde14b87 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Wed, 12 Apr 2023 17:28:47 -0400 Subject: [PATCH 09/12] xfjchgjk --- 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 9942932..227763a 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -68,6 +68,7 @@ public class RobotContainer { GenericEntry reculerdistanceb = layoutauto.addPersistent("reculerdistancebalance", -31).getEntry(); GenericEntry avancerdistance = layoutauto.addPersistent("avancer", 35).getEntry(); GenericEntry avancerforce = layoutauto.addPersistent("avancerforce", 0.4).getEntry(); + GenericEntry reculerforce = layoutauto.addPersistent("reculerforce", 0.4).getEntry(); // subsystems BasePilotable basePilotable = new BasePilotable(); Gratte gratte = new Gratte(); From a1062d3ae368259d4fcd8e57caac6f8a146193d3 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Wed, 12 Apr 2023 19:35:44 -0400 Subject: [PATCH 10/12] yfcghjhfhcgvnm --- src/main/java/frc/robot/RobotContainer.java | 29 ++++++++++++------- src/main/java/frc/robot/commands/Avancer.java | 7 +++-- src/main/java/frc/robot/commands/Gyro.java | 10 +++++-- src/main/java/frc/robot/commands/Reculer.java | 6 ++-- .../frc/robot/commands/bras/Bougerbras.java | 13 +++++++-- .../frc/robot/commands/bras/Bougerpivot.java | 13 +++++++-- .../commands/bras/DescendrePivotBras.java | 7 +++-- .../robot/commands/bras/MonterPivotBras.java | 9 +++--- .../frc/robot/subsystems/BasePilotable.java | 1 + 9 files changed, 63 insertions(+), 32 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 227763a..f39e5a9 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -13,6 +13,7 @@ import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets; 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.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; @@ -60,15 +61,21 @@ public class RobotContainer { String aumilieux = "au milieux"; String enbas = "en bas"; String nulpart = "nul part"; + GenericEntry forcebrasmonter = Shuffleboard.getTab("teb").addPersistent("force bras monter", 0.35).getEntry(); + GenericEntry forcebrasdescendre = Shuffleboard.getTab("teb").addPersistent("force bras descendre", -0.35).getEntry(); + GenericEntry forcepivotmonter = Shuffleboard.getTab("teb").addPersistent("force pivot monter", 0.5).getEntry(); + GenericEntry forcepivotdescendre = Shuffleboard.getTab("teb").addPersistent("force pivot descendre", -0.5).getEntry(); ShuffleboardLayout layoutauto = Shuffleboard.getTab("teb").getLayout("auto", BuiltInLayouts.kList) .withSize(2, 2).withProperties(Map.of("Label position", "LEFT")); GenericEntry autobalance = layoutauto.add("choix balance", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); GenericEntry autosortir = layoutauto.add("choix sortir", false).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); - GenericEntry reculerdistances = layoutauto.addPersistent("reculerdistancesortir", -66).getEntry(); - GenericEntry reculerdistanceb = layoutauto.addPersistent("reculerdistancebalance", -31).getEntry(); + GenericEntry reculerdistances = layoutauto.addPersistent("reculer distance sortir", -66).getEntry(); + GenericEntry reculerdistanceb = layoutauto.addPersistent("reculer distance balance", -31).getEntry(); GenericEntry avancerdistance = layoutauto.addPersistent("avancer", 35).getEntry(); - GenericEntry avancerforce = layoutauto.addPersistent("avancerforce", 0.4).getEntry(); - GenericEntry reculerforce = layoutauto.addPersistent("reculerforce", 0.4).getEntry(); + GenericEntry avancerforce = layoutauto.addPersistent("avancer force", 0.4).getEntry(); + GenericEntry reculerforce = layoutauto.addPersistent("reculer force", -0.45).getEntry(); + GenericEntry gyroforce = layoutauto.addPersistent("gyro force", 0.3).getEntry(); + // subsystems BasePilotable basePilotable = new BasePilotable(); Gratte gratte = new Gratte(); @@ -82,13 +89,13 @@ public class RobotContainer { BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable); GratteBaisser gratteBaisser = new GratteBaisser(gratte); GratteMonte gratteMonte = new GratteMonte(gratte); - Gyro gyro = new Gyro(basePilotable); + Gyro gyro = new Gyro(basePilotable,()->gyroforce.getDouble(0)); FermePince fermePince = new FermePince(pince); OuvrePince ouvrePince = new OuvrePince(pince); Cone cone = new Cone(limelight, basePilotable, () -> -manette1.getLeftY()); - Reculer reculers = new Reculer(basePilotable, () -> reculerdistances.getDouble(0)); - Reculer reculerb = new Reculer(basePilotable, () -> reculerdistanceb.getDouble(0)); - Avancer avancer = new Avancer(basePilotable, () -> avancerdistance.getDouble(0)); + Reculer reculers = new Reculer(basePilotable, () -> reculerdistances.getDouble(0),()->reculerforce.getDouble(0)); + Reculer reculerb = new Reculer(basePilotable, () -> reculerdistanceb.getDouble(0),()->reculerforce.getDouble(0)); + Avancer avancer = new Avancer(basePilotable, () -> avancerdistance.getDouble(0),()-> avancerforce.getDouble(0)); Cube cube = new Cube(limelight, basePilotable, () -> manette1.getLeftY()); Apriltag aprilTag = new Apriltag(limelight, basePilotable, () -> manette1.getLeftY()); Tape tape = new Tape(limelight, basePilotable, () -> manette1.getLeftY()); @@ -137,8 +144,8 @@ public class RobotContainer { private Command creerCommandBras(double distancePivot, double distanceBras) { return Commands.either( - new MonterPivotBras(brasTelescopique, pivot, distanceBras, distancePivot), - new DescendrePivotBras(brasTelescopique, pivot, distanceBras, distancePivot), + new MonterPivotBras(brasTelescopique, pivot, distanceBras, distancePivot,forcebrasmonter,forcebrasdescendre,forcepivotmonter,forcepivotdescendre), + new DescendrePivotBras(brasTelescopique, pivot, distanceBras, distancePivot,forcebrasmonter,forcebrasdescendre,forcepivotmonter,forcepivotdescendre), () -> pivot.distance() < distancePivot); } @@ -160,7 +167,7 @@ public class RobotContainer { new FermePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), new ParallelCommandGroup (creerCommandBras(0, 0).unless(() -> chooser.getSelected().equals(nulpart)), Commands.either(reculers, reculerb, () -> autosortir.getBoolean(true))), - new Avancer(basePilotable, () -> avancerdistance.getDouble(0)).unless(() -> !autosortir.getBoolean(true) || !autobalance.getBoolean(false)), + new Avancer(basePilotable, () -> avancerdistance.getDouble(0),()->avancerforce.getDouble(0)).unless(() -> !autosortir.getBoolean(true) || !autobalance.getBoolean(false)), Commands.either(gyro, Commands.none(), () -> autobalance.getBoolean(true)))) .andThen(brakeOuvre); diff --git a/src/main/java/frc/robot/commands/Avancer.java b/src/main/java/frc/robot/commands/Avancer.java index c0cc3cf..f62d7f9 100644 --- a/src/main/java/frc/robot/commands/Avancer.java +++ b/src/main/java/frc/robot/commands/Avancer.java @@ -7,17 +7,18 @@ package frc.robot.commands; import java.util.function.DoubleSupplier; -import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.BasePilotable; public class Avancer extends CommandBase { BasePilotable basePilotable; DoubleSupplier distance; + DoubleSupplier force; /** Creates a new Reculer. */ - public Avancer(BasePilotable basePilotable, DoubleSupplier distance) { + public Avancer(BasePilotable basePilotable, DoubleSupplier distance, DoubleSupplier force) { this.basePilotable = basePilotable; this.distance = distance; + this.force = force; // Use addRequirements() here to declare subsystem dependencies. addRequirements(basePilotable); } @@ -31,7 +32,7 @@ public class Avancer extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - basePilotable.drive(0.4,0); + basePilotable.drive(force.getAsDouble(),0); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/Gyro.java b/src/main/java/frc/robot/commands/Gyro.java index 7874235..ea56e0d 100644 --- a/src/main/java/frc/robot/commands/Gyro.java +++ b/src/main/java/frc/robot/commands/Gyro.java @@ -5,14 +5,18 @@ package frc.robot.commands; +import java.util.function.DoubleSupplier; + import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.BasePilotable; public class Gyro extends CommandBase { private BasePilotable basePilotable; + DoubleSupplier force; /** Creates a new Gyro. */ - public Gyro(BasePilotable basePilotable) { + public Gyro(BasePilotable basePilotable,DoubleSupplier force) { this.basePilotable = basePilotable; + this.force = force; // Use addRequirements() here to declare subsystem dependencies. addRequirements(basePilotable); } @@ -26,11 +30,11 @@ public class Gyro extends CommandBase { public void execute() { if(basePilotable.getpitch()>6) { - basePilotable.drive(0.3*basePilotable.getpitch()/12, 0); + basePilotable.drive(force.getAsDouble()*basePilotable.getpitch()/12, 0); } else if(basePilotable.getpitch()<-6) { - basePilotable.drive(0.3*basePilotable.getpitch()/12, 0); + basePilotable.drive(force.getAsDouble()*basePilotable.getpitch()/12, 0); } else { diff --git a/src/main/java/frc/robot/commands/Reculer.java b/src/main/java/frc/robot/commands/Reculer.java index 51e81b2..128cdfb 100644 --- a/src/main/java/frc/robot/commands/Reculer.java +++ b/src/main/java/frc/robot/commands/Reculer.java @@ -13,10 +13,12 @@ import frc.robot.subsystems.BasePilotable; public class Reculer extends CommandBase { BasePilotable basePilotable; DoubleSupplier distance; + DoubleSupplier force; /** Creates a new Reculer. */ - public Reculer(BasePilotable basePilotable, DoubleSupplier distance) { + public Reculer(BasePilotable basePilotable, DoubleSupplier distance,DoubleSupplier force) { this.basePilotable = basePilotable; this.distance = distance; + this.force = force; // Use addRequirements() here to declare subsystem dependencies. addRequirements(basePilotable); } @@ -30,7 +32,7 @@ public class Reculer extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - basePilotable.drive(-0.45,0); + basePilotable.drive(force.getAsDouble(),0); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/bras/Bougerbras.java b/src/main/java/frc/robot/commands/bras/Bougerbras.java index d807832..8a97404 100644 --- a/src/main/java/frc/robot/commands/bras/Bougerbras.java +++ b/src/main/java/frc/robot/commands/bras/Bougerbras.java @@ -4,6 +4,8 @@ package frc.robot.commands.bras; +import edu.wpi.first.networktables.GenericEntry; +import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.bras.BrasTelescopique; @@ -11,9 +13,14 @@ public class Bougerbras extends CommandBase { /** Creates a new bougerbras. */ double distance; BrasTelescopique brasTelescopique; - public Bougerbras(BrasTelescopique brasTelescopique,double distance) { + private GenericEntry forcebrasdescendre; + private GenericEntry forcebrasmonter; + + public Bougerbras(BrasTelescopique brasTelescopique,double distance,GenericEntry forcebrasdescendre, GenericEntry forcebrasmonter) { this.brasTelescopique = brasTelescopique; this.distance = distance; + this.forcebrasdescendre = forcebrasdescendre; + this.forcebrasmonter = forcebrasmonter; addRequirements(brasTelescopique); // Use addRequirements() here to declare subsystem dependencies. } @@ -28,11 +35,11 @@ public class Bougerbras extends CommandBase { @Override public void execute() { if(brasTelescopique.distance()>distance+0.5 ) { - brasTelescopique.AvanceRecule(-0.35); + brasTelescopique.AvanceRecule(forcebrasdescendre.getDouble(-0.35)); } else if(brasTelescopique.distance()distance+0.5 ) { - pivot.monteDescendre(-0.5); + pivot.monteDescendre(forcepivotdescendre.getDouble(-0.5)); } else if(pivot.distance()pivot.distance()>10), - new ParallelCommandGroup(new Bougerpivot(pivot, distancePivot)), - new ParallelCommandGroup(new Bougerbras(brasTelescopique, distanceBras)) + new Bougerpivot(pivot, 10, forcepivotdescendre, forcepivotdescendre).unless(()->pivot.distance()>10), + new ParallelCommandGroup(new Bougerpivot(pivot, distancePivot,forcepivotdescendre,forcepivotmonter)), + new ParallelCommandGroup(new Bougerbras(brasTelescopique, distanceBras,forcebrasdescendre,forcebrasmonter)) ); diff --git a/src/main/java/frc/robot/subsystems/BasePilotable.java b/src/main/java/frc/robot/subsystems/BasePilotable.java index a5d5b91..a582c7b 100644 --- a/src/main/java/frc/robot/subsystems/BasePilotable.java +++ b/src/main/java/frc/robot/subsystems/BasePilotable.java @@ -74,6 +74,7 @@ public void BrakeFerme(){ teb.add(drive); teb.addDouble("distancerobot",this::distance); teb.addDouble("angle gyro", this::getpitch); + } @Override From 59a7c30154c26e1efcd213391b182961d70f8e74 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Thu, 13 Apr 2023 18:25:05 -0400 Subject: [PATCH 11/12] fhcgjvhbm, --- src/main/java/frc/robot/RobotContainer.java | 8 ++------ .../java/frc/robot/commands/bras/Bougerbras.java | 13 ++++--------- .../java/frc/robot/commands/bras/Bougerpivot.java | 12 +++--------- .../frc/robot/commands/bras/DescendrePivotBras.java | 8 +++----- .../frc/robot/commands/bras/MonterPivotBras.java | 10 +++++----- 5 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index f39e5a9..62f6cad 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -61,10 +61,6 @@ public class RobotContainer { String aumilieux = "au milieux"; String enbas = "en bas"; String nulpart = "nul part"; - GenericEntry forcebrasmonter = Shuffleboard.getTab("teb").addPersistent("force bras monter", 0.35).getEntry(); - GenericEntry forcebrasdescendre = Shuffleboard.getTab("teb").addPersistent("force bras descendre", -0.35).getEntry(); - GenericEntry forcepivotmonter = Shuffleboard.getTab("teb").addPersistent("force pivot monter", 0.5).getEntry(); - GenericEntry forcepivotdescendre = Shuffleboard.getTab("teb").addPersistent("force pivot descendre", -0.5).getEntry(); ShuffleboardLayout layoutauto = Shuffleboard.getTab("teb").getLayout("auto", BuiltInLayouts.kList) .withSize(2, 2).withProperties(Map.of("Label position", "LEFT")); GenericEntry autobalance = layoutauto.add("choix balance", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); @@ -144,8 +140,8 @@ public class RobotContainer { private Command creerCommandBras(double distancePivot, double distanceBras) { return Commands.either( - new MonterPivotBras(brasTelescopique, pivot, distanceBras, distancePivot,forcebrasmonter,forcebrasdescendre,forcepivotmonter,forcepivotdescendre), - new DescendrePivotBras(brasTelescopique, pivot, distanceBras, distancePivot,forcebrasmonter,forcebrasdescendre,forcepivotmonter,forcepivotdescendre), + new MonterPivotBras(brasTelescopique, pivot, distanceBras, distancePivot), + new DescendrePivotBras(brasTelescopique, pivot, distanceBras, distancePivot), () -> pivot.distance() < distancePivot); } diff --git a/src/main/java/frc/robot/commands/bras/Bougerbras.java b/src/main/java/frc/robot/commands/bras/Bougerbras.java index 8a97404..8c658e0 100644 --- a/src/main/java/frc/robot/commands/bras/Bougerbras.java +++ b/src/main/java/frc/robot/commands/bras/Bougerbras.java @@ -4,8 +4,6 @@ package frc.robot.commands.bras; -import edu.wpi.first.networktables.GenericEntry; -import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.bras.BrasTelescopique; @@ -13,14 +11,11 @@ public class Bougerbras extends CommandBase { /** Creates a new bougerbras. */ double distance; BrasTelescopique brasTelescopique; - private GenericEntry forcebrasdescendre; - private GenericEntry forcebrasmonter; - public Bougerbras(BrasTelescopique brasTelescopique,double distance,GenericEntry forcebrasdescendre, GenericEntry forcebrasmonter) { + public Bougerbras(BrasTelescopique brasTelescopique,double distance) { this.brasTelescopique = brasTelescopique; this.distance = distance; - this.forcebrasdescendre = forcebrasdescendre; - this.forcebrasmonter = forcebrasmonter; + addRequirements(brasTelescopique); // Use addRequirements() here to declare subsystem dependencies. } @@ -35,11 +30,11 @@ public class Bougerbras extends CommandBase { @Override public void execute() { if(brasTelescopique.distance()>distance+0.5 ) { - brasTelescopique.AvanceRecule(forcebrasdescendre.getDouble(-0.35)); + brasTelescopique.AvanceRecule(0.35); } else if(brasTelescopique.distance()distance+0.5 ) { - pivot.monteDescendre(forcepivotdescendre.getDouble(-0.5)); + pivot.monteDescendre(0.5); } else if(pivot.distance()pivot.distance()>10), - new ParallelCommandGroup(new Bougerpivot(pivot, distancePivot,forcepivotdescendre,forcepivotmonter)), - new ParallelCommandGroup(new Bougerbras(brasTelescopique, distanceBras,forcebrasdescendre,forcebrasmonter)) + new Bougerpivot(pivot, 10).unless(()->pivot.distance()>10), + new ParallelCommandGroup(new Bougerpivot(pivot, distancePivot)), + new ParallelCommandGroup(new Bougerbras(brasTelescopique, distanceBras)) ); From a73b9c7374749fb8d820f4645c3f120807b5556b Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Wed, 3 May 2023 19:30:01 -0400 Subject: [PATCH 12/12] idifjkeakjfo h --- src/main/java/frc/robot/RobotContainer.java | 31 ++++++++++--------- .../frc/robot/commands/bras/Bougerbras.java | 4 +-- .../frc/robot/commands/bras/Bougerpivot.java | 4 +-- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 62f6cad..ee10622 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -6,7 +6,6 @@ package frc.robot; import java.util.Map; - import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.networktables.GenericEntry; import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; @@ -50,6 +49,7 @@ import frc.robot.commands.bras.MonterPivotBras; import frc.robot.commands.bras.OuvrePince; import frc.robot.commands.bras.PivotManuel; import frc.robot.commands.ActiverLimeLight; + public class RobotContainer { CommandXboxController manette1 = new CommandXboxController(0); @@ -71,7 +71,7 @@ public class RobotContainer { GenericEntry avancerforce = layoutauto.addPersistent("avancer force", 0.4).getEntry(); GenericEntry reculerforce = layoutauto.addPersistent("reculer force", -0.45).getEntry(); GenericEntry gyroforce = layoutauto.addPersistent("gyro force", 0.3).getEntry(); - + // subsystems BasePilotable basePilotable = new BasePilotable(); Gratte gratte = new Gratte(); @@ -85,13 +85,13 @@ public class RobotContainer { BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable); GratteBaisser gratteBaisser = new GratteBaisser(gratte); GratteMonte gratteMonte = new GratteMonte(gratte); - Gyro gyro = new Gyro(basePilotable,()->gyroforce.getDouble(0)); + Gyro gyro = new Gyro(basePilotable, () -> gyroforce.getDouble(0)); FermePince fermePince = new FermePince(pince); OuvrePince ouvrePince = new OuvrePince(pince); Cone cone = new Cone(limelight, basePilotable, () -> -manette1.getLeftY()); - Reculer reculers = new Reculer(basePilotable, () -> reculerdistances.getDouble(0),()->reculerforce.getDouble(0)); - Reculer reculerb = new Reculer(basePilotable, () -> reculerdistanceb.getDouble(0),()->reculerforce.getDouble(0)); - Avancer avancer = new Avancer(basePilotable, () -> avancerdistance.getDouble(0),()-> avancerforce.getDouble(0)); + Reculer reculers = new Reculer(basePilotable, () -> reculerdistances.getDouble(0), () -> reculerforce.getDouble(0)); + Reculer reculerb = new Reculer(basePilotable, () -> reculerdistanceb.getDouble(0), () -> reculerforce.getDouble(0)); + Avancer avancer = new Avancer(basePilotable, () -> avancerdistance.getDouble(0), () -> avancerforce.getDouble(0)); Cube cube = new Cube(limelight, basePilotable, () -> manette1.getLeftY()); Apriltag aprilTag = new Apriltag(limelight, basePilotable, () -> manette1.getLeftY()); Tape tape = new Tape(limelight, basePilotable, () -> manette1.getLeftY()); @@ -116,7 +116,7 @@ public class RobotContainer { private void configureBindings() { // manette 1 - manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince)); + manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer, pince)); manette2.a().onTrue(brakeOuvre); manette2.b().onTrue(brakeFerme); manette1.leftBumper().whileTrue(aprilTag); @@ -126,7 +126,7 @@ public class RobotContainer { manette1.povRight().whileTrue(creerCommandBras(44, -17)); manette1.povLeft().whileTrue(creerCommandBras(0, 0)); manette1.y().whileTrue(activerLimeLight); - //manette 2 + // manette 2 manette2.povDown().whileTrue(creerCommandBras(9, -18)); manette2.povUp().whileTrue(creerCommandBras(44, 0)); manette2.rightBumper().whileTrue(cube); @@ -156,14 +156,17 @@ public class RobotContainer { Map.entry(aumilieux, creerCommandBras(45, -13)), Map.entry(enbas, creerCommandBras(12, -9)), Map.entry(nulpart, creerCommandBras(0, 0))), chooser::getSelected), - //creerCommandBras(50, -40).unless(() -> !chooser.getSelected().equals(enhaut)), - //creerCommandBras(51, -40).unless(() -> !chooser.getSelected().equals(enhaut)), + // creerCommandBras(50, -40).unless(() -> + // !chooser.getSelected().equals(enhaut)), + // creerCommandBras(51, -40).unless(() -> + // !chooser.getSelected().equals(enhaut)), new OuvrePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), Commands.waitSeconds(1), - new FermePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), - new ParallelCommandGroup (creerCommandBras(0, 0).unless(() -> chooser.getSelected().equals(nulpart)), - Commands.either(reculers, reculerb, () -> autosortir.getBoolean(true))), - new Avancer(basePilotable, () -> avancerdistance.getDouble(0),()->avancerforce.getDouble(0)).unless(() -> !autosortir.getBoolean(true) || !autobalance.getBoolean(false)), + new FermePince(pince).unless(() -> chooser.getSelected().equals(nulpart)), + new ParallelCommandGroup(creerCommandBras(0, 0).unless(() -> chooser.getSelected().equals(nulpart)), + Commands.either(reculers, reculerb, () -> autosortir.getBoolean(true))), + new Avancer(basePilotable, () -> avancerdistance.getDouble(0), () -> avancerforce.getDouble(0)) + .unless(() -> !autosortir.getBoolean(true) || !autobalance.getBoolean(false)), Commands.either(gyro, Commands.none(), () -> autobalance.getBoolean(true)))) .andThen(brakeOuvre); diff --git a/src/main/java/frc/robot/commands/bras/Bougerbras.java b/src/main/java/frc/robot/commands/bras/Bougerbras.java index 8c658e0..20c3a99 100644 --- a/src/main/java/frc/robot/commands/bras/Bougerbras.java +++ b/src/main/java/frc/robot/commands/bras/Bougerbras.java @@ -30,11 +30,11 @@ public class Bougerbras extends CommandBase { @Override public void execute() { if(brasTelescopique.distance()>distance+0.5 ) { - brasTelescopique.AvanceRecule(0.35); + brasTelescopique.AvanceRecule(-0.35); } else if(brasTelescopique.distance()distance+0.5 ) { - pivot.monteDescendre(0.5); + pivot.monteDescendre(-0.5); } else if(pivot.distance()