From be2188d63e19da254db65c89050467a2e32b39e2 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 20 Feb 2023 18:53:50 -0500 Subject: [PATCH 1/6] dsf --- src/main/java/frc/robot/RobotContainer.java | 6 +++++- src/main/java/frc/robot/subsystems/BasePilotable.java | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 8b4539a..16048c8 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -16,6 +16,7 @@ import frc.robot.subsystems.Gratte; import frc.robot.subsystems.bras.BrasTelescopique; import frc.robot.subsystems.bras.Pince; import frc.robot.subsystems.bras.Pivot; +import pabeles.concurrency.ConcurrencyOps.Reset; import frc.robot.subsystems.Limelight; // command import frc.robot.commands.BrakeFerme; @@ -66,7 +67,10 @@ public RobotContainer() { private void configureBindings() { 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(gratte::baiser, gratte::Lever,gratte)); + manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable)); + } diff --git a/src/main/java/frc/robot/subsystems/BasePilotable.java b/src/main/java/frc/robot/subsystems/BasePilotable.java index 272c321..cf9e355 100644 --- a/src/main/java/frc/robot/subsystems/BasePilotable.java +++ b/src/main/java/frc/robot/subsystems/BasePilotable.java @@ -8,6 +8,7 @@ import com.kauailabs.navx.frc.AHRS; import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.PneumaticsModuleType; import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import edu.wpi.first.wpilibj.drive.DifferentialDrive; @@ -55,6 +56,10 @@ public void BrakeFerme(){ brakedroit.set(Value.kReverse); brakegauche.set(Value.kReverse); } +public void resetGyro(){ + try {gyroscope.reset();} catch(Exception e){DriverStation.reportError("bye bye",true); + } + } /** Creates a new BasePilotable. */ public BasePilotable() { droit.setInverted(true); From 01c8a1485047cf1cd32b275d91c73e437a60cdd5 Mon Sep 17 00:00:00 2001 From: EdwardFaucher Date: Mon, 20 Feb 2023 18:56:29 -0500 Subject: [PATCH 2/6] dggggc --- src/main/java/frc/robot/RobotContainer.java | 3 +- src/main/java/frc/robot/commands/Cone.java | 49 +++++++++++++++++++ .../frc/robot/subsystems/BasePilotable.java | 2 +- .../java/frc/robot/subsystems/Limelight.java | 13 +++++ vendordeps/photonlib.json | 8 +-- 5 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 src/main/java/frc/robot/commands/Cone.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 390c2a1..d36da33 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -20,6 +20,7 @@ import frc.robot.subsystems.Limelight; // command import frc.robot.commands.BrakeFerme; import frc.robot.commands.BrakeOuvre; +import frc.robot.commands.Cone; import frc.robot.commands.GratteBaisser; import frc.robot.commands.GratteMonte; import frc.robot.commands.Gyro; @@ -52,7 +53,7 @@ PivotBrasRentre pivotBrasRentre = new PivotBrasRentre(brasTelescopique, pivot); 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()); public RobotContainer() { configureBindings(); diff --git a/src/main/java/frc/robot/commands/Cone.java b/src/main/java/frc/robot/commands/Cone.java new file mode 100644 index 0000000..d780293 --- /dev/null +++ b/src/main/java/frc/robot/commands/Cone.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; + +import java.util.function.DoubleSupplier; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.BasePilotable; +import frc.robot.subsystems.Limelight; + +public class Cone extends CommandBase { + private Limelight limelight; + private BasePilotable basePilotable; + private DoubleSupplier doubleSupplier; + /** Creates a new ConeCube. */ + public Cone(Limelight limelight,BasePilotable basePilotable,DoubleSupplier doubleSupplier) { + this.basePilotable = basePilotable; + this.limelight = limelight; + this.doubleSupplier = doubleSupplier; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(limelight,basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + limelight.cone(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw()); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + limelight.pilote(); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystems/BasePilotable.java b/src/main/java/frc/robot/subsystems/BasePilotable.java index 4ed9d06..272c321 100644 --- a/src/main/java/frc/robot/subsystems/BasePilotable.java +++ b/src/main/java/frc/robot/subsystems/BasePilotable.java @@ -32,7 +32,7 @@ public class BasePilotable extends SubsystemBase { return gyroscope.getPitch(); } - public void drive(double xSpeed, double zRotation, double d){ + public void drive(double xSpeed, double zRotation){ drive.arcadeDrive(xSpeed, zRotation); } public double distance(){ diff --git a/src/main/java/frc/robot/subsystems/Limelight.java b/src/main/java/frc/robot/subsystems/Limelight.java index ac1d815..2f8bcf4 100644 --- a/src/main/java/frc/robot/subsystems/Limelight.java +++ b/src/main/java/frc/robot/subsystems/Limelight.java @@ -6,6 +6,7 @@ package frc.robot.subsystems; 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; @@ -38,6 +39,18 @@ public class Limelight extends SubsystemBase { limelight.setPipelineIndex(1); } + public double getYaw() { + var result = limelight.getLatestResult(); + if(result.hasTargets()){ + return result.getBestTarget().getYaw(); + } + return 0; + + } + public void pilote(){ + limelight.setLED(VisionLEDMode.kOff); + limelight.setDriverMode(true); + } @Override public void periodic() { // This method will be called once per scheduler run diff --git a/vendordeps/photonlib.json b/vendordeps/photonlib.json index 4f378c4..dad3105 100644 --- a/vendordeps/photonlib.json +++ b/vendordeps/photonlib.json @@ -1,7 +1,7 @@ { "fileName": "photonlib.json", "name": "photonlib", - "version": "v2023.3.0", + "version": "v2023.4.2", "uuid": "515fe07e-bfc6-11fa-b3de-0242ac130004 ", "mavenUrls": [ "https://maven.photonvision.org/repository/internal", @@ -13,7 +13,7 @@ { "groupId": "org.photonvision", "artifactId": "PhotonLib-cpp", - "version": "v2023.3.0", + "version": "v2023.4.2", "libName": "Photon", "headerClassifier": "headers", "sharedLibrary": true, @@ -30,12 +30,12 @@ { "groupId": "org.photonvision", "artifactId": "PhotonLib-java", - "version": "v2023.3.0" + "version": "v2023.4.2" }, { "groupId": "org.photonvision", "artifactId": "PhotonTargeting-java", - "version": "v2023.3.0" + "version": "v2023.4.2" } ] } \ No newline at end of file From 0d9f19b8448314d3b86956f90cc58d8d4c0f710b Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 20 Feb 2023 19:12:24 -0500 Subject: [PATCH 3/6] k --- src/main/java/frc/robot/RobotContainer.java | 1 - src/main/java/frc/robot/commands/GratteMonte.java | 1 + src/main/java/frc/robot/subsystems/Gratte.java | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 16048c8..5635da0 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -70,7 +70,6 @@ public RobotContainer() { manette1.y().whileTrue(gyro); manette1.b().toggleOnTrue(Commands.startEnd(gratte::baiser, gratte::Lever,gratte)); manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable)); - } diff --git a/src/main/java/frc/robot/commands/GratteMonte.java b/src/main/java/frc/robot/commands/GratteMonte.java index 950dcd2..522deff 100644 --- a/src/main/java/frc/robot/commands/GratteMonte.java +++ b/src/main/java/frc/robot/commands/GratteMonte.java @@ -44,6 +44,7 @@ public class GratteMonte extends CommandBase { // Returns true when the command should end. @Override public boolean isFinished() { + return false; } } diff --git a/src/main/java/frc/robot/subsystems/Gratte.java b/src/main/java/frc/robot/subsystems/Gratte.java index 3aa09ac..4cefbae 100644 --- a/src/main/java/frc/robot/subsystems/Gratte.java +++ b/src/main/java/frc/robot/subsystems/Gratte.java @@ -17,6 +17,7 @@ public class Gratte extends SubsystemBase { private DigitalInput limithg = new DigitalInput(Constants.limithg); private DigitalInput limitbd = new DigitalInput(Constants.limitbd); private DigitalInput limitbg = new DigitalInput(Constants.limitbg); + public boolean hautd(){ return limithd.get(); } From 2fd0092876a848fc93bb826ecf0d72205a487818 Mon Sep 17 00:00:00 2001 From: EdwardFaucher Date: Mon, 20 Feb 2023 19:30:11 -0500 Subject: [PATCH 4/6] utvkil --- src/main/java/frc/robot/RobotContainer.java | 6 +++ .../java/frc/robot/commands/Apriltag.java | 49 +++++++++++++++++++ src/main/java/frc/robot/commands/Cube.java | 49 +++++++++++++++++++ src/main/java/frc/robot/commands/Tape.java | 49 +++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 src/main/java/frc/robot/commands/Apriltag.java create mode 100644 src/main/java/frc/robot/commands/Cube.java create mode 100644 src/main/java/frc/robot/commands/Tape.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index d64c88d..f04083d 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,6 +4,7 @@ package frc.robot; +import edu.wpi.first.apriltag.AprilTag; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; @@ -22,10 +23,12 @@ 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; @@ -56,6 +59,9 @@ 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(); diff --git a/src/main/java/frc/robot/commands/Apriltag.java b/src/main/java/frc/robot/commands/Apriltag.java new file mode 100644 index 0000000..9ef54b3 --- /dev/null +++ b/src/main/java/frc/robot/commands/Apriltag.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; + +import java.util.function.DoubleSupplier; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.BasePilotable; +import frc.robot.subsystems.Limelight; + +public class Apriltag extends CommandBase { + private Limelight limelight; + private BasePilotable basePilotable; + private DoubleSupplier doubleSupplier; + /** Creates a new Apriltag. */ + public Apriltag(Limelight limelight,BasePilotable basePilotable,DoubleSupplier doubleSupplier) { + this.basePilotable = basePilotable; + this.limelight = limelight; + this.doubleSupplier = doubleSupplier; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(limelight,basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + limelight.apriltag(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw()); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + limelight.pilote(); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/Cube.java b/src/main/java/frc/robot/commands/Cube.java new file mode 100644 index 0000000..d54839e --- /dev/null +++ b/src/main/java/frc/robot/commands/Cube.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; + +import java.util.function.DoubleSupplier; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.BasePilotable; +import frc.robot.subsystems.Limelight; + +public class Cube extends CommandBase { + private Limelight limelight; + private BasePilotable basePilotable; + private DoubleSupplier doubleSupplier; + /** Creates a new cube. */ + public Cube(Limelight limelight,BasePilotable basePilotable,DoubleSupplier doubleSupplier) { + this.basePilotable = basePilotable; + this.limelight = limelight; + this.doubleSupplier = doubleSupplier; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(limelight,basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + limelight.cube(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw()); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + limelight.pilote(); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/Tape.java b/src/main/java/frc/robot/commands/Tape.java new file mode 100644 index 0000000..e1346f0 --- /dev/null +++ b/src/main/java/frc/robot/commands/Tape.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; + +import java.util.function.DoubleSupplier; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.BasePilotable; +import frc.robot.subsystems.Limelight; + +public class Tape extends CommandBase { + private Limelight limelight; + private BasePilotable basePilotable; + private DoubleSupplier doubleSupplier; + /** Creates a new Tape. */ + public Tape(Limelight limelight,BasePilotable basePilotable,DoubleSupplier doubleSupplier) { + this.basePilotable = basePilotable; + this.limelight = limelight; + this.doubleSupplier = doubleSupplier; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(limelight,basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + limelight.tape(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw()); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + limelight.pilote(); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} From 6556561f08b49e8185d93fc009f26826aadeace3 Mon Sep 17 00:00:00 2001 From: EdwardFaucher Date: Mon, 20 Feb 2023 19:34:31 -0500 Subject: [PATCH 5/6] mb --- src/main/java/frc/robot/RobotContainer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index ff44136..42d5b9f 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,7 +4,7 @@ package frc.robot; -import edu.wpi.first.apriltag.AprilTag; + import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; @@ -35,6 +35,7 @@ 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,7 +61,7 @@ PivoteBrasMilieux pivoteBrasMilieux = new PivoteBrasMilieux(brasTelescopique, pi 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()); +Apriltag aprilTag = new Apriltag(limelight, basePilotable, ()->-manette1.getLeftY()); Tape tape = new Tape(limelight, basePilotable, ()->-manette1.getLeftY()); public RobotContainer() { configureBindings(); From 392561c0e2419a56d9dfe5d46d9adc73d83be7e3 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 20 Feb 2023 19:55:47 -0500 Subject: [PATCH 6/6] nbm --- src/main/java/frc/robot/RobotContainer.java | 2 +- src/main/java/frc/robot/commands/GratteMonte.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 3110ddd..9fc957a 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -69,7 +69,7 @@ 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(gratte::baiser, gratte::Lever,gratte)); + manette1.b().toggleOnTrue(Commands.startEnd()); manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable)); } diff --git a/src/main/java/frc/robot/commands/GratteMonte.java b/src/main/java/frc/robot/commands/GratteMonte.java index 522deff..b460277 100644 --- a/src/main/java/frc/robot/commands/GratteMonte.java +++ b/src/main/java/frc/robot/commands/GratteMonte.java @@ -4,6 +4,8 @@ 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; @@ -24,7 +26,7 @@ public class GratteMonte extends CommandBase { @Override public void execute() { if(gratte.hautd()){ - gratte.Lever(0); + gratte.Lever(0.5); } else{ gratte.Lever(0.5); @@ -43,8 +45,7 @@ public class GratteMonte extends CommandBase { // Returns true when the command should end. @Override - public boolean isFinished() { - + public boolean isFinished(){ return false; - } } + } \ No newline at end of file