From 03bf04f40e379aed4e632337fd4990395ca40f52 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Mon, 25 Nov 2024 18:32:18 -0500 Subject: [PATCH 1/4] dashboard + limitswitchs tourel --- .../frc/robot/Commands/FollowAprilTag.java | 11 +++-- src/main/java/frc/robot/Commands/Lancer.java | 3 -- src/main/java/frc/robot/Commands/Tourel.java | 42 +++++++++++++++++++ src/main/java/frc/robot/RobotContainer.java | 8 ++-- .../frc/robot/Subsystems/Accumulateur.java | 4 +- .../java/frc/robot/Subsystems/Lanceur.java | 26 ++++++++---- .../frc/robot/Subsystems/Limelight3G.java | 2 + 7 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 src/main/java/frc/robot/Commands/Tourel.java diff --git a/src/main/java/frc/robot/Commands/FollowAprilTag.java b/src/main/java/frc/robot/Commands/FollowAprilTag.java index 22a27e8..47ee2bc 100644 --- a/src/main/java/frc/robot/Commands/FollowAprilTag.java +++ b/src/main/java/frc/robot/Commands/FollowAprilTag.java @@ -27,13 +27,16 @@ public class FollowAprilTag extends Command { @Override public void execute() { - - if (enlignement.getv()==1) + if (lanceur.limitswitch1()){ + + } + else if(lanceur.limitswitch2()){ + + } + else if (enlignement.getv()==1) { lanceur.tourelRotation(0,0, enlignement.getx()/30); } - if (lanceur.limitswitch1() || lanceur.limitswitch2()){ - lanceur.lance(0);} else { lanceur.tourelRotation(0, 0, 0); diff --git a/src/main/java/frc/robot/Commands/Lancer.java b/src/main/java/frc/robot/Commands/Lancer.java index f0aee4f..bd42d4a 100644 --- a/src/main/java/frc/robot/Commands/Lancer.java +++ b/src/main/java/frc/robot/Commands/Lancer.java @@ -29,9 +29,6 @@ public class Lancer extends Command { lanceur.lance(); accumulateur.Petitlanceur(0.7); accumulateur.desaccumule(0.2); - - - } // Called once the command ends or is interrupted. @Override diff --git a/src/main/java/frc/robot/Commands/Tourel.java b/src/main/java/frc/robot/Commands/Tourel.java new file mode 100644 index 0000000..738ac23 --- /dev/null +++ b/src/main/java/frc/robot/Commands/Tourel.java @@ -0,0 +1,42 @@ +// 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; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.Subsystems.Lanceur; + +public class Tourel extends Command { + private Lanceur lanceur; + /** Creates a new Tourel. */ + public Tourel(Lanceur lanceur) { + this.lanceur = lanceur; + // 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(lanceur.limitswitch1()){ + lanceur.touchagedelimitswitch1(0); + } + else if(lanceur.limitswitch2()){ + lanceur.touchagedelimitswitch2(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/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 20a4557..39f3b18 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -28,11 +28,11 @@ public class RobotContainer { CommandXboxController manette = new CommandXboxController(0); public RobotContainer() { dashboard.addCamera("limelight3G", "limelight3G","limelight.local:5800") - .withSize(4,3) - .withPosition(0,0); + .withSize(3,3) + .withPosition(5,0); dashboard.addCamera("limelight3", "limelight3","limelight.local:5800") - .withSize(4,3) - .withPosition(4,0); + .withSize(3,3) + .withPosition(2,0); configureBindings(); drive.setDefaultCommand(new RunCommand(()->{ drive.drive(-MathUtil.applyDeadband(manette.getRightX(),0.2), MathUtil.applyDeadband(-manette.getRightY(),0.2), MathUtil.applyDeadband(-manette.getRightX(), 0.2)); diff --git a/src/main/java/frc/robot/Subsystems/Accumulateur.java b/src/main/java/frc/robot/Subsystems/Accumulateur.java index a6fc01c..9606b3a 100644 --- a/src/main/java/frc/robot/Subsystems/Accumulateur.java +++ b/src/main/java/frc/robot/Subsystems/Accumulateur.java @@ -13,14 +13,14 @@ public class Accumulateur extends SubsystemBase { /** Creates a new Accumulateur. */ public Accumulateur() {dashboard.addBoolean("photocell", this::photocell).withSize(1, 1).withPosition(0, 1); - dashboard.addBoolean("photocell2", this::photocell).withSize(1, 1).withPosition(0, 1); + dashboard.addBoolean("photocell2", this::photocell).withSize(1, 1).withPosition(1, 1); } ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); private GenericEntry vitesse = dashboard.add("vitesseacc", 0.1) .withSize(1, 1) - .withPosition(0, 4) + .withPosition(0, 0) .getEntry(); final WPI_TalonSRX strap = new WPI_TalonSRX(0); diff --git a/src/main/java/frc/robot/Subsystems/Lanceur.java b/src/main/java/frc/robot/Subsystems/Lanceur.java index cc97f61..c80ae5d 100644 --- a/src/main/java/frc/robot/Subsystems/Lanceur.java +++ b/src/main/java/frc/robot/Subsystems/Lanceur.java @@ -21,20 +21,25 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Lanceur extends SubsystemBase { /** Creates a new Lanceur. */ - public Lanceur() {dashboard.add("rottourel", 0.2) - .withSize(0,0) - .withPosition(1, 3);} + public Lanceur() { + dashboard.addBoolean("limitswitch1", this::limitswitch1) + .withSize(0,0).withPosition(1,2); + dashboard.addBoolean("limitswitch2", this::limitswitch2) + .withSize(0,0).withPosition(0,3); + dashboard.addDouble("rottourel", this::distancetourel) + .withSize(0,0).withPosition(1, 0); +} ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard"); final WPI_TalonSRX lanceur1 = new WPI_TalonSRX(0); final WPI_TalonSRX lanceur2 = new WPI_TalonSRX(1); - final CANSparkMax tourelle = new CANSparkMax(2, MotorType.kBrushed); + final CANSparkMax tourelle = new CANSparkMax(2, MotorType.kBrushless); final DigitalInput limitswitch1 = new DigitalInput(0); final DigitalInput limitswitch2 = new DigitalInput(1); private GenericEntry vitesse = dashboard.add("vitesselanceur", 0.2) .withSize(0,0) - .withPosition(0, 3) + .withPosition(0, 2) .getEntry(); public void encodeur(double distance){ @@ -42,7 +47,12 @@ public class Lanceur extends SubsystemBase { lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative); lanceur1.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1); } - + public void touchagedelimitswitch1(double distance){ + tourelle.getEncoder().setPosition(distance); + } + public void touchagedelimitswitch2(double distance){ + tourelle.getEncoder().setPosition(distance); + } public void masterslave(){ lanceur2.follow(lanceur1); lanceur2.setInverted(true); @@ -58,10 +68,10 @@ public class Lanceur extends SubsystemBase { } public double vitessetourel(){ - return(tourelle.getEncoder().getVelocity()); + return (tourelle.getEncoder().getVelocity()); } public double distancetourel(){ - return(tourelle.getEncoder().getPosition()); + return (tourelle.getEncoder().getPosition()); } public void PIDlanceur(double p, double i, double d) { lanceur1.config_kP(0, p); diff --git a/src/main/java/frc/robot/Subsystems/Limelight3G.java b/src/main/java/frc/robot/Subsystems/Limelight3G.java index da22dec..2ab83b0 100644 --- a/src/main/java/frc/robot/Subsystems/Limelight3G.java +++ b/src/main/java/frc/robot/Subsystems/Limelight3G.java @@ -21,8 +21,10 @@ public class Limelight3G extends SubsystemBase { NetworkTableEntry tv = table.getEntry("tv"); NetworkTableEntry camMode = table.getEntry("camMode"); NetworkTableEntry tid = table.getEntry("tid"); + /** Creates a new Limelight. */ public Limelight3G() { + dashboard.addDouble("tv", this::getv).withSize(0, 0).withPosition(1,3); for (int port = 5800; port <= 5807; port++) { PortForwarder.add(port, "limelight.local", port); }} From fcc3a090709e5118910b179068814613c6bc05b6 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Mon, 25 Nov 2024 18:47:46 -0500 Subject: [PATCH 2/4] --- src/main/java/frc/robot/RobotContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 9126cb5..8efe797 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -59,4 +59,4 @@ public class RobotContainer { public Command getAutonomousCommand() { return autoChooser.getSelected(); } -} +} \ No newline at end of file From 0f2363826e9eadb0a35fc1a2eb3c35cc0d7006b0 Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Mon, 25 Nov 2024 19:11:22 -0500 Subject: [PATCH 3/4] paufinage dashboard --- src/main/java/frc/robot/RobotContainer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 8efe797..c118040 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -35,10 +35,10 @@ public class RobotContainer { NamedCommands.registerCommand("lancer", new Lancer(lanceur, accumulateur)); autoChooser = AutoBuilder.buildAutoChooser(); dashboard.addCamera("limelight3G", "limelight3G","limelight.local:5800") - .withSize(3,3) + .withSize(3,4) .withPosition(5,0); dashboard.addCamera("limelight3", "limelight3","limelight.local:5800") - .withSize(3,3) + .withSize(3,4) .withPosition(2,0); configureBindings(); drive.setDefaultCommand(new RunCommand(()->{ @@ -46,7 +46,7 @@ public class RobotContainer { },drive)); dashboard.add("autochooser",autoChooser) .withSize(1,1) - .withPosition(6,0); + .withPosition(8,0); } private void configureBindings() { From d8c572e47d080d226b3b70d32be4514a07dfd304 Mon Sep 17 00:00:00 2001 From: Antoine <2443335@carrefour.cegepvicto.ca> Date: Mon, 25 Nov 2024 19:12:17 -0500 Subject: [PATCH 4/4] l --- src/main/java/frc/robot/RobotContainer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 8efe797..c0fd440 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -12,7 +12,6 @@ import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import frc.robot.Commands.Desaccumuler;