From aa420b56af41558d8c0043369bddd916e6a22930 Mon Sep 17 00:00:00 2001 From: Olivier Demers Date: Tue, 21 Mar 2023 23:17:59 +0000 Subject: [PATCH] Grattedebug --- src/main/java/frc/robot/Constants.java | 4 ++-- src/main/java/frc/robot/RobotContainer.java | 6 +++--- .../frc/robot/commands/ActiverLimeLight.java | 4 +++- .../frc/robot/commands/GratteBaisser.java | 14 ++++++------- .../java/frc/robot/commands/GratteMonte.java | 13 ++++++------ .../commands/bras/DescendrePivotBras.java | 2 ++ .../robot/commands/bras/MonterPivotBras.java | 10 +++++---- .../commands/bras/PivoteBrasMilieux.java | 4 ++-- .../java/frc/robot/subsystems/Gratte.java | 21 +++---------------- .../java/frc/robot/subsystems/Limelight.java | 5 ++++- 10 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 13b0abe..692915c 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -11,8 +11,8 @@ public class Constants { //moteur - public static int GratteD = 7; - public static int GratteG = 8; + public static int GratteD = 8; + public static int GratteG = 7; // pneumatique diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 633b898..1acf40d 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -114,9 +114,9 @@ public class RobotContainer { manette1.b().onTrue(brakeFerme); manette1.leftBumper().whileTrue(aprilTag); manette1.rightBumper().whileTrue(tape); - manette1.povUp().whileTrue(creerCommandBras(51, -40)); - manette1.povDown().whileTrue(creerCommandBras(9, -14)); - manette1.povRight().whileTrue(creerCommandBras(44, -17)); + manette1.povUp().whileTrue(creerCommandBras(51, -37)); + manette1.povDown().whileTrue(creerCommandBras(9, -12)); + manette1.povRight().whileTrue(creerCommandBras(45, -13)); manette1.povLeft().whileTrue(creerCommandBras(0, 0)); manette1.y().whileTrue(activerLimeLight); //manette 2 diff --git a/src/main/java/frc/robot/commands/ActiverLimeLight.java b/src/main/java/frc/robot/commands/ActiverLimeLight.java index 79e7fe9..3458798 100644 --- a/src/main/java/frc/robot/commands/ActiverLimeLight.java +++ b/src/main/java/frc/robot/commands/ActiverLimeLight.java @@ -28,7 +28,9 @@ public class ActiverLimeLight extends CommandBase { // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + limelight.joueurhumain1(); + } // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/commands/GratteBaisser.java b/src/main/java/frc/robot/commands/GratteBaisser.java index 9d1292f..5649059 100644 --- a/src/main/java/frc/robot/commands/GratteBaisser.java +++ b/src/main/java/frc/robot/commands/GratteBaisser.java @@ -20,23 +20,23 @@ public class GratteBaisser extends CommandBase { // Called when the command is initially scheduled. @Override public void initialize() { - gratte.setenHaut(false); + } // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { if(gratte.basd()){ - gratte.baiserd(0); + gratte.bougerd(0); } else{ - gratte.baiserd(0.5); + gratte.bougerd(0.3); } if(gratte.basg()){ - gratte.baiserg(0); + gratte.bougerg(0); } else{ - gratte.baiserg(0.5); + gratte.bougerg(0.3); } @@ -45,8 +45,8 @@ public class GratteBaisser extends CommandBase { // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - gratte.baiserd(0); - gratte.baiserg(0); + gratte.bougerd(0); + gratte.bougerg(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/commands/GratteMonte.java b/src/main/java/frc/robot/commands/GratteMonte.java index 0fd83fa..5dce6f8 100644 --- a/src/main/java/frc/robot/commands/GratteMonte.java +++ b/src/main/java/frc/robot/commands/GratteMonte.java @@ -20,31 +20,30 @@ public class GratteMonte extends CommandBase { // Called when the command is initially scheduled. @Override public void initialize() { - gratte.setenHaut(true); } // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { if(gratte.hautd()){ - gratte.Leverd(0); + gratte.bougerd(0); } else{ - gratte.Leverd(0.5); + gratte.bougerd(-0.3); } if(gratte.hautg()) { - gratte.Leverg(0); + gratte.bougerg(0); } else{ - gratte.Leverg(0.5); + gratte.bougerg(-0.3); } } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - gratte.Leverd(0); - gratte.Leverg(0); + gratte.bougerd(0); + gratte.bougerg(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/commands/bras/DescendrePivotBras.java b/src/main/java/frc/robot/commands/bras/DescendrePivotBras.java index 83cecb7..8b4a615 100644 --- a/src/main/java/frc/robot/commands/bras/DescendrePivotBras.java +++ b/src/main/java/frc/robot/commands/bras/DescendrePivotBras.java @@ -18,8 +18,10 @@ public class DescendrePivotBras extends SequentialCommandGroup { // Add your commands in the addCommands() call, e.g. // addCommands(new FooCommand(), new BarCommand()); addCommands( + new Bougerbras(brasTelescopique, distanceBras), new Bougerpivot(pivot, distancePivot) + ); } } diff --git a/src/main/java/frc/robot/commands/bras/MonterPivotBras.java b/src/main/java/frc/robot/commands/bras/MonterPivotBras.java index a7d8153..b0e6441 100644 --- a/src/main/java/frc/robot/commands/bras/MonterPivotBras.java +++ b/src/main/java/frc/robot/commands/bras/MonterPivotBras.java @@ -4,7 +4,7 @@ package frc.robot.commands.bras; -import edu.wpi.first.wpilibj2.command.Commands; + import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import frc.robot.subsystems.bras.BrasTelescopique; @@ -13,15 +13,17 @@ import frc.robot.subsystems.bras.Pivot; // NOTE: Consider using this command inline, rather than writing a subclass. For more // information, see: // https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html -public class MonterPivotBras extends ParallelCommandGroup { +public class MonterPivotBras extends SequentialCommandGroup { /** Creates a new Sequancepivotbras. */ public MonterPivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot) { // Add your commands in the addCommands() call, e.g. // addCommands(new FooCommand(), new BarCommand()); addCommands( - new SequentialCommandGroup(Commands.waitUntil(()->pivot.distance()>8),new Bougerbras(brasTelescopique, distanceBras)), - new Bougerpivot(pivot, distancePivot) + new Bougerpivot(pivot, 10).unless(()->pivot.distance()>10), + new ParallelCommandGroup(new Bougerpivot(pivot, distancePivot)), + new ParallelCommandGroup(new Bougerbras(brasTelescopique, distanceBras)) + ); } diff --git a/src/main/java/frc/robot/commands/bras/PivoteBrasMilieux.java b/src/main/java/frc/robot/commands/bras/PivoteBrasMilieux.java index 4494a33..8d10a66 100644 --- a/src/main/java/frc/robot/commands/bras/PivoteBrasMilieux.java +++ b/src/main/java/frc/robot/commands/bras/PivoteBrasMilieux.java @@ -29,11 +29,11 @@ public class PivoteBrasMilieux extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(brasTelescopique.distance()>-12.5){ + if(brasTelescopique.distance()>-11){ brasTelescopique.AvanceRecule(-0.15); brasTelescopique.fermer(); } - else if(brasTelescopique.distance()<-13.5) { + else if(brasTelescopique.distance()<-13) { brasTelescopique.AvanceRecule(0.15); } else { diff --git a/src/main/java/frc/robot/subsystems/Gratte.java b/src/main/java/frc/robot/subsystems/Gratte.java index d5920cf..b78edad 100644 --- a/src/main/java/frc/robot/subsystems/Gratte.java +++ b/src/main/java/frc/robot/subsystems/Gratte.java @@ -24,15 +24,6 @@ ShuffleboardLayout limitswitchgratte = Shuffleboard.getTab("teb") private DigitalInput limithg = new DigitalInput(Constants.limithg); private DigitalInput limitbd = new DigitalInput(Constants.limitbd); private DigitalInput limitbg = new DigitalInput(Constants.limitbg); - public boolean baiser; - boolean enHaut = true; - public void setenHaut(boolean enHaut){ - this.enHaut = enHaut; - } - public boolean getenHaut(){ - return enHaut; - - } public boolean hautd(){ return limithd.get(); @@ -55,17 +46,11 @@ ShuffleboardLayout limitswitchgratte = Shuffleboard.getTab("teb") limitswitchgratte.addBoolean ("limithd", this::hautd); limitswitchgratte.addBoolean ("limitbg", this::basg); } - public void Leverd(double vitesse){ - Gratted.set(-vitesse); + public void bougerd(double vitesse){ + Gratted.set(vitesse); } - public void Leverg(double vitesse){ - Gratteg.set(-vitesse); - } - public void baiserd(double vitesse){ - Gratted.set(vitesse); - } - public void baiserg(double vitesse){ + public void bougerg(double vitesse){ Gratteg.set(vitesse); } diff --git a/src/main/java/frc/robot/subsystems/Limelight.java b/src/main/java/frc/robot/subsystems/Limelight.java index 4663c1b..0417352 100644 --- a/src/main/java/frc/robot/subsystems/Limelight.java +++ b/src/main/java/frc/robot/subsystems/Limelight.java @@ -47,7 +47,7 @@ public class Limelight extends SubsystemBase { public double getYaw() { var result = limelight.getLatestResult(); if(result.hasTargets()){ - return -result.getBestTarget().getYaw()/60; + return -result.getBestTarget().getYaw()/30; } return 0; @@ -57,6 +57,9 @@ public class Limelight extends SubsystemBase { limelight.setDriverMode(true); } public void joueurhumain(){ + limelight.setLED(VisionLEDMode.kOn); + } + public void joueurhumain1(){ limelight.setLED(VisionLEDMode.kOff); } @Override