diff --git a/simgui-ds.json b/simgui-ds.json index 1ba71ce..4a63cc1 100644 --- a/simgui-ds.json +++ b/simgui-ds.json @@ -1,9 +1,4 @@ { - "Joysticks": { - "window": { - "visible": false - } - }, "System Joysticks": { "window": { "enabled": false diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index a1f1808..32d2657 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -24,30 +24,27 @@ import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import frc.robot.TunerConstants.TunerConstants; -import frc.robot.commands.Algue1Test; -import frc.robot.commands.Algue2Test; -import frc.robot.commands.AlgueExpire; -import frc.robot.commands.Algue_inspire; import frc.robot.commands.AprilTag3; import frc.robot.commands.AprilTag3G; -import frc.robot.commands.CorailAspir; -import frc.robot.commands.CorailTest; -import frc.robot.commands.CoralAlgueInspire; -import frc.robot.commands.CoralExpire; -import frc.robot.commands.Depart; -import frc.robot.commands.ElevateurManuel; import frc.robot.commands.Forme3; -import frc.robot.commands.L2; -import frc.robot.commands.L3; -import frc.robot.commands.L4; -import frc.robot.commands.PinceManuel; -import frc.robot.commands.PinceManuel2; import frc.robot.commands.RainBow; import frc.robot.commands.StationPince; import frc.robot.commands.reset; +import frc.robot.commands.Elevateur.Depart; +import frc.robot.commands.Elevateur.ElevateurManuel; +import frc.robot.commands.Elevateur.L2; +import frc.robot.commands.Elevateur.L3; +import frc.robot.commands.Elevateur.L4; +import frc.robot.commands.Pince.AlgueExpire; +import frc.robot.commands.Pince.Algue_inspire; +import frc.robot.commands.Pince.CorailAspir; +import frc.robot.commands.Pince.CoralAlgueInspire; +import frc.robot.commands.Pince.CoralExpire; +import frc.robot.commands.Pince.PinceManuel; import frc.robot.subsystems.Bougie; import frc.robot.subsystems.CommandSwerveDrivetrain; import frc.robot.subsystems.Elevateur; +import frc.robot.subsystems.Grimpeur; import frc.robot.subsystems.Limelight3; import frc.robot.subsystems.Limelight3G; import frc.robot.subsystems.Pince; @@ -76,14 +73,12 @@ public class RobotContainer { Pince pince = new Pince(); ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); PinceManuel pinceManuel = new PinceManuel(pince,manette2::getRightY); - PinceManuel2 pinceManuel2 = new PinceManuel2(pince); Bougie bougie = new Bougie(); Limelight3G limelight3g = new Limelight3G(); Limelight3 limelight3 = new Limelight3(); Pose2d pose = new Pose2d(); + Grimpeur Grimpeur = new Grimpeur(); - - public RobotContainer() { autoChooser = AutoBuilder.buildAutoChooser("New Auto"); SmartDashboard.putData("Auto Mode", autoChooser); @@ -118,31 +113,35 @@ public class RobotContainer { // manette1 - // reset the field-centric heading on left bumper press + + // reset the field-centric heading on start press manette1.start().onTrue(drivetrain.runOnce(() -> drivetrain.seedFieldCentric())); + + //elevateur manette1.a().whileTrue(new Depart(elevateur, pince)); manette1.b().whileTrue(new L2(elevateur,pince)); manette1.x().whileTrue(new L3(elevateur, pince)); manette1.y().whileTrue(new L4(elevateur, pince)); + + //pince manette1.rightTrigger().whileTrue(new CoralAlgueInspire(pince, bougie)); manette1.rightBumper().whileTrue(new StationPince(pince, elevateur)); manette1.leftTrigger().whileTrue(new CoralExpire(pince, bougie)); + //manette2 - manette2.leftTrigger().whileTrue(new AlgueExpire(pince, bougie)); + + //pince manette2.a().whileTrue(new CorailAspir(pince)); manette2.start().whileTrue(new reset(elevateur,pince)); manette2.b().whileTrue(new Algue_inspire(pince)); + manette2.start().whileTrue(new reset(elevateur,pince)); + manette2.leftTrigger().whileTrue(new AlgueExpire(pince, bougie)); + + //limelight manette2.leftBumper().whileTrue(new AprilTag3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY)); manette2.rightBumper().whileTrue(new Forme3(limelight3,drivetrain,manette1::getLeftX,manette1::getLeftY)); } - - - - // Note that X is defined as forward according to WPILib convention, - // and Y is defined as to the left according to WPILib convention. - - // manette2.leftTrigger().whileTrue(new AprilTag3G(limelight3g,drivetrain,manette1::getLeftX,manette1::getLeftY)); public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/commands/Depart.java b/src/main/java/frc/robot/commands/Elevateur/Depart.java similarity index 88% rename from src/main/java/frc/robot/commands/Depart.java rename to src/main/java/frc/robot/commands/Elevateur/Depart.java index f5322dd..56f684b 100644 --- a/src/main/java/frc/robot/commands/Depart.java +++ b/src/main/java/frc/robot/commands/Elevateur/Depart.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Elevateur; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; @@ -11,12 +11,10 @@ import frc.robot.subsystems.Pince; /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ public class Depart extends Command { private Elevateur elevateur; - private Pince pince; /** Creates a new L2. */ public Depart(Elevateur elevateur, Pince pince) { - this.pince = pince; this.elevateur = elevateur; - addRequirements(elevateur,pince); + addRequirements(elevateur); // Use addRequirements() here to declare subsystem dependencies. } @@ -41,12 +39,11 @@ public class Depart extends Command { @Override public void end(boolean interrupted) { elevateur.vitesse(0); - pince.pivote(0); } // Returns true when the command should end. @Override public boolean isFinished() { - return elevateur.limit2()==true; + return elevateur.limit2() == true; } } diff --git a/src/main/java/frc/robot/commands/ElevateurManuel.java b/src/main/java/frc/robot/commands/Elevateur/ElevateurManuel.java similarity index 93% rename from src/main/java/frc/robot/commands/ElevateurManuel.java rename to src/main/java/frc/robot/commands/Elevateur/ElevateurManuel.java index eca4068..682fdc6 100644 --- a/src/main/java/frc/robot/commands/ElevateurManuel.java +++ b/src/main/java/frc/robot/commands/Elevateur/ElevateurManuel.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Elevateur; import java.util.function.DoubleSupplier; @@ -28,9 +28,7 @@ public class ElevateurManuel extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.limit2()==true){ - elevateur.vitesse(0); - } + if (elevateur.limit2()) elevateur.vitesse(doubleSupplier.getAsDouble()/3.5); } diff --git a/src/main/java/frc/robot/commands/L2.java b/src/main/java/frc/robot/commands/Elevateur/L2.java similarity index 61% rename from src/main/java/frc/robot/commands/L2.java rename to src/main/java/frc/robot/commands/Elevateur/L2.java index 3a201a8..ac4c59f 100644 --- a/src/main/java/frc/robot/commands/L2.java +++ b/src/main/java/frc/robot/commands/Elevateur/L2.java @@ -2,8 +2,10 @@ // 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; - +package frc.robot.commands.Elevateur; +import edu.wpi.first.networktables.DoubleSubscriber; +import edu.wpi.first.networktables.NetworkTable; +import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; @@ -13,6 +15,13 @@ import frc.robot.subsystems.Pince; public class L2 extends Command { private Elevateur elevateur; private Pince pince; + + NetworkTableInstance networktable = NetworkTableInstance.getDefault(); + NetworkTable tabelevateur = networktable.getTable("tabelevateur"); + private DoubleSubscriber encodeur1 = tabelevateur.getDoubleTopic("encodeurelevateurbasL2").subscribe(-1); + private DoubleSubscriber encodeur2 = tabelevateur.getDoubleTopic("encodeurelevateurhautL2").subscribe(-0.9); + private DoubleSubscriber encodeur3 = tabelevateur.getDoubleTopic("encodeurpincebasL2").subscribe(-1); + private DoubleSubscriber encodeur4 = tabelevateur.getDoubleTopic("encodeurpinceautL2").subscribe(-0.9); /** Creates a new L2. */ public L2(Elevateur elevateur,Pince pince) { this.elevateur = elevateur; @@ -28,10 +37,14 @@ public class L2 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position()<=-1 && elevateur.position()>=-0.9){ + double encodeurbase = encodeur1.get(); + double encodeurhaute = encodeur2.get(); + double encodeurbasp = encodeur3.get(); + double encodeurhautp = encodeur4.get(); + if(elevateur.position()<=encodeurbase && elevateur.position()>=-encodeurhaute){ elevateur.vitesse(0); } - else if(elevateur.position()>=-1){ + else if(elevateur.position()>=encodeurbase){ elevateur.vitesse(-0.2); } else{ diff --git a/src/main/java/frc/robot/commands/L3.java b/src/main/java/frc/robot/commands/Elevateur/L3.java similarity index 61% rename from src/main/java/frc/robot/commands/L3.java rename to src/main/java/frc/robot/commands/Elevateur/L3.java index 7308950..b653c77 100644 --- a/src/main/java/frc/robot/commands/L3.java +++ b/src/main/java/frc/robot/commands/Elevateur/L3.java @@ -2,8 +2,11 @@ // 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; +package frc.robot.commands.Elevateur; +import edu.wpi.first.networktables.DoubleSubscriber; +import edu.wpi.first.networktables.NetworkTable; +import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; @@ -13,6 +16,12 @@ import frc.robot.subsystems.Pince; public class L3 extends Command { private Elevateur elevateur; private Pince pince; + NetworkTableInstance networktable = NetworkTableInstance.getDefault(); + NetworkTable tabelevateur = networktable.getTable("tabelevateur"); + private DoubleSubscriber encodeur1 = tabelevateur.getDoubleTopic("encodeurhautL3").subscribe(-2.9); + private DoubleSubscriber encodeur2 = tabelevateur.getDoubleTopic("encodeurbasL3").subscribe(-3); + private DoubleSubscriber encodeur3 = tabelevateur.getDoubleTopic("encodeurpincebasL3").subscribe(-1); + private DoubleSubscriber encodeur4 = tabelevateur.getDoubleTopic("encodeurpincehautL3").subscribe(-0.9); /** Creates a new L2. */ public L3(Elevateur elevateur,Pince pince) { this.elevateur = elevateur; @@ -28,10 +37,14 @@ public class L3 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position()<=-2.9 && elevateur.position()>=-3){ + double encodeurHaute = encodeur1.get(); + double encodeurBase = encodeur2.get(); + double encodeurbase = encodeur3.get(); + double encodeurhaute = encodeur4.get(); + if(elevateur.position()<=-encodeurHaute && elevateur.position()>=encodeurBase){ elevateur.vitesse(0); } - else if(elevateur.position()>=-2.9){ + else if(elevateur.position()>=-encodeurHaute){ elevateur.vitesse(-0.2); } else{ diff --git a/src/main/java/frc/robot/commands/L4.java b/src/main/java/frc/robot/commands/Elevateur/L4.java similarity index 58% rename from src/main/java/frc/robot/commands/L4.java rename to src/main/java/frc/robot/commands/Elevateur/L4.java index 6612995..f76d59b 100644 --- a/src/main/java/frc/robot/commands/L4.java +++ b/src/main/java/frc/robot/commands/Elevateur/L4.java @@ -2,8 +2,12 @@ // 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; +package frc.robot.commands.Elevateur; +import edu.wpi.first.networktables.DoubleSubscriber; +import edu.wpi.first.networktables.DoubleTopic; +import edu.wpi.first.networktables.NetworkTable; +import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; @@ -13,10 +17,18 @@ import frc.robot.subsystems.Pince; public class L4 extends Command { private Elevateur elevateur; private Pince pince; + NetworkTableInstance networktable = NetworkTableInstance.getDefault(); + NetworkTable tabelevateur = networktable.getTable("tabelevateur"); + private DoubleTopic encodeur1topic = tabelevateur.getDoubleTopic("encodeurbasL4"); + DoubleSubscriber encodeur1 = encodeur1topic.subscribe(-6.4); + private DoubleSubscriber encodeur2 = tabelevateur.getDoubleTopic("encodeurhautL4").subscribe(-6.5); + private DoubleSubscriber encodeur3 = tabelevateur.getDoubleTopic("encodeurpincebasL4").subscribe(-1); + private DoubleSubscriber encodeur4 = tabelevateur.getDoubleTopic("encodeurpincehautL4").subscribe(-0.9); /** Creates a new L2. */ public L4(Elevateur elevateur,Pince pince) { this.elevateur = elevateur; this.pince = pince; + encodeur1topic.setPersistent(true); addRequirements(elevateur,pince); // Use addRequirements() here to declare subsystem dependencies. } @@ -28,10 +40,14 @@ public class L4 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position()<=-6.5 && elevateur.position()>=-6.4){ + double encodeurBase = encodeur1.get(); + double encodeurhaute = encodeur2.get(); + double encodeurbasp = encodeur3.get(); + double encodeurhautp = encodeur4.get(); + if(elevateur.position()<=encodeurhaute && elevateur.position()>=encodeurBase){ elevateur.vitesse(0); } - else if(elevateur.position()>=-6.5){ + else if(elevateur.position()>=encodeurhaute){ elevateur.vitesse(-0.2); } else{ diff --git a/src/main/java/frc/robot/commands/Algue1Test.java b/src/main/java/frc/robot/commands/Pince/Algue1Test.java similarity index 97% rename from src/main/java/frc/robot/commands/Algue1Test.java rename to src/main/java/frc/robot/commands/Pince/Algue1Test.java index f79faa6..ab5e886 100644 --- a/src/main/java/frc/robot/commands/Algue1Test.java +++ b/src/main/java/frc/robot/commands/Pince/Algue1Test.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/Algue2Test.java b/src/main/java/frc/robot/commands/Pince/Algue2Test.java similarity index 97% rename from src/main/java/frc/robot/commands/Algue2Test.java rename to src/main/java/frc/robot/commands/Pince/Algue2Test.java index 5f0e758..386e4f1 100644 --- a/src/main/java/frc/robot/commands/Algue2Test.java +++ b/src/main/java/frc/robot/commands/Pince/Algue2Test.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/AlgueExpire.java b/src/main/java/frc/robot/commands/Pince/AlgueExpire.java similarity index 97% rename from src/main/java/frc/robot/commands/AlgueExpire.java rename to src/main/java/frc/robot/commands/Pince/AlgueExpire.java index 49606d7..ebaac37 100644 --- a/src/main/java/frc/robot/commands/AlgueExpire.java +++ b/src/main/java/frc/robot/commands/Pince/AlgueExpire.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Bougie; diff --git a/src/main/java/frc/robot/commands/Algue_inspire.java b/src/main/java/frc/robot/commands/Pince/Algue_inspire.java similarity index 97% rename from src/main/java/frc/robot/commands/Algue_inspire.java rename to src/main/java/frc/robot/commands/Pince/Algue_inspire.java index f3e3bdf..d184827 100644 --- a/src/main/java/frc/robot/commands/Algue_inspire.java +++ b/src/main/java/frc/robot/commands/Pince/Algue_inspire.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/CorailAspir.java b/src/main/java/frc/robot/commands/Pince/CorailAspir.java similarity index 97% rename from src/main/java/frc/robot/commands/CorailAspir.java rename to src/main/java/frc/robot/commands/Pince/CorailAspir.java index 8199c75..ae3753b 100644 --- a/src/main/java/frc/robot/commands/CorailAspir.java +++ b/src/main/java/frc/robot/commands/Pince/CorailAspir.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/CorailTest.java b/src/main/java/frc/robot/commands/Pince/CorailTest.java similarity index 97% rename from src/main/java/frc/robot/commands/CorailTest.java rename to src/main/java/frc/robot/commands/Pince/CorailTest.java index 5e947d2..ba33689 100644 --- a/src/main/java/frc/robot/commands/CorailTest.java +++ b/src/main/java/frc/robot/commands/Pince/CorailTest.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/CoralAlgueInspire.java b/src/main/java/frc/robot/commands/Pince/CoralAlgueInspire.java similarity index 97% rename from src/main/java/frc/robot/commands/CoralAlgueInspire.java rename to src/main/java/frc/robot/commands/Pince/CoralAlgueInspire.java index b64185b..29a21a3 100644 --- a/src/main/java/frc/robot/commands/CoralAlgueInspire.java +++ b/src/main/java/frc/robot/commands/Pince/CoralAlgueInspire.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Bougie; diff --git a/src/main/java/frc/robot/commands/CoralExpire.java b/src/main/java/frc/robot/commands/Pince/CoralExpire.java similarity index 97% rename from src/main/java/frc/robot/commands/CoralExpire.java rename to src/main/java/frc/robot/commands/Pince/CoralExpire.java index 0879f50..13293c6 100644 --- a/src/main/java/frc/robot/commands/CoralExpire.java +++ b/src/main/java/frc/robot/commands/Pince/CoralExpire.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/DepartPince.java b/src/main/java/frc/robot/commands/Pince/DepartPince.java similarity index 97% rename from src/main/java/frc/robot/commands/DepartPince.java rename to src/main/java/frc/robot/commands/Pince/DepartPince.java index 12a69dd..bdfc343 100644 --- a/src/main/java/frc/robot/commands/DepartPince.java +++ b/src/main/java/frc/robot/commands/Pince/DepartPince.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/PinceManuel.java b/src/main/java/frc/robot/commands/Pince/PinceManuel.java similarity index 97% rename from src/main/java/frc/robot/commands/PinceManuel.java rename to src/main/java/frc/robot/commands/Pince/PinceManuel.java index 5b8b2c0..1382d39 100644 --- a/src/main/java/frc/robot/commands/PinceManuel.java +++ b/src/main/java/frc/robot/commands/Pince/PinceManuel.java @@ -2,7 +2,7 @@ // 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; +package frc.robot.commands.Pince; import java.util.function.DoubleSupplier; import edu.wpi.first.wpilibj2.command.Command; diff --git a/src/main/java/frc/robot/commands/RainBow.java b/src/main/java/frc/robot/commands/RainBow.java index 2c4e5e2..3929ea2 100644 --- a/src/main/java/frc/robot/commands/RainBow.java +++ b/src/main/java/frc/robot/commands/RainBow.java @@ -9,8 +9,8 @@ import frc.robot.subsystems.Bougie; /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ public class RainBow extends Command { - Bougie bougie; /** Creates a new RainBow. */ + private Bougie bougie; public RainBow(Bougie bougie) { this.bougie = bougie; addRequirements(bougie); diff --git a/src/main/java/frc/robot/commands/StationPince.java b/src/main/java/frc/robot/commands/StationPince.java index 59527d5..bdb69a1 100644 --- a/src/main/java/frc/robot/commands/StationPince.java +++ b/src/main/java/frc/robot/commands/StationPince.java @@ -4,6 +4,9 @@ package frc.robot.commands; +import edu.wpi.first.networktables.DoubleSubscriber; +import edu.wpi.first.networktables.NetworkTable; +import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; @@ -13,6 +16,12 @@ public class StationPince extends Command { private Pince pince; private Elevateur elevateur; + NetworkTableInstance networktable = NetworkTableInstance.getDefault(); + NetworkTable tabelevateur = networktable.getTable("tabelevateur"); + private DoubleSubscriber encodeur1 = tabelevateur.getDoubleTopic("encodeur bas Station").subscribe(-0.5); + private DoubleSubscriber encodeur2 = tabelevateur.getDoubleTopic("encodeur haut Station").subscribe(-0.4); + private DoubleSubscriber encodeur3 = tabelevateur.getDoubleTopic("encodeur pince bas Station").subscribe(-1); + private DoubleSubscriber encodeur4 = tabelevateur.getDoubleTopic("encodeur pince haut Station").subscribe(-0.9); /** Creates a new L2Pince. */ public StationPince(Pince pince,Elevateur elevateur) { this.elevateur = elevateur; @@ -28,11 +37,15 @@ public class StationPince extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { + double encodeurBase = encodeur1.get(); + double encodeurhaute = encodeur2.get(); + double encodeurbasp = encodeur3.get(); + double encodeurhautp = encodeur4.get(); pince.aspirecoral(0.5); - if(pince.encodeurpivot()>=900 && pince.encodeurpivot()<=910){ + if(pince.encodeurpivot()<=encodeurBase && pince.encodeurpivot()>=encodeurhaute){ pince.pivote(0); } - else if(pince.encodeurpivot()>=910){ + else if(pince.encodeurpivot()>=encodeurBase){ pince.pivote(0.2); } else{ diff --git a/src/main/java/frc/robot/commands/grimpeur/GrimperHaut.java b/src/main/java/frc/robot/commands/grimpeur/GrimperHaut.java new file mode 100644 index 0000000..ce3f65a --- /dev/null +++ b/src/main/java/frc/robot/commands/grimpeur/GrimperHaut.java @@ -0,0 +1,56 @@ +// 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.grimpeur; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; +import frc.robot.subsystems.Grimpeur; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class GrimperHaut extends Command { + private Grimpeur grimpeur; + private Bougie bougie; + /** Creates a new Grimper. */ + public GrimperHaut(Grimpeur grimpeur, Bougie bougie) { + this.grimpeur = grimpeur; + this.bougie = bougie; + addRequirements(grimpeur,bougie); + // Use addRequirements() here to declare subsystem dependencies. + } + + // 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(grimpeur.stop()==true){ + grimpeur.grimpe(0); + grimpeur.reset(); + bougie.RainBow(); + } + else{ + grimpeur.grimpe(0.5); + bougie.RainBowStop(); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + grimpeur.grimpe(0); + if(grimpeur.stop()){ + bougie.RainBow(); + } + + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return grimpeur.stop()==true; + } +} diff --git a/src/main/java/frc/robot/commands/grimpeur/GrimpeurBas.java b/src/main/java/frc/robot/commands/grimpeur/GrimpeurBas.java new file mode 100644 index 0000000..4dfc3b0 --- /dev/null +++ b/src/main/java/frc/robot/commands/grimpeur/GrimpeurBas.java @@ -0,0 +1,57 @@ +// 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.grimpeur; + +import edu.wpi.first.networktables.DoubleSubscriber; +import edu.wpi.first.networktables.NetworkTable; +import edu.wpi.first.networktables.NetworkTableInstance; +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Grimpeur; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class GrimpeurBas extends Command { + private Grimpeur grimpeur; + NetworkTableInstance networktable = NetworkTableInstance.getDefault(); + NetworkTable tabelevateur = networktable.getTable("tabelevateur"); + private DoubleSubscriber encodeur1 = tabelevateur.getDoubleTopic("encodeurgrimpeurbas").subscribe(-39.19); + private DoubleSubscriber encodeur2 = tabelevateur.getDoubleTopic("encodeurgrimpeurhaut ").subscribe(-38.5); + /** Creates a new GrimpeurBas. */ + public GrimpeurBas(Grimpeur grimpeur) { + this.grimpeur = grimpeur; + addRequirements(grimpeur); + // Use addRequirements() here to declare subsystem dependencies. + } + + // 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() { + double encodeurbas = encodeur1.get(); + double encodeurhaut = encodeur2.get(); + if(grimpeur.encodeur()>=encodeurhaut && grimpeur.encodeur()<=encodeurbas){ + grimpeur.grimpe(0); + } + else if(grimpeur.encodeur()>=encodeurhaut){ + grimpeur.grimpe(-0.5); + } + else{grimpeur.grimpe(0.5); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + grimpeur.grimpe(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/grimpeur/GrimpeurManuel.java b/src/main/java/frc/robot/commands/grimpeur/GrimpeurManuel.java new file mode 100644 index 0000000..60fdace --- /dev/null +++ b/src/main/java/frc/robot/commands/grimpeur/GrimpeurManuel.java @@ -0,0 +1,51 @@ +// 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.grimpeur; + +import java.util.function.DoubleSupplier; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Grimpeur; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class GrimpeurManuel extends Command { + private Grimpeur grimpeur; + private DoubleSupplier x; + /** Creates a new GrimpeurManuel. */ + public GrimpeurManuel(Grimpeur grimpeur,DoubleSupplier x) { + this.grimpeur = grimpeur; + this.x = x; + addRequirements(grimpeur); + // Use addRequirements() here to declare subsystem dependencies. + } + + // 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(grimpeur.stop()){ + grimpeur.grimpe(0); + } + else{ + grimpeur.grimpe(x.getAsDouble()); + } + + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + grimpeur.grimpe(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/grimpeur/ResetGrimpeur.java b/src/main/java/frc/robot/commands/grimpeur/ResetGrimpeur.java new file mode 100644 index 0000000..5bf0bea --- /dev/null +++ b/src/main/java/frc/robot/commands/grimpeur/ResetGrimpeur.java @@ -0,0 +1,39 @@ +// 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.grimpeur; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Grimpeur; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class ResetGrimpeur extends Command { + private Grimpeur grimpeur; + /** Creates a new ResetGrimpeur. */ + public ResetGrimpeur(Grimpeur grimpeur) { + this.grimpeur = grimpeur; + addRequirements(grimpeur); + // Use addRequirements() here to declare subsystem dependencies. + } + + // 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() { + grimpeur.reset(); + } + + // 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/requin/BalayeuseAlgue.java b/src/main/java/frc/robot/commands/requin/BalayeuseAlgue.java new file mode 100644 index 0000000..212583b --- /dev/null +++ b/src/main/java/frc/robot/commands/requin/BalayeuseAlgue.java @@ -0,0 +1,63 @@ +// 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.requin; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; +import frc.robot.subsystems.Requin; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class BalayeuseAlgue extends Command { + private Requin requin; + private Bougie bougie; + /** Creates a new Balayeuse. */ + public BalayeuseAlgue(Requin requin, Bougie bougie) { + this.requin = requin; + this.bougie =bougie; + addRequirements(requin,bougie); + // Use addRequirements() here to declare subsystem dependencies. + } + + // 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(requin.encodeur()>=500 && requin.encodeur()<=510) + { + requin.rotationer(0); + if(requin.amp()> 60){ + requin.balaye(0); + bougie.Vert(); + } + else + { + requin.balaye(0.5); + } + } + else if(requin.encodeur()>=510){ + requin.rotationer(0.5); + } + else{ + requin.rotationer(-0.5); + } + + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + requin.rotationer(0); + requin.balaye(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/requin/BalayeuseBas.java b/src/main/java/frc/robot/commands/requin/BalayeuseBas.java new file mode 100644 index 0000000..67d0687 --- /dev/null +++ b/src/main/java/frc/robot/commands/requin/BalayeuseBas.java @@ -0,0 +1,40 @@ +// 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.requin; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Requin; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class BalayeuseBas extends Command { + private Requin requin; + /** Creates a new Balayeuse. */ + public BalayeuseBas(Requin requin) { + this.requin = requin; + addRequirements(requin); + // Use addRequirements() here to declare subsystem dependencies. + } + + // 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() { + requin.rotationer(-0.5); + } + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + requin.rotationer(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/requin/BalayeuseCoral.java b/src/main/java/frc/robot/commands/requin/BalayeuseCoral.java new file mode 100644 index 0000000..5b12ada --- /dev/null +++ b/src/main/java/frc/robot/commands/requin/BalayeuseCoral.java @@ -0,0 +1,67 @@ +// 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.requin; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; +import frc.robot.subsystems.Requin; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class BalayeuseCoral extends Command { + private Requin requin; + private Bougie bougie; + /** Creates a new Balayeuse. */ + public BalayeuseCoral(Requin requin, Bougie bougie) { + this.requin = requin; + this.bougie = bougie; + addRequirements(requin,bougie); + // Use addRequirements() here to declare subsystem dependencies. + } + + // 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(requin.encodeur()>=100 && requin.encodeur()<=110){ + requin.rotationer(0); + if(requin.amp()>60){ + requin.balaye(0); + bougie.Vert(); + if(requin.enHaut()){ + requin.rotationer(0); + } + else{ + requin.rotationer(0.5); + } + } + else{ + requin.balaye(0.5); + } + } + else if(requin.encodeur()>=110){ + requin.rotationer(0.5); + } + else{ + requin.rotationer(-0.5); + } + + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + requin.rotationer(0); + requin.balaye(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/PinceManuel2.java b/src/main/java/frc/robot/commands/requin/BalayeuseHaut.java similarity index 68% rename from src/main/java/frc/robot/commands/PinceManuel2.java rename to src/main/java/frc/robot/commands/requin/BalayeuseHaut.java index bf8d1e4..eea2d7d 100644 --- a/src/main/java/frc/robot/commands/PinceManuel2.java +++ b/src/main/java/frc/robot/commands/requin/BalayeuseHaut.java @@ -2,22 +2,18 @@ // 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; +package frc.robot.commands.requin; + import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.subsystems.Pince; +import frc.robot.subsystems.Requin; /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ -public class PinceManuel2 extends Command { - private Pince pince; - //private DoubleSupplier doubleSupplier; - /** Creates a new PinceManuel. */ - public PinceManuel2(Pince pince - - //,DoubleSupplier doubleSupplier - ) { - this.pince = pince; - // this.doubleSupplier = doubleSupplier; - addRequirements(pince); +public class BalayeuseHaut extends Command { + private Requin requin; + /** Creates a new Balayeuse. */ + public BalayeuseHaut(Requin requin) { + this.requin = requin; + addRequirements(requin); // Use addRequirements() here to declare subsystem dependencies. } @@ -28,15 +24,19 @@ public class PinceManuel2 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - - pince.pivote(-0.2); - + if(requin.enHaut()==true){ + requin.rotationer(0); + requin.reset(); + } + else{ + requin.rotationer(-0.5); + } } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - pince.pivote(0); + requin.rotationer(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/commands/requin/ExpireAlgue.java b/src/main/java/frc/robot/commands/requin/ExpireAlgue.java new file mode 100644 index 0000000..679c6ce --- /dev/null +++ b/src/main/java/frc/robot/commands/requin/ExpireAlgue.java @@ -0,0 +1,41 @@ +// 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.requin; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Requin; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class ExpireAlgue extends Command { + private Requin requin; + /** Creates a new ExpireAlgue. */ + public ExpireAlgue(Requin requin) { + this.requin = requin; + addRequirements(requin); + // Use addRequirements() here to declare subsystem dependencies. + } + + // 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() { + requin.balaye(0.5); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + requin.balaye(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/requin/L1Requin.java b/src/main/java/frc/robot/commands/requin/L1Requin.java new file mode 100644 index 0000000..1a7d127 --- /dev/null +++ b/src/main/java/frc/robot/commands/requin/L1Requin.java @@ -0,0 +1,65 @@ +// 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.requin; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; +import frc.robot.subsystems.Requin; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class L1Requin extends Command { + private Requin requin; + private Bougie bougie; + /** Creates a new Balayeuse. */ + public L1Requin(Requin requin,Bougie bougie) { + this.requin = requin; + this.bougie = bougie; + addRequirements(requin,bougie); + // Use addRequirements() here to declare subsystem dependencies. + } + + // 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(requin.encodeur()>=800 && requin.encodeur()<=810){ + requin.rotationer(0); + if(requin.amp()>8){ + requin.balaye(-0.5); + } + else{ + requin.balaye(0); + bougie.Rouge(); + } + } + else if(requin.encodeur()>=810){ + requin.rotationer(0.5); + } + else{ + requin.rotationer(-0.5); + } + + + + + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + requin.rotationer(0); + requin.balaye(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/requin/aspire.java b/src/main/java/frc/robot/commands/requin/aspire.java new file mode 100644 index 0000000..5105d83 --- /dev/null +++ b/src/main/java/frc/robot/commands/requin/aspire.java @@ -0,0 +1,41 @@ +// 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.requin; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Requin; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class aspire extends Command { + /** Creates a new aspire. */ + private Requin requin; + public aspire(Requin requin) { + // Use addRequirements() here to declare subsystem dependencies. + this.requin = requin; + addRequirements(requin); + } + + // 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() { + requin.balaye(0.3); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + requin.balaye(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/requin/exspire.java b/src/main/java/frc/robot/commands/requin/exspire.java new file mode 100644 index 0000000..9c57fe0 --- /dev/null +++ b/src/main/java/frc/robot/commands/requin/exspire.java @@ -0,0 +1,41 @@ +// 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.requin; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Requin; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class exspire extends Command { + /** Creates a new aspire. */ + private Requin requin; + public exspire(Requin requin) { + // Use addRequirements() here to declare subsystem dependencies. + this.requin = requin; + addRequirements(requin); + } + + // 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() { + requin.balaye(-0.3); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + requin.balaye(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/requin/requin_manuel.java b/src/main/java/frc/robot/commands/requin/requin_manuel.java new file mode 100644 index 0000000..9a3fa3d --- /dev/null +++ b/src/main/java/frc/robot/commands/requin/requin_manuel.java @@ -0,0 +1,49 @@ +// 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.requin; + +import java.util.function.DoubleSupplier; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Requin; + +/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ +public class requin_manuel extends Command { + /** Creates a new requin_manuel. */ + private Requin requin; + private DoubleSupplier x; + public requin_manuel(Requin requin) { + // Use addRequirements() here to declare subsystem dependencies. + this.requin = requin; + addRequirements(requin); + } + + // 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(requin.enHaut()){ + requin.rotationer(0); + } + else{ + requin.rotationer(x.getAsDouble()); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + requin.rotationer(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystems/Bougie.java b/src/main/java/frc/robot/subsystems/Bougie.java index 02cd2a8..4c2dcb5 100644 --- a/src/main/java/frc/robot/subsystems/Bougie.java +++ b/src/main/java/frc/robot/subsystems/Bougie.java @@ -43,8 +43,12 @@ public class Bougie extends SubsystemBase { candle.setLEDs(255, 215, 0,0,48,8); candle.setLEDs(255, 215, 0,0,64,8); } - public void RainBow(){candle.animate(rainbowAnim);} - public void RainBowStop(){candle.animate(null);} + public void RainBow(){ + candle.animate(rainbowAnim); + } + public void RainBowStop(){ + candle.animate(null); + } @Override public void periodic() { // This method will be called once per scheduler run diff --git a/src/main/java/frc/robot/subsystems/Grimpeur.java b/src/main/java/frc/robot/subsystems/Grimpeur.java new file mode 100644 index 0000000..759c4b3 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Grimpeur.java @@ -0,0 +1,40 @@ +// 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.subsystems; + +import com.revrobotics.spark.SparkMax; +import com.revrobotics.spark.SparkLowLevel.MotorType; + +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; + +public class Grimpeur extends SubsystemBase { + /** Creates a new Grimpeur. */ + ShuffleboardTab teb = Shuffleboard.getTab("teb"); + public Grimpeur() { + teb.addBoolean("limit grimpeur", this::stop); + teb.addDouble("encodeur grimpeur", this::encodeur); + } + final SparkMax grimpeur = new SparkMax(21,MotorType.kBrushless); + final DigitalInput limit1 = new DigitalInput(2); + public void grimpe(double vitesse){ + grimpeur.set(vitesse); + } + public boolean stop(){ + return limit1.get(); + } + public double encodeur(){ + return grimpeur.getEncoder().getPosition(); + } + public void reset(){ + grimpeur.getEncoder().setPosition(0); + } + @Override + public void periodic() { + // This method will be called once per scheduler run + } +} diff --git a/src/main/java/frc/robot/subsystems/Requin.java b/src/main/java/frc/robot/subsystems/Requin.java new file mode 100644 index 0000000..db0e3c4 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Requin.java @@ -0,0 +1,48 @@ +// 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.subsystems; + +import com.revrobotics.spark.SparkFlex; +import com.revrobotics.spark.SparkMax; +import com.revrobotics.spark.SparkLowLevel.MotorType; +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; + +public class Requin extends SubsystemBase { + /** Creates a new Requin. */ + ShuffleboardTab teb = Shuffleboard.getTab("teb"); + public Requin() { + teb.addBoolean("limit requin", this::enHaut); + } + + final SparkFlex balaye = new SparkFlex(15, MotorType.kBrushless); + final SparkMax rotatione = new SparkMax(17, MotorType.kBrushless); + final DigitalInput limit3 = new DigitalInput(1); + + public void balaye(double vitesse){ + balaye.set(vitesse); + } + public void rotationer(double vitesse){ + rotatione.set(vitesse); + } + public boolean enHaut(){ + return limit3.get(); + } + public double encodeur(){ + return rotatione.getEncoder().getPosition(); + } + public void reset(){ + rotatione.getEncoder().setPosition(0); + } + public double amp(){ + return balaye.getOutputCurrent(); + } + @Override + public void periodic() { + // This method will be called once per scheduler run + } +}