From 64556db1cdf87628040a1dff60884d7848a2b896 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 7 Mar 2023 20:03:12 -0500 Subject: [PATCH] tfghjkm --- src/main/java/frc/robot/RobotContainer.java | 31 +++++++++------ .../frc/robot/commands/GratteBaisser.java | 8 ++-- .../java/frc/robot/commands/GratteMonte.java | 4 +- .../java/frc/robot/subsystems/Gratte.java | 38 ++++++++++++------- 4 files changed, 51 insertions(+), 30 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index eef6f29..3734664 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -18,6 +18,7 @@ import frc.robot.subsystems.bras.Pince; import frc.robot.subsystems.bras.Pivot; import pabeles.concurrency.ConcurrencyOps.Reset; import frc.robot.subsystems.Limelight; +import frc.robot.commands.Apriltag; // command import frc.robot.commands.BrakeFerme; import frc.robot.commands.BrakeOuvre; @@ -35,6 +36,7 @@ import frc.robot.commands.bras.PivoteBrasMilieux; import frc.robot.commands.bras.PivotChercheBas; import frc.robot.commands.bras.PivotChercheHaut; import edu.wpi.first.apriltag.AprilTag; +import edu.wpi.first.math.spline.CubicHermiteSpline; import frc.robot.commands.Cube; import frc.robot.commands.Cone; import frc.robot.commands.Tape; @@ -62,6 +64,12 @@ PivoteBrasBas pivoteBrasBas = new PivoteBrasBas(brasTelescopique, pivot); PivoteBrasMilieux pivoteBrasMilieux = new PivoteBrasMilieux(brasTelescopique, pivot); PivoteBrasHaut pivoteBrasHaut = new PivoteBrasHaut(brasTelescopique, pivot); Cone cone = new Cone(limelight, basePilotable, ()->-manette1.getLeftY()); +PivotChercheBas pivotChercheBas = new PivotChercheBas(brasTelescopique, pivot); +PivotChercheHaut pivotChercheHaut = new PivotChercheHaut(brasTelescopique, pivot); +Cube cube = new Cube(limelight, basePilotable, null); +Apriltag aprilTag = new Apriltag(limelight, basePilotable, null); +Tape tape = new Tape(limelight, basePilotable, null); + public RobotContainer() { configureBindings(); @@ -71,23 +79,24 @@ public RobotContainer() { } - private boolean configureBindings() { + private void configureBindings() { // manette 1 manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince)); manette1.x().toggleOnTrue(Commands.startEnd(basePilotable::BrakeFerme,basePilotable::BrakeOuvre,basePilotable)); manette1.y().whileTrue(gyro); manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable)); - manette1.b().toggleOnTrue(Commands.startEnd(gratte::baiser, gratte::Lever,gratte)); + manette1.b().onTrue(Commands.either(gratteBaisser, gratteMonte, gratte::getenHaut)); + manette1.leftBumper().toggleOnTrue(aprilTag); + manette1.rightBumper().toggleOnTrue(tape); // manette 2 - manette2.a().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasHaut, brasTelescopique::pivoteBrasHaut, brasTelescopique)); - manette2.b().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasBas, brasTelescopique::pivoteBrasBas, brasTelescopique)); - manette2.x().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasMilieux, brasTelescopique::pivoteBrasMilieux, brasTelescopique)); - manette2.y().toggleOnTrue(Commands.startEnd(brasTelescopique::pivotBrasRentre, brasTelescopique::pivotBrasRentre, brasTelescopique)); - manette2.povRight().toggleOnTrue(Commands.startEnd(brasTelescopique::PivotChercheBas, brasTelescopique::PivotChercheBas, brasTelescopique)); - manette2.povLeft().toggleOnTrue(Commands.startEnd(brasTelescopique::PivotChercheHaut, brasTelescopique::PivotChercheHaut, brasTelescopique)); - manette2.rightBumper().toggleOnTrue(Commands.startEnd(null, null, null)); - manette2.leftBumper().toggleOnTrue(Commands.startEnd(null, null, null)); - + manette2.a().onTrue(pivoteBrasHaut); + manette2.b().onTrue(pivoteBrasBas); + manette2.x().onTrue(pivoteBrasMilieux); + manette2.y().onTrue(pivotBrasRentre); + manette2.povRight().onTrue(pivotChercheBas); + manette2.povLeft().onTrue(pivotChercheHaut); + manette2.rightBumper().toggleOnTrue(cube); + manette2.leftBumper().toggleOnTrue(cone); } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/commands/GratteBaisser.java b/src/main/java/frc/robot/commands/GratteBaisser.java index 8984475..61c7240 100644 --- a/src/main/java/frc/robot/commands/GratteBaisser.java +++ b/src/main/java/frc/robot/commands/GratteBaisser.java @@ -18,7 +18,9 @@ public class GratteBaisser extends CommandBase { // Called when the command is initially scheduled. @Override - public void initialize() {} + public void initialize() { + gratte.setenHaut(false); + } // Called every time the scheduler runs while the command is scheduled. @Override @@ -41,9 +43,7 @@ public class GratteBaisser extends CommandBase { // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) { - - } + public void end(boolean interrupted) {} // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/commands/GratteMonte.java b/src/main/java/frc/robot/commands/GratteMonte.java index 3581712..507b90d 100644 --- a/src/main/java/frc/robot/commands/GratteMonte.java +++ b/src/main/java/frc/robot/commands/GratteMonte.java @@ -19,7 +19,9 @@ public class GratteMonte extends CommandBase { // Called when the command is initially scheduled. @Override - public void initialize() {} + public void initialize() { + gratte.setenHaut(true); + } // Called every time the scheduler runs while the command is scheduled. @Override diff --git a/src/main/java/frc/robot/subsystems/Gratte.java b/src/main/java/frc/robot/subsystems/Gratte.java index 3f727ef..0934180 100644 --- a/src/main/java/frc/robot/subsystems/Gratte.java +++ b/src/main/java/frc/robot/subsystems/Gratte.java @@ -5,6 +5,11 @@ package frc.robot.subsystems; import edu.wpi.first.wpilibj2.command.SubsystemBase; + +import javax.swing.text.StyledEditorKit.BoldAction; + +import org.apache.commons.collections4.functors.IfClosure; + import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; @@ -25,8 +30,16 @@ 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; - + 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(); } @@ -35,14 +48,19 @@ public boolean baiser; return limithg.get(); } - public boolean basd(int i, String string){ + public boolean basd(){ return limitbd.get(); } public boolean basg(){ return limitbg.get(); } /** Creates a new Gratte. */ - public Gratte() {} + public Gratte() { + + } + + + public void Lever(double vitesse){ Gratted.set(vitesse); Gratteg.set(vitesse); @@ -52,18 +70,10 @@ public boolean baiser; Gratteg.set(-vitesse); } @Override - public void periodic() { - teb .add("limithd", 0.1); - teb .add("limithg", 0.1); - teb .add("limitbd", 0.1); - teb .add("limitbg", 0.1); + public void periodic(){ limitswitchgratte.add ("limitbd", 0.1); limitswitchgratte.add ("limithg", 0.1); limitswitchgratte.add ("limithd", 0.1); limitswitchgratte.add ("limitbg", 0.1); } - -public boolean basd() { - return false; -} -} +} \ No newline at end of file