diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index f0fb8a8..1518cc8 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -18,6 +18,8 @@ public class Constants { public static int actuateur = 2; public static int brakedroit = 3; public static int brakegauche = 4; + public static int brakewinchf = 5; + public static int brakewinchb = 5; // DIO public static int limitbd = 0; public static int limitbg = 2; diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index aff140e..20a459a 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,7 +4,6 @@ package frc.robot; - import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; @@ -23,19 +22,16 @@ import frc.robot.subsystems.Limelight; import frc.robot.commands.BrakeFerme; import frc.robot.commands.BrakeOuvre; import frc.robot.commands.Cone; -import frc.robot.commands.Cube; import frc.robot.commands.GratteBaisser; 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.FermePince; import frc.robot.commands.bras.OuvrePince; 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.Apriltag; public class RobotContainer { CommandXboxController manette1 = new CommandXboxController(0); @@ -60,9 +56,6 @@ 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()); -Cube cube = new Cube(limelight, basePilotable, ()->-manette1.getLeftY()); -Apriltag aprilTag = new Apriltag(limelight, basePilotable, ()->-manette1.getLeftY()); -Tape tape = new Tape(limelight, basePilotable, ()->-manette1.getLeftY()); public RobotContainer() { configureBindings(); @@ -76,9 +69,8 @@ public RobotContainer() { 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.b().toggleOnTrue(Commands.startEnd()); + manette1.b().toggleOnTrue(Commands.startEnd(gratte::baiser, gratte::Lever,gratte)); manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable)); - } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/commands/GratteMonte.java b/src/main/java/frc/robot/commands/GratteMonte.java index b460277..3581712 100644 --- a/src/main/java/frc/robot/commands/GratteMonte.java +++ b/src/main/java/frc/robot/commands/GratteMonte.java @@ -4,8 +4,7 @@ package frc.robot.commands; -import com.ctre.phoenix.motorcontrol.LimitSwitchNormal; -import frc.robot.Constants; + import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.Gratte; diff --git a/src/main/java/frc/robot/commands/bras/PivotBrasRentre.java b/src/main/java/frc/robot/commands/bras/PivotBrasRentre.java index 192dc88..6efbb90 100644 --- a/src/main/java/frc/robot/commands/bras/PivotBrasRentre.java +++ b/src/main/java/frc/robot/commands/bras/PivotBrasRentre.java @@ -29,6 +29,7 @@ public class PivotBrasRentre extends CommandBase { public void execute() { if(brasTelescopique.distance()>1){ brasTelescopique.AvanceRecule(0.5); + brasTelescopique.fermer(); } if (pivot.distance()>1){ pivot.monteDescendre(0.5); @@ -36,9 +37,10 @@ public class PivotBrasRentre extends CommandBase { else if(brasTelescopique.photocell()){ brasTelescopique.Reset(); brasTelescopique.AvanceRecule(0); + brasTelescopique.ouvrir(); } else{ - brasTelescopique.AvanceRecule(.5); + brasTelescopique.AvanceRecule(0.5); } if(pivot.limitpivot()){ pivot.Reset(); diff --git a/src/main/java/frc/robot/commands/bras/PivotChercheBas.java b/src/main/java/frc/robot/commands/bras/PivotChercheBas.java new file mode 100644 index 0000000..76367e4 --- /dev/null +++ b/src/main/java/frc/robot/commands/bras/PivotChercheBas.java @@ -0,0 +1,61 @@ +// 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.commands.bras; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.bras.BrasTelescopique; +import frc.robot.subsystems.bras.Pivot; + +public class PivotChercheBas extends CommandBase { + private BrasTelescopique brasTelescopique; + private Pivot pivot; + /** Creates a new PivotChercheBas. */ + public PivotChercheBas(BrasTelescopique brasTelescopique, Pivot pivot) { + this.brasTelescopique = brasTelescopique; + this.pivot = pivot; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(brasTelescopique); + addRequirements(pivot); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + if(brasTelescopique.distance()<10){ + brasTelescopique.AvanceRecule(0.5); + brasTelescopique.fermer(); + } + else if(brasTelescopique.distance()>11) { + brasTelescopique.AvanceRecule(-0.5); + } + else { + brasTelescopique.AvanceRecule(0); + brasTelescopique.ouvrir(); + } + if (pivot.distance()<10){ + pivot.monteDescendre(0.5); + } + else if(pivot.distance()>11) { + pivot.monteDescendre(-0.5); + } + else{ + pivot.monteDescendre(0); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) {} + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/bras/PivotChercheHaut.java b/src/main/java/frc/robot/commands/bras/PivotChercheHaut.java new file mode 100644 index 0000000..1bdd45a --- /dev/null +++ b/src/main/java/frc/robot/commands/bras/PivotChercheHaut.java @@ -0,0 +1,61 @@ +// 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.commands.bras; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.bras.BrasTelescopique; +import frc.robot.subsystems.bras.Pivot; + +public class PivotChercheHaut extends CommandBase { + private BrasTelescopique brasTelescopique; + private Pivot pivot; + /** Creates a new PivotChercheHaut. */ + public PivotChercheHaut(BrasTelescopique brasTelescopique, Pivot pivot) { + this.brasTelescopique = brasTelescopique; + this.pivot = pivot; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(brasTelescopique); + addRequirements(pivot); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + if(brasTelescopique.distance()<10){ + brasTelescopique.AvanceRecule(0.5); + brasTelescopique.fermer(); + } + else if(brasTelescopique.distance()>11) { + brasTelescopique.AvanceRecule(-0.5); + } + else { + brasTelescopique.AvanceRecule(0); + brasTelescopique.ouvrir(); + } + if (pivot.distance()<10){ + pivot.monteDescendre(0.5); + } + else if(pivot.distance()>11) { + pivot.monteDescendre(-0.5); + } + else{ + pivot.monteDescendre(0); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) {} + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/bras/PivoteBrasBas.java b/src/main/java/frc/robot/commands/bras/PivoteBrasBas.java index 038ec51..226454e 100644 --- a/src/main/java/frc/robot/commands/bras/PivoteBrasBas.java +++ b/src/main/java/frc/robot/commands/bras/PivoteBrasBas.java @@ -31,12 +31,14 @@ public class PivoteBrasBas extends CommandBase { public void execute() { if(brasTelescopique.distance()<10){ brasTelescopique.AvanceRecule(0.5); + brasTelescopique.fermer(); } else if(brasTelescopique.distance()>11) { brasTelescopique.AvanceRecule(-0.5); } else { brasTelescopique.AvanceRecule(0); + brasTelescopique.ouvrir(); } if (pivot.distance()<10){ pivot.monteDescendre(0.5); diff --git a/src/main/java/frc/robot/commands/bras/PivoteBrasHaut.java b/src/main/java/frc/robot/commands/bras/PivoteBrasHaut.java index 2ba3c74..1968013 100644 --- a/src/main/java/frc/robot/commands/bras/PivoteBrasHaut.java +++ b/src/main/java/frc/robot/commands/bras/PivoteBrasHaut.java @@ -29,12 +29,14 @@ public class PivoteBrasHaut extends CommandBase { public void execute() { if(brasTelescopique.distance()<10){ brasTelescopique.AvanceRecule(0.5); + brasTelescopique.fermer(); } else if(brasTelescopique.distance()>11) { brasTelescopique.AvanceRecule(-0.5); } else { brasTelescopique.AvanceRecule(0); + brasTelescopique.ouvrir(); } if (pivot.distance()<10){ pivot.monteDescendre(0.5); diff --git a/src/main/java/frc/robot/commands/bras/PivoteBrasMilieux.java b/src/main/java/frc/robot/commands/bras/PivoteBrasMilieux.java index da8939b..c230cfc 100644 --- a/src/main/java/frc/robot/commands/bras/PivoteBrasMilieux.java +++ b/src/main/java/frc/robot/commands/bras/PivoteBrasMilieux.java @@ -29,12 +29,14 @@ public class PivoteBrasMilieux extends CommandBase { public void execute() { if(brasTelescopique.distance()<10){ brasTelescopique.AvanceRecule(0.5); + brasTelescopique.fermer(); } else if(brasTelescopique.distance()>11) { brasTelescopique.AvanceRecule(-0.5); } else { brasTelescopique.AvanceRecule(0); + brasTelescopique.ouvrir(); } if (pivot.distance()<10){ pivot.monteDescendre(0.5); diff --git a/src/main/java/frc/robot/subsystems/Limelight.java b/src/main/java/frc/robot/subsystems/Limelight.java index 5a4f7fc..58d30f8 100644 --- a/src/main/java/frc/robot/subsystems/Limelight.java +++ b/src/main/java/frc/robot/subsystems/Limelight.java @@ -10,7 +10,7 @@ import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import org.photonvision.PhotonCamera; import org.photonvision.common.hardware.VisionLEDMode; -import org.photonvision.targeting.PhotonTrackedTarget; + import edu.wpi.first.net.PortForwarder; import edu.wpi.first.wpilibj2.command.SubsystemBase; diff --git a/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java b/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java index 7334c0b..47ca244 100644 --- a/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java +++ b/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java @@ -9,6 +9,12 @@ import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import edu.wpi.first.wpilibj.DigitalInput; +<<<<<<< HEAD +======= +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.PneumaticsModuleType; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; +>>>>>>> 2c79346ce98c80f71d749f5cfbe0025b5dedf77a import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj2.command.SubsystemBase; @@ -20,6 +26,7 @@ public class BrasTelescopique extends SubsystemBase { public BrasTelescopique() {} final CANSparkMax Winch = new CANSparkMax(Constants.BrasTelescopique,MotorType.kBrushless); private DigitalInput photocell = new DigitalInput(Constants.photocell); + private DoubleSolenoid brakewinch = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.brakewinchf, Constants.brakewinchb); public void AvanceRecule(double vitesse) { Winch.set(vitesse); } @@ -30,11 +37,22 @@ public class BrasTelescopique extends SubsystemBase { Winch.getEncoder().setPosition(0); } public boolean photocell(){ - return photocell.get(); + return photocell.get(); } + public void fermer() { + brakewinch.set(Value.kReverse); + } + public void ouvrir() { + brakewinch.set(Value.kForward); + } @Override public void periodic() { +<<<<<<< HEAD teb .add("``photocell``",0.1); teb .add("winch",0.1); +======= + Shuffleboard.getTab("SmartDashBoard") .add("photocell",0.1); + Shuffleboard.getTab("SmartDashBoard") .add("winch",0.1); +>>>>>>> 2c79346ce98c80f71d749f5cfbe0025b5dedf77a } } diff --git a/src/main/java/frc/robot/subsystems/bras/Pivot.java b/src/main/java/frc/robot/subsystems/bras/Pivot.java index e4ea340..447e9cb 100644 --- a/src/main/java/frc/robot/subsystems/bras/Pivot.java +++ b/src/main/java/frc/robot/subsystems/bras/Pivot.java @@ -36,6 +36,14 @@ public class Pivot extends SubsystemBase { } @Override public void periodic() { +<<<<<<< HEAD teb .add("encodeur", 0.1); } } +======= + Shuffleboard.getTab("SmartDashBoard") .add("limitpivot",0.1); + Shuffleboard.getTab("SmartDashBoard") .add("pivot encodeur",0.1); + } + } + +>>>>>>> 2c79346ce98c80f71d749f5cfbe0025b5dedf77a