diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 710e70d..bfc6d3b 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -17,6 +17,7 @@ import frc.robot.subsystems.bras.BrasTelescopique; import frc.robot.subsystems.bras.Pince; import frc.robot.subsystems.bras.Pivot; import frc.robot.subsystems.Limelight; +import frc.robot.commands.Apriltag; // command import frc.robot.commands.BrakeFerme; import frc.robot.commands.BrakeOuvre; @@ -31,6 +32,10 @@ import frc.robot.commands.bras.PivotBrasRentre; import frc.robot.commands.bras.PivoteBrasBas; import frc.robot.commands.bras.PivoteBrasHaut; import frc.robot.commands.bras.PivoteBrasMilieux; +import frc.robot.commands.bras.PivotChercheBas; +import frc.robot.commands.bras.PivotChercheHaut; +import frc.robot.commands.Cube; +import frc.robot.commands.Tape; public class RobotContainer { @@ -57,6 +62,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(); @@ -67,19 +78,23 @@ public RobotContainer() { } 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)); - manette2.a().toggleOnTrue(Commands.startEnd(brasTelescopique::pivoteBrasHaut, brasTelescopique::pivoteBrasHaut)); - 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));**/ + manette1.b().onTrue(Commands.either(gratteBaisser, gratteMonte, gratte::getenHaut)); + manette1.leftBumper().toggleOnTrue(aprilTag); + manette1.rightBumper().toggleOnTrue(tape); + // manette 2 + 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 1657537..056c6da 100644 --- a/src/main/java/frc/robot/subsystems/Gratte.java +++ b/src/main/java/frc/robot/subsystems/Gratte.java @@ -3,7 +3,6 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot.subsystems; - import edu.wpi.first.wpilibj2.command.SubsystemBase; import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import edu.wpi.first.wpilibj.DigitalInput; @@ -24,8 +23,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(); } @@ -34,13 +41,13 @@ 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() { limitswitchgratte.add ("limitbd", 0.1); limitswitchgratte.add ("limithg", 0.1); @@ -56,11 +63,10 @@ public boolean baiser; Gratteg.set(-vitesse); } @Override - public void periodic() { - - } - -public boolean basd() { - return false; -} + public void periodic(){ + limitswitchgratte.add ("limitbd", 0.1); + limitswitchgratte.add ("limithg", 0.1); + limitswitchgratte.add ("limithd", 0.1); + limitswitchgratte.add ("limitbg", 0.1); } +} \ No newline at end of file