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 d9ff154..a68150c 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -32,6 +32,12 @@ 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 edu.wpi.first.apriltag.AprilTag; +import frc.robot.commands.Cube; +import frc.robot.commands.Cone; +import frc.robot.commands.Tape; public class RobotContainer { CommandXboxController manette1 = new CommandXboxController(0); @@ -69,8 +75,20 @@ 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); +<<<<<<< HEAD // manette1.b().toggleOnTrue(Commands.startEnd(gratte::baiser, gratte::Lever,gratte)); +======= +>>>>>>> 4b22cac30fd2b3c5e7b1af3c7f890c4def2d21f7 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)); } public Command getAutonomousCommand() { 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 index 33cc965..76367e4 100644 --- a/src/main/java/frc/robot/commands/bras/PivotChercheBas.java +++ b/src/main/java/frc/robot/commands/bras/PivotChercheBas.java @@ -29,12 +29,14 @@ public class PivotChercheBas 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/PivotChercheHaut.java b/src/main/java/frc/robot/commands/bras/PivotChercheHaut.java index 4288827..1bdd45a 100644 --- a/src/main/java/frc/robot/commands/bras/PivotChercheHaut.java +++ b/src/main/java/frc/robot/commands/bras/PivotChercheHaut.java @@ -29,12 +29,14 @@ public class PivotChercheHaut 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/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/BasePilotable.java b/src/main/java/frc/robot/subsystems/BasePilotable.java index 5ec5abc..b628ceb 100644 --- a/src/main/java/frc/robot/subsystems/BasePilotable.java +++ b/src/main/java/frc/robot/subsystems/BasePilotable.java @@ -76,5 +76,7 @@ public void resetGyro(){ teb .add("encodeurarrieredroit",0.1); teb .add("encodeuravantgauche",0.1); teb .add("distance",0.1); + teb .add("brakedroit",0.1); + teb .add("brakegauche", 0.1); } -} +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Gratte.java b/src/main/java/frc/robot/subsystems/Gratte.java index 4cefbae..0332f41 100644 --- a/src/main/java/frc/robot/subsystems/Gratte.java +++ b/src/main/java/frc/robot/subsystems/Gratte.java @@ -8,9 +8,11 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import frc.robot.Constants; public class Gratte extends SubsystemBase { + ShuffleboardTab teb = Shuffleboard.getTab("teb"); private WPI_TalonSRX Gratted = new WPI_TalonSRX(Constants.leverGratte); private WPI_TalonSRX Gratteg = new WPI_TalonSRX(Constants.baisserGratte); private DigitalInput limithd = new DigitalInput(Constants.limithd); @@ -44,9 +46,9 @@ public class Gratte extends SubsystemBase { } @Override public void periodic() { - Shuffleboard.getTab("SmartDashBoard") .add("limithd",0.1); - Shuffleboard.getTab("SmartDashBoard") .add("limitbd",0.1); - Shuffleboard.getTab("SmartDashBoard") .add("limithg",0.1); - Shuffleboard.getTab("SmartDashBoard") .add("limitbg",0.1); + teb .add("limithd", 0.1); + teb .add("limithg", 0.1); + teb .add("limitbd", 0.1); + teb .add("limitbg", 0.1); } } diff --git a/src/main/java/frc/robot/subsystems/Limelight.java b/src/main/java/frc/robot/subsystems/Limelight.java index 1d41677..58d30f8 100644 --- a/src/main/java/frc/robot/subsystems/Limelight.java +++ b/src/main/java/frc/robot/subsystems/Limelight.java @@ -6,6 +6,8 @@ package frc.robot.subsystems; import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; + import org.photonvision.PhotonCamera; import org.photonvision.common.hardware.VisionLEDMode; @@ -15,6 +17,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Limelight extends SubsystemBase { + ShuffleboardTab teb = Shuffleboard.getTab("teb"); PhotonCamera limelight = new PhotonCamera("limelight"); /** Creates a new Limelight. */ public Limelight() { @@ -56,6 +59,6 @@ public class Limelight extends SubsystemBase { @Override public void periodic() { CameraServer.startAutomaticCapture(); - Shuffleboard.getTab("SmartDashBoard") .add("limelight",0.1); + teb .add("limelight", 0.1); } } diff --git a/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java b/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java index e015295..94ed0f7 100644 --- a/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java +++ b/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java @@ -9,15 +9,21 @@ import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.PneumaticsModuleType; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; 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; public class BrasTelescopique extends SubsystemBase { + ShuffleboardTab teb = Shuffleboard.getTab("teb"); /** Creates a new BrasTelescopique. */ 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); } @@ -28,11 +34,19 @@ 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() { - Shuffleboard.getTab("SmartDashBoard") .add("photocell",0.1); - Shuffleboard.getTab("SmartDashBoard") .add("winch",0.1); + teb .add("``photocell``",0.1); + teb .add("winch",0.1); } + + } diff --git a/src/main/java/frc/robot/subsystems/bras/Pince.java b/src/main/java/frc/robot/subsystems/bras/Pince.java index 2aa6540..62022de 100644 --- a/src/main/java/frc/robot/subsystems/bras/Pince.java +++ b/src/main/java/frc/robot/subsystems/bras/Pince.java @@ -8,9 +8,12 @@ import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.PneumaticsModuleType; import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj.DoubleSolenoid.Value; +import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import frc.robot.Constants; -public class Pince extends SubsystemBase { + +public class Pince extends SubsystemBase{ private DoubleSolenoid pistonPince = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.pistonpinceouvre, Constants.pistonpinceferme); /** Creates a new Pince. */ public Pince() { @@ -23,6 +26,5 @@ public class Pince extends SubsystemBase { } @Override public void periodic() { - } } diff --git a/src/main/java/frc/robot/subsystems/bras/Pivot.java b/src/main/java/frc/robot/subsystems/bras/Pivot.java index 58f24d2..42f5ef3 100644 --- a/src/main/java/frc/robot/subsystems/bras/Pivot.java +++ b/src/main/java/frc/robot/subsystems/bras/Pivot.java @@ -6,6 +6,7 @@ package frc.robot.subsystems.bras; import edu.wpi.first.wpilibj.DigitalInput; 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; @@ -13,6 +14,7 @@ import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMaxLowLevel.MotorType; public class Pivot extends SubsystemBase { + ShuffleboardTab teb = Shuffleboard.getTab("teb"); // moteur private CANSparkMax pivot = new CANSparkMax(Constants.pivot,MotorType.kBrushless); private DigitalInput limitpivot = new DigitalInput(Constants.limitpivot); @@ -34,8 +36,6 @@ public class Pivot extends SubsystemBase { } @Override public void periodic() { - Shuffleboard.getTab("SmartDashBoard") .add("limitpivot",0.1); - Shuffleboard.getTab("SmartDashBoard") .add("pivot encodeur",0.1); + teb .add("encodeur", 0.1); } - } - +} \ No newline at end of file