From b16d11b70a484a897f0b332ced2f6de152b8358b Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 27 Jan 2025 19:11:22 -0500 Subject: [PATCH 01/43] elevateur --- .../java/frc/robot/subsystems/Elevateur.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/frc/robot/subsystems/Elevateur.java diff --git a/src/main/java/frc/robot/subsystems/Elevateur.java b/src/main/java/frc/robot/subsystems/Elevateur.java new file mode 100644 index 0000000..abdf9c4 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Elevateur.java @@ -0,0 +1,27 @@ +// 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 edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj.motorcontrol.Spark; +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import com.revrobotics.spark.SparkMax; +import com.revrobotics.spark.SparkLowLevel.MotorType; +public class Elevateur extends SubsystemBase { + /** Creates a new Elevateur. */ + public Elevateur() {} + final SparkMax monte = new SparkMax(0, MotorType.kBrushless); + final DigitalInput limit2 = new DigitalInput(0); + public double positionL2(double position){ + return monte.getEncoder().getPosition(); + } + public void vitesseL2(double vitesse){ + monte.set(vitesse); + } + @Override + public void periodic() { + // This method will be called once per scheduler run + } +} From 7521c0d94ea8e476df941a0d8679ff52f3d4404b Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 27 Jan 2025 19:15:16 -0500 Subject: [PATCH 02/43] elevateur --- .../java/frc/robot/subsystems/Elevateur.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/Elevateur.java b/src/main/java/frc/robot/subsystems/Elevateur.java index abdf9c4..33d51b1 100644 --- a/src/main/java/frc/robot/subsystems/Elevateur.java +++ b/src/main/java/frc/robot/subsystems/Elevateur.java @@ -5,7 +5,6 @@ package frc.robot.subsystems; import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.motorcontrol.Spark; import edu.wpi.first.wpilibj2.command.SubsystemBase; import com.revrobotics.spark.SparkMax; import com.revrobotics.spark.SparkLowLevel.MotorType; @@ -20,6 +19,28 @@ public class Elevateur extends SubsystemBase { public void vitesseL2(double vitesse){ monte.set(vitesse); } + public double positionL3(double position){ + return monte.getEncoder().getPosition(); + } + public void vitesseL3(double vitesse){ + monte.set(vitesse); + } + public double positionL4(double position){ + return monte.getEncoder().getPosition(); + } + public void vitesseL4(double vitesse){ + monte.set(vitesse); + } + public double position1(double position){ + return monte.getEncoder().getPosition(); + } + public void vitesse1(double vitesse){ + monte.set(vitesse); + } + + public void manuel(double vitesse){ + monte.set(vitesse); + } @Override public void periodic() { // This method will be called once per scheduler run From 0577ce368a4ae2f8c77c7cb5e4daa92c58935f3f Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 27 Jan 2025 19:26:11 -0500 Subject: [PATCH 03/43] positon --- src/main/java/frc/robot/command/L2.java | 46 +++++++++++++++++++ src/main/java/frc/robot/command/L3.java | 46 +++++++++++++++++++ src/main/java/frc/robot/command/L4.java | 46 +++++++++++++++++++ .../java/frc/robot/subsystems/Elevateur.java | 28 ++--------- 4 files changed, 143 insertions(+), 23 deletions(-) create mode 100644 src/main/java/frc/robot/command/L2.java create mode 100644 src/main/java/frc/robot/command/L3.java create mode 100644 src/main/java/frc/robot/command/L4.java diff --git a/src/main/java/frc/robot/command/L2.java b/src/main/java/frc/robot/command/L2.java new file mode 100644 index 0000000..9804df8 --- /dev/null +++ b/src/main/java/frc/robot/command/L2.java @@ -0,0 +1,46 @@ +// 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.command; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Elevateur; + +/* 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 L2 extends Command { + private Elevateur elevateur; + /** Creates a new L2. */ + public L2(Elevateur elevateur) { + this.elevateur = elevateur; + addRequirements(elevateur); + // 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(elevateur.position(500)>=500){ + elevateur.vitesse(0); + } + else{ + elevateur.vitesse(.5); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + elevateur.vitesse(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return elevateur.position(500)>=500; + } +} diff --git a/src/main/java/frc/robot/command/L3.java b/src/main/java/frc/robot/command/L3.java new file mode 100644 index 0000000..e5ff0da --- /dev/null +++ b/src/main/java/frc/robot/command/L3.java @@ -0,0 +1,46 @@ +// 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.command; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Elevateur; + +/* 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 L3 extends Command { + private Elevateur elevateur; + /** Creates a new L2. */ + public L3(Elevateur elevateur) { + this.elevateur = elevateur; + addRequirements(elevateur); + // 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(elevateur.position(700)>=700){ + elevateur.vitesse(0); + } + else{ + elevateur.vitesse(.5); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + elevateur.vitesse(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return elevateur.position(700)>=700; + } +} diff --git a/src/main/java/frc/robot/command/L4.java b/src/main/java/frc/robot/command/L4.java new file mode 100644 index 0000000..b0b3c1c --- /dev/null +++ b/src/main/java/frc/robot/command/L4.java @@ -0,0 +1,46 @@ +// 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.command; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Elevateur; + +/* 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 L4 extends Command { + private Elevateur elevateur; + /** Creates a new L2. */ + public L4(Elevateur elevateur) { + this.elevateur = elevateur; + addRequirements(elevateur); + // 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(elevateur.position(800)>=800){ + elevateur.vitesse(0); + } + else{ + elevateur.vitesse(.5); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + elevateur.vitesse(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return elevateur.position(800)>=800; + } +} diff --git a/src/main/java/frc/robot/subsystems/Elevateur.java b/src/main/java/frc/robot/subsystems/Elevateur.java index 33d51b1..e81d5ef 100644 --- a/src/main/java/frc/robot/subsystems/Elevateur.java +++ b/src/main/java/frc/robot/subsystems/Elevateur.java @@ -13,34 +13,16 @@ public class Elevateur extends SubsystemBase { public Elevateur() {} final SparkMax monte = new SparkMax(0, MotorType.kBrushless); final DigitalInput limit2 = new DigitalInput(0); - public double positionL2(double position){ + public double position(double position){ return monte.getEncoder().getPosition(); } - public void vitesseL2(double vitesse){ - monte.set(vitesse); - } - public double positionL3(double position){ - return monte.getEncoder().getPosition(); - } - public void vitesseL3(double vitesse){ - monte.set(vitesse); - } - public double positionL4(double position){ - return monte.getEncoder().getPosition(); - } - public void vitesseL4(double vitesse){ - monte.set(vitesse); - } - public double position1(double position){ - return monte.getEncoder().getPosition(); - } - public void vitesse1(double vitesse){ + public void vitesse(double vitesse){ monte.set(vitesse); } + + + - public void manuel(double vitesse){ - monte.set(vitesse); - } @Override public void periodic() { // This method will be called once per scheduler run From e7b4b479284ce1337c598724639717e3e3962ea8 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 27 Jan 2025 19:51:46 -0500 Subject: [PATCH 04/43] elevateur --- src/main/java/frc/robot/command/Depart.java | 47 ++++++++++++++++++ .../frc/robot/command/ElevateurManuel.java | 48 +++++++++++++++++++ src/main/java/frc/robot/command/L2.java | 6 +-- src/main/java/frc/robot/command/L3.java | 4 +- src/main/java/frc/robot/command/L4.java | 4 +- .../java/frc/robot/subsystems/Elevateur.java | 12 +++-- 6 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 src/main/java/frc/robot/command/Depart.java create mode 100644 src/main/java/frc/robot/command/ElevateurManuel.java diff --git a/src/main/java/frc/robot/command/Depart.java b/src/main/java/frc/robot/command/Depart.java new file mode 100644 index 0000000..4d101e9 --- /dev/null +++ b/src/main/java/frc/robot/command/Depart.java @@ -0,0 +1,47 @@ +// 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.command; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Elevateur; + +/* 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; + /** Creates a new L2. */ + public Depart(Elevateur elevateur) { + this.elevateur = elevateur; + addRequirements(elevateur); + // 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(elevateur.limit2()==true){ + elevateur.vitesse(0); + elevateur.reset(); + } + else{ + elevateur.vitesse(-.5); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + elevateur.vitesse(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return elevateur.limit2()==true; + } +} diff --git a/src/main/java/frc/robot/command/ElevateurManuel.java b/src/main/java/frc/robot/command/ElevateurManuel.java new file mode 100644 index 0000000..c75b4f9 --- /dev/null +++ b/src/main/java/frc/robot/command/ElevateurManuel.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.command; + +import java.util.function.DoubleSupplier; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Elevateur; + +/* 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 ElevateurManuel extends Command { + private DoubleSupplier doubleSupplier; + private Elevateur elevateur; + /** Creates a new ElevateurManuel. */ + public ElevateurManuel(Elevateur elevateur,DoubleSupplier doubleSupplier) { + this.doubleSupplier = doubleSupplier; + this.elevateur = elevateur; + addRequirements(elevateur); + // 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(elevateur.limit2()==true){ + elevateur.vitesse(0); + } + elevateur.vitesse(doubleSupplier.getAsDouble()); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + elevateur.vitesse(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/command/L2.java b/src/main/java/frc/robot/command/L2.java index 9804df8..36c6522 100644 --- a/src/main/java/frc/robot/command/L2.java +++ b/src/main/java/frc/robot/command/L2.java @@ -24,11 +24,11 @@ public class L2 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position(500)>=500){ + if(elevateur.position()>=500){ elevateur.vitesse(0); } else{ - elevateur.vitesse(.5); + elevateur.vitesse(.3); } } @@ -41,6 +41,6 @@ public class L2 extends Command { // Returns true when the command should end. @Override public boolean isFinished() { - return elevateur.position(500)>=500; + return elevateur.position()>=500; } } diff --git a/src/main/java/frc/robot/command/L3.java b/src/main/java/frc/robot/command/L3.java index e5ff0da..92dfd18 100644 --- a/src/main/java/frc/robot/command/L3.java +++ b/src/main/java/frc/robot/command/L3.java @@ -24,7 +24,7 @@ public class L3 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position(700)>=700){ + if(elevateur.position()>=700){ elevateur.vitesse(0); } else{ @@ -41,6 +41,6 @@ public class L3 extends Command { // Returns true when the command should end. @Override public boolean isFinished() { - return elevateur.position(700)>=700; + return elevateur.position()>=700; } } diff --git a/src/main/java/frc/robot/command/L4.java b/src/main/java/frc/robot/command/L4.java index b0b3c1c..df01def 100644 --- a/src/main/java/frc/robot/command/L4.java +++ b/src/main/java/frc/robot/command/L4.java @@ -24,7 +24,7 @@ public class L4 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position(800)>=800){ + if(elevateur.position()>=800){ elevateur.vitesse(0); } else{ @@ -41,6 +41,6 @@ public class L4 extends Command { // Returns true when the command should end. @Override public boolean isFinished() { - return elevateur.position(800)>=800; + return elevateur.position()>=800; } } diff --git a/src/main/java/frc/robot/subsystems/Elevateur.java b/src/main/java/frc/robot/subsystems/Elevateur.java index e81d5ef..b37f6f0 100644 --- a/src/main/java/frc/robot/subsystems/Elevateur.java +++ b/src/main/java/frc/robot/subsystems/Elevateur.java @@ -13,16 +13,18 @@ public class Elevateur extends SubsystemBase { public Elevateur() {} final SparkMax monte = new SparkMax(0, MotorType.kBrushless); final DigitalInput limit2 = new DigitalInput(0); - public double position(double position){ + public double position(){ return monte.getEncoder().getPosition(); } public void vitesse(double vitesse){ monte.set(vitesse); } - - - - + public boolean limit2(){ + return limit2.get(); + } + public void reset(){ + monte.getEncoder().setPosition(0); + } @Override public void periodic() { // This method will be called once per scheduler run From 5ffa28596ced83cbdaeb04eaece20f208771b8c2 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 28 Jan 2025 18:24:21 -0500 Subject: [PATCH 05/43] aspire --- src/main/java/frc/robot/subsystems/Pince.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/main/java/frc/robot/subsystems/Pince.java diff --git a/src/main/java/frc/robot/subsystems/Pince.java b/src/main/java/frc/robot/subsystems/Pince.java new file mode 100644 index 0000000..e5219be --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Pince.java @@ -0,0 +1,44 @@ +// 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.SparkLowLevel.MotorType; +import com.revrobotics.spark.SparkMax; + +import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Pince extends SubsystemBase { + /** Creates a new Pince. */ + public Pince() {} + final SparkMax coral = new SparkMax(0, MotorType.kBrushless); + final SparkMax pivoti = new SparkMax(0, MotorType.kBrushless); + final SparkMax algue1 = new SparkMax(0, MotorType.kBrushless); + final SparkMax algue2 = new SparkMax(0, MotorType.kBrushless); + final DigitalInput limit6 = new DigitalInput(0); + public void aspirecoral(double vitesse){ + coral.set(vitesse); + } +public void pivote(double vitesse){ + pivoti.set(vitesse); +} +public void aspirealgue(double vitesse){ + algue2.set(vitesse); + algue1.set(-vitesse); +} +public double encodeurpivot(){ + return pivoti.getEncoder().getPosition(); +} +public void pisotion(){ + limit6.get(); +} +public void reset(){ + pivoti.getEncoder().setPosition(0); +} + @Override + public void periodic() { + // This method will be called once per scheduler run + } +} From 017f168b3c11aa032e2a37818a7324ff36848b78 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 28 Jan 2025 18:46:42 -0500 Subject: [PATCH 06/43] Pince --- .../frc/robot/command/CoralAlgueExpire.java | 43 +++++++++++++++++ .../frc/robot/command/CoralAlgueInspire.java | 43 +++++++++++++++++ .../java/frc/robot/command/CoralExpire.java | 41 ++++++++++++++++ .../java/frc/robot/command/CoralInspire.java | 41 ++++++++++++++++ .../java/frc/robot/command/DepartPince.java | 47 +++++++++++++++++++ src/main/java/frc/robot/subsystems/Pince.java | 4 +- 6 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 src/main/java/frc/robot/command/CoralAlgueExpire.java create mode 100644 src/main/java/frc/robot/command/CoralAlgueInspire.java create mode 100644 src/main/java/frc/robot/command/CoralExpire.java create mode 100644 src/main/java/frc/robot/command/CoralInspire.java create mode 100644 src/main/java/frc/robot/command/DepartPince.java diff --git a/src/main/java/frc/robot/command/CoralAlgueExpire.java b/src/main/java/frc/robot/command/CoralAlgueExpire.java new file mode 100644 index 0000000..261619f --- /dev/null +++ b/src/main/java/frc/robot/command/CoralAlgueExpire.java @@ -0,0 +1,43 @@ +// 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.command; + +import edu.wpi.first.wpilibj2.command.Command; +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 CoralAlgueExpire extends Command { + private Pince pince; + /** Creates a new CoralAlgue. */ + public CoralAlgueExpire(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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() { + pince.aspirecoral(.5); + pince.aspirealgue(0.5); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.aspirecoral(0); + pince.aspirealgue(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/command/CoralAlgueInspire.java b/src/main/java/frc/robot/command/CoralAlgueInspire.java new file mode 100644 index 0000000..d870285 --- /dev/null +++ b/src/main/java/frc/robot/command/CoralAlgueInspire.java @@ -0,0 +1,43 @@ +// 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.command; + +import edu.wpi.first.wpilibj2.command.Command; +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 CoralAlgueInspire extends Command { + private Pince pince; + /** Creates a new CoralAlgue. */ + public CoralAlgueInspire(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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() { + pince.aspirecoral(-.5); + pince.aspirealgue(-0.5); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.aspirecoral(0); + pince.aspirealgue(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/command/CoralExpire.java b/src/main/java/frc/robot/command/CoralExpire.java new file mode 100644 index 0000000..f4fc090 --- /dev/null +++ b/src/main/java/frc/robot/command/CoralExpire.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.command; + +import edu.wpi.first.wpilibj2.command.Command; +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 CoralExpire extends Command { + private Pince pince; + /** Creates a new CoralAlgue. */ + public CoralExpire(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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() { + pince.aspirecoral(.5); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.aspirecoral(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/command/CoralInspire.java b/src/main/java/frc/robot/command/CoralInspire.java new file mode 100644 index 0000000..6a3cc9e --- /dev/null +++ b/src/main/java/frc/robot/command/CoralInspire.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.command; + +import edu.wpi.first.wpilibj2.command.Command; +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 CoralInspire extends Command { + private Pince pince; + /** Creates a new CoralAlgue. */ + public CoralInspire(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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() { + pince.aspirecoral(-.5); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.aspirecoral(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/command/DepartPince.java b/src/main/java/frc/robot/command/DepartPince.java new file mode 100644 index 0000000..6e229f1 --- /dev/null +++ b/src/main/java/frc/robot/command/DepartPince.java @@ -0,0 +1,47 @@ +// 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.command; + +import edu.wpi.first.wpilibj2.command.Command; +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 DepartPince extends Command { + private Pince pince; + /** Creates a new DepartPince. */ + public DepartPince(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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(pince.position()==true){ + pince.pivote(0); + pince.reset(); + } + else{ + pince.pivote(-.5); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.pivote(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystems/Pince.java b/src/main/java/frc/robot/subsystems/Pince.java index e5219be..9b44423 100644 --- a/src/main/java/frc/robot/subsystems/Pince.java +++ b/src/main/java/frc/robot/subsystems/Pince.java @@ -31,8 +31,8 @@ public void aspirealgue(double vitesse){ public double encodeurpivot(){ return pivoti.getEncoder().getPosition(); } -public void pisotion(){ - limit6.get(); +public boolean position(){ + return limit6.get(); } public void reset(){ pivoti.getEncoder().setPosition(0); From 0fdfa4269d0ab9efff2fe29047013c8ad6a50fa8 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 28 Jan 2025 18:54:42 -0500 Subject: [PATCH 07/43] elevateurise mieux --- src/main/java/frc/robot/command/L2.java | 8 ++++++-- src/main/java/frc/robot/command/L3.java | 7 +++++-- src/main/java/frc/robot/command/L4.java | 5 ++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/command/L2.java b/src/main/java/frc/robot/command/L2.java index 36c6522..8f7287a 100644 --- a/src/main/java/frc/robot/command/L2.java +++ b/src/main/java/frc/robot/command/L2.java @@ -24,12 +24,16 @@ public class L2 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position()>=500){ + if(elevateur.position()>=500 && elevateur.position()<=510){ elevateur.vitesse(0); } + else if(elevateur.position()>=510){ + elevateur.vitesse(-0.3); + } else{ elevateur.vitesse(.3); } + } // Called once the command ends or is interrupted. @@ -41,6 +45,6 @@ public class L2 extends Command { // Returns true when the command should end. @Override public boolean isFinished() { - return elevateur.position()>=500; + return false; } } diff --git a/src/main/java/frc/robot/command/L3.java b/src/main/java/frc/robot/command/L3.java index 92dfd18..8974af4 100644 --- a/src/main/java/frc/robot/command/L3.java +++ b/src/main/java/frc/robot/command/L3.java @@ -24,9 +24,12 @@ public class L3 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position()>=700){ + if(elevateur.position()>=700 && elevateur.position()<=710){ elevateur.vitesse(0); } + else if(elevateur.position()>=510){ + elevateur.vitesse(-0.5); + } else{ elevateur.vitesse(.5); } @@ -41,6 +44,6 @@ public class L3 extends Command { // Returns true when the command should end. @Override public boolean isFinished() { - return elevateur.position()>=700; + return false; } } diff --git a/src/main/java/frc/robot/command/L4.java b/src/main/java/frc/robot/command/L4.java index df01def..a688516 100644 --- a/src/main/java/frc/robot/command/L4.java +++ b/src/main/java/frc/robot/command/L4.java @@ -24,9 +24,12 @@ public class L4 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position()>=800){ + if(elevateur.position()>=800 && elevateur.position()<=810){ elevateur.vitesse(0); } + else if(elevateur.position()>=810){ + elevateur.vitesse(-0.5); + } else{ elevateur.vitesse(.5); } From aafb2a62b5f53e43224cd5e6ea5afddf3f5aedb6 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 28 Jan 2025 19:09:16 -0500 Subject: [PATCH 08/43] Algue --- ...CoralAlgueExpire.java => AlgueExpire.java} | 6 +-- .../frc/robot/command/CoralAlgueInspire.java | 15 +++++- src/main/java/frc/robot/command/L2Pince.java | 47 +++++++++++++++++++ src/main/java/frc/robot/subsystems/Pince.java | 6 +++ 4 files changed, 68 insertions(+), 6 deletions(-) rename src/main/java/frc/robot/command/{CoralAlgueExpire.java => AlgueExpire.java} (89%) create mode 100644 src/main/java/frc/robot/command/L2Pince.java diff --git a/src/main/java/frc/robot/command/CoralAlgueExpire.java b/src/main/java/frc/robot/command/AlgueExpire.java similarity index 89% rename from src/main/java/frc/robot/command/CoralAlgueExpire.java rename to src/main/java/frc/robot/command/AlgueExpire.java index 261619f..00559dd 100644 --- a/src/main/java/frc/robot/command/CoralAlgueExpire.java +++ b/src/main/java/frc/robot/command/AlgueExpire.java @@ -8,10 +8,10 @@ import edu.wpi.first.wpilibj2.command.Command; 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 CoralAlgueExpire extends Command { +public class AlgueExpire extends Command { private Pince pince; /** Creates a new CoralAlgue. */ - public CoralAlgueExpire(Pince pince) { + public AlgueExpire(Pince pince) { this.pince = pince; addRequirements(pince); // Use addRequirements() here to declare subsystem dependencies. @@ -24,14 +24,12 @@ public class CoralAlgueExpire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - pince.aspirecoral(.5); pince.aspirealgue(0.5); } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - pince.aspirecoral(0); pince.aspirealgue(0); } diff --git a/src/main/java/frc/robot/command/CoralAlgueInspire.java b/src/main/java/frc/robot/command/CoralAlgueInspire.java index d870285..64d0e1d 100644 --- a/src/main/java/frc/robot/command/CoralAlgueInspire.java +++ b/src/main/java/frc/robot/command/CoralAlgueInspire.java @@ -24,8 +24,19 @@ public class CoralAlgueInspire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - pince.aspirecoral(-.5); - pince.aspirealgue(-0.5); + if(pince.emperagecoral()>8){ + pince.aspirealgue(-0.5); + } + else{ + pince.aspirealgue(0); + } + if(pince.emperagealgue()>8){ + pince.aspirealgue(0); + } + else{ + pince.aspirealgue(-0.5); + } + } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/command/L2Pince.java b/src/main/java/frc/robot/command/L2Pince.java new file mode 100644 index 0000000..a39c34c --- /dev/null +++ b/src/main/java/frc/robot/command/L2Pince.java @@ -0,0 +1,47 @@ +// 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.command; + +import edu.wpi.first.wpilibj2.command.Command; +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 L2Pince extends Command { + private Pince pince; + /** Creates a new L2Pince. */ + public L2Pince(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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(pince.encodeurpivot()>=500 && pince.encodeurpivot()<=510){ + pince.pivote(0); + } + else if(pince.encodeurpivot()>=510){ + pince.pivote(-0.3); + } + else{ + pince.pivote(0.3); + } + } + + // 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/subsystems/Pince.java b/src/main/java/frc/robot/subsystems/Pince.java index 9b44423..e2ec30e 100644 --- a/src/main/java/frc/robot/subsystems/Pince.java +++ b/src/main/java/frc/robot/subsystems/Pince.java @@ -36,6 +36,12 @@ public boolean position(){ } public void reset(){ pivoti.getEncoder().setPosition(0); +} +public double emperagecoral(){ + return coral.getOutputCurrent(); +} +public double emperagealgue(){ + return algue1.getOutputCurrent(); } @Override public void periodic() { From d6420659e9703c278858b6ba706e6c85de1f8d56 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 28 Jan 2025 19:10:42 -0500 Subject: [PATCH 09/43] --- src/main/java/frc/robot/command/CoralInspire.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/command/CoralInspire.java b/src/main/java/frc/robot/command/CoralInspire.java index 6a3cc9e..a2de4a2 100644 --- a/src/main/java/frc/robot/command/CoralInspire.java +++ b/src/main/java/frc/robot/command/CoralInspire.java @@ -24,7 +24,12 @@ public class CoralInspire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - pince.aspirecoral(-.5); + if(pince.emperagecoral()>8){ + pince.aspirecoral(-.5); + } + else{ + pince.aspirecoral(.5); + } } // Called once the command ends or is interrupted. From 1d1d6e962d880d6e5bf5f6e9375cd29f88646f45 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 28 Jan 2025 19:19:34 -0500 Subject: [PATCH 10/43] pince --- .../frc/robot/command/CoralAlgueInspire.java | 7 +-- src/main/java/frc/robot/command/L2Pince.java | 4 +- src/main/java/frc/robot/command/L3Pince.java | 49 +++++++++++++++++++ src/main/java/frc/robot/command/L4Pince.java | 49 +++++++++++++++++++ .../java/frc/robot/command/StationPince.java | 49 +++++++++++++++++++ 5 files changed, 151 insertions(+), 7 deletions(-) create mode 100644 src/main/java/frc/robot/command/L3Pince.java create mode 100644 src/main/java/frc/robot/command/L4Pince.java create mode 100644 src/main/java/frc/robot/command/StationPince.java diff --git a/src/main/java/frc/robot/command/CoralAlgueInspire.java b/src/main/java/frc/robot/command/CoralAlgueInspire.java index 64d0e1d..4823613 100644 --- a/src/main/java/frc/robot/command/CoralAlgueInspire.java +++ b/src/main/java/frc/robot/command/CoralAlgueInspire.java @@ -24,12 +24,7 @@ public class CoralAlgueInspire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(pince.emperagecoral()>8){ - pince.aspirealgue(-0.5); - } - else{ - pince.aspirealgue(0); - } + pince.aspirecoral(.5); if(pince.emperagealgue()>8){ pince.aspirealgue(0); } diff --git a/src/main/java/frc/robot/command/L2Pince.java b/src/main/java/frc/robot/command/L2Pince.java index a39c34c..febefc9 100644 --- a/src/main/java/frc/robot/command/L2Pince.java +++ b/src/main/java/frc/robot/command/L2Pince.java @@ -37,7 +37,9 @@ public class L2Pince extends Command { // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + pince.pivote(0); + } // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/command/L3Pince.java b/src/main/java/frc/robot/command/L3Pince.java new file mode 100644 index 0000000..a56a809 --- /dev/null +++ b/src/main/java/frc/robot/command/L3Pince.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.command; + +import edu.wpi.first.wpilibj2.command.Command; +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 L3Pince extends Command { + private Pince pince; + /** Creates a new L2Pince. */ + public L3Pince(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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(pince.encodeurpivot()>=700 && pince.encodeurpivot()<=710){ + pince.pivote(0); + } + else if(pince.encodeurpivot()>=710){ + pince.pivote(-0.5); + } + else{ + pince.pivote(0.5); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.pivote(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/command/L4Pince.java b/src/main/java/frc/robot/command/L4Pince.java new file mode 100644 index 0000000..b113b92 --- /dev/null +++ b/src/main/java/frc/robot/command/L4Pince.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.command; + +import edu.wpi.first.wpilibj2.command.Command; +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 L4Pince extends Command { + private Pince pince; + /** Creates a new L2Pince. */ + public L4Pince(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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(pince.encodeurpivot()>=800 && pince.encodeurpivot()<=810){ + pince.pivote(0); + } + else if(pince.encodeurpivot()>=810){ + pince.pivote(-0.5); + } + else{ + pince.pivote(0.5); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.pivote(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/command/StationPince.java b/src/main/java/frc/robot/command/StationPince.java new file mode 100644 index 0000000..9721590 --- /dev/null +++ b/src/main/java/frc/robot/command/StationPince.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.command; + +import edu.wpi.first.wpilibj2.command.Command; +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 StationPince extends Command { + private Pince pince; + /** Creates a new L2Pince. */ + public StationPince(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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(pince.encodeurpivot()>=900 && pince.encodeurpivot()<=910){ + pince.pivote(0); + } + else if(pince.encodeurpivot()>=910){ + pince.pivote(-0.5); + } + else{ + pince.pivote(0.5); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.pivote(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} From 7848c4aaf24c0b7b9c25ac0b292d4b7f4660c422 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 18:12:14 -0500 Subject: [PATCH 11/43] debug --- src/main/java/frc/robot/command/CoralAlgueInspire.java | 4 ++-- src/main/java/frc/robot/command/CoralInspire.java | 2 +- src/main/java/frc/robot/command/DepartPince.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/command/CoralAlgueInspire.java b/src/main/java/frc/robot/command/CoralAlgueInspire.java index 4823613..d8007fc 100644 --- a/src/main/java/frc/robot/command/CoralAlgueInspire.java +++ b/src/main/java/frc/robot/command/CoralAlgueInspire.java @@ -24,12 +24,12 @@ public class CoralAlgueInspire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - pince.aspirecoral(.5); + pince.aspirecoral(-.5); if(pince.emperagealgue()>8){ pince.aspirealgue(0); } else{ - pince.aspirealgue(-0.5); + pince.aspirealgue(0.5); } } diff --git a/src/main/java/frc/robot/command/CoralInspire.java b/src/main/java/frc/robot/command/CoralInspire.java index a2de4a2..3a9a7c7 100644 --- a/src/main/java/frc/robot/command/CoralInspire.java +++ b/src/main/java/frc/robot/command/CoralInspire.java @@ -25,7 +25,7 @@ public class CoralInspire extends Command { @Override public void execute() { if(pince.emperagecoral()>8){ - pince.aspirecoral(-.5); + pince.aspirecoral(0); } else{ pince.aspirecoral(.5); diff --git a/src/main/java/frc/robot/command/DepartPince.java b/src/main/java/frc/robot/command/DepartPince.java index 6e229f1..f47c0cb 100644 --- a/src/main/java/frc/robot/command/DepartPince.java +++ b/src/main/java/frc/robot/command/DepartPince.java @@ -29,7 +29,7 @@ public class DepartPince extends Command { pince.reset(); } else{ - pince.pivote(-.5); + pince.pivote(.5); } } From eece0f47fa9071b3ea8b7d3022152c2a0e79d3f6 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 18:43:31 -0500 Subject: [PATCH 12/43] pince et elevateur --- src/main/java/frc/robot/command/Depart.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/frc/robot/command/Depart.java b/src/main/java/frc/robot/command/Depart.java index 4d101e9..0980101 100644 --- a/src/main/java/frc/robot/command/Depart.java +++ b/src/main/java/frc/robot/command/Depart.java @@ -10,8 +10,10 @@ import frc.robot.subsystems.Elevateur; /* 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) { + this.elevateur = elevateur; addRequirements(elevateur); // Use addRequirements() here to declare subsystem dependencies. @@ -31,6 +33,13 @@ public class Depart extends Command { else{ elevateur.vitesse(-.5); } + if(pince.position()==true){ + pince.pivote(0); + pince.reset(); + } + else{ + pince.pivote(.5); + } } // Called once the command ends or is interrupted. From 1f17aaf4de27b582d69b0413ae9fed785abe18ef Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 18:55:06 -0500 Subject: [PATCH 13/43] pince+elevateur --- src/main/java/frc/robot/command/Depart.java | 16 ++++--- src/main/java/frc/robot/command/L2.java | 18 +++++-- src/main/java/frc/robot/command/L2Pince.java | 49 -------------------- src/main/java/frc/robot/command/L3.java | 17 ++++++- src/main/java/frc/robot/command/L3Pince.java | 49 -------------------- src/main/java/frc/robot/command/L4.java | 17 ++++++- src/main/java/frc/robot/command/L4Pince.java | 49 -------------------- 7 files changed, 55 insertions(+), 160 deletions(-) delete mode 100644 src/main/java/frc/robot/command/L2Pince.java delete mode 100644 src/main/java/frc/robot/command/L3Pince.java delete mode 100644 src/main/java/frc/robot/command/L4Pince.java diff --git a/src/main/java/frc/robot/command/Depart.java b/src/main/java/frc/robot/command/Depart.java index 0980101..5a9f11e 100644 --- a/src/main/java/frc/robot/command/Depart.java +++ b/src/main/java/frc/robot/command/Depart.java @@ -6,16 +6,17 @@ package frc.robot.command; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; +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) { - + public Depart(Elevateur elevateur, Pince pince) { + this.pince = pince; this.elevateur = elevateur; - addRequirements(elevateur); + addRequirements(elevateur,pince); // Use addRequirements() here to declare subsystem dependencies. } @@ -33,12 +34,14 @@ public class Depart extends Command { else{ elevateur.vitesse(-.5); } - if(pince.position()==true){ + if(pince.encodeurpivot()>=900 && pince.encodeurpivot()<=910){ pince.pivote(0); - pince.reset(); + } + else if(pince.encodeurpivot()>=910){ + pince.pivote(-0.5); } else{ - pince.pivote(.5); + pince.pivote(0.5); } } @@ -46,6 +49,7 @@ public class Depart extends Command { @Override public void end(boolean interrupted) { elevateur.vitesse(0); + pince.pivote(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/command/L2.java b/src/main/java/frc/robot/command/L2.java index 8f7287a..dea2746 100644 --- a/src/main/java/frc/robot/command/L2.java +++ b/src/main/java/frc/robot/command/L2.java @@ -6,14 +6,17 @@ package frc.robot.command; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; +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 L2 extends Command { private Elevateur elevateur; + private Pince pince; /** Creates a new L2. */ - public L2(Elevateur elevateur) { + public L2(Elevateur elevateur,Pince pince) { this.elevateur = elevateur; - addRequirements(elevateur); + this.pince = pince; + addRequirements(elevateur,pince); // Use addRequirements() here to declare subsystem dependencies. } @@ -33,13 +36,22 @@ public class L2 extends Command { else{ elevateur.vitesse(.3); } - + if(pince.encodeurpivot()>=500 && pince.encodeurpivot()<=510){ + pince.pivote(0); + } + else if(pince.encodeurpivot()>=510){ + pince.pivote(-0.3); + } + else{ + pince.pivote(0.3); + } } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { elevateur.vitesse(0); + pince.pivote(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/command/L2Pince.java b/src/main/java/frc/robot/command/L2Pince.java deleted file mode 100644 index febefc9..0000000 --- a/src/main/java/frc/robot/command/L2Pince.java +++ /dev/null @@ -1,49 +0,0 @@ -// 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.command; - -import edu.wpi.first.wpilibj2.command.Command; -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 L2Pince extends Command { - private Pince pince; - /** Creates a new L2Pince. */ - public L2Pince(Pince pince) { - this.pince = pince; - addRequirements(pince); - // 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(pince.encodeurpivot()>=500 && pince.encodeurpivot()<=510){ - pince.pivote(0); - } - else if(pince.encodeurpivot()>=510){ - pince.pivote(-0.3); - } - else{ - pince.pivote(0.3); - } - } - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) { - pince.pivote(0); - } - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/frc/robot/command/L3.java b/src/main/java/frc/robot/command/L3.java index 8974af4..e83b28e 100644 --- a/src/main/java/frc/robot/command/L3.java +++ b/src/main/java/frc/robot/command/L3.java @@ -6,14 +6,17 @@ package frc.robot.command; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; +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 L3 extends Command { private Elevateur elevateur; + private Pince pince; /** Creates a new L2. */ - public L3(Elevateur elevateur) { + public L3(Elevateur elevateur,Pince pince) { this.elevateur = elevateur; - addRequirements(elevateur); + this.pince = pince; + addRequirements(elevateur,pince); // Use addRequirements() here to declare subsystem dependencies. } @@ -33,12 +36,22 @@ public class L3 extends Command { else{ elevateur.vitesse(.5); } + if(pince.encodeurpivot()>=700 && pince.encodeurpivot()<=710){ + pince.pivote(0); + } + else if(pince.encodeurpivot()>=710){ + pince.pivote(-0.5); + } + else{ + pince.pivote(0.5); + } } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { elevateur.vitesse(0); + pince.pivote(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/command/L3Pince.java b/src/main/java/frc/robot/command/L3Pince.java deleted file mode 100644 index a56a809..0000000 --- a/src/main/java/frc/robot/command/L3Pince.java +++ /dev/null @@ -1,49 +0,0 @@ -// 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.command; - -import edu.wpi.first.wpilibj2.command.Command; -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 L3Pince extends Command { - private Pince pince; - /** Creates a new L2Pince. */ - public L3Pince(Pince pince) { - this.pince = pince; - addRequirements(pince); - // 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(pince.encodeurpivot()>=700 && pince.encodeurpivot()<=710){ - pince.pivote(0); - } - else if(pince.encodeurpivot()>=710){ - pince.pivote(-0.5); - } - else{ - pince.pivote(0.5); - } - } - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) { - pince.pivote(0); - } - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/frc/robot/command/L4.java b/src/main/java/frc/robot/command/L4.java index a688516..ec79016 100644 --- a/src/main/java/frc/robot/command/L4.java +++ b/src/main/java/frc/robot/command/L4.java @@ -6,14 +6,17 @@ package frc.robot.command; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; +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 L4 extends Command { private Elevateur elevateur; + private Pince pince; /** Creates a new L2. */ - public L4(Elevateur elevateur) { + public L4(Elevateur elevateur,Pince pince) { this.elevateur = elevateur; - addRequirements(elevateur); + this.pince = pince; + addRequirements(elevateur,pince); // Use addRequirements() here to declare subsystem dependencies. } @@ -33,12 +36,22 @@ public class L4 extends Command { else{ elevateur.vitesse(.5); } + if(pince.encodeurpivot()>=800 && pince.encodeurpivot()<=810){ + pince.pivote(0); + } + else if(pince.encodeurpivot()>=810){ + pince.pivote(-0.5); + } + else{ + pince.pivote(0.5); + } } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { elevateur.vitesse(0); + pince.pivote(0); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/command/L4Pince.java b/src/main/java/frc/robot/command/L4Pince.java deleted file mode 100644 index b113b92..0000000 --- a/src/main/java/frc/robot/command/L4Pince.java +++ /dev/null @@ -1,49 +0,0 @@ -// 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.command; - -import edu.wpi.first.wpilibj2.command.Command; -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 L4Pince extends Command { - private Pince pince; - /** Creates a new L2Pince. */ - public L4Pince(Pince pince) { - this.pince = pince; - addRequirements(pince); - // 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(pince.encodeurpivot()>=800 && pince.encodeurpivot()<=810){ - pince.pivote(0); - } - else if(pince.encodeurpivot()>=810){ - pince.pivote(-0.5); - } - else{ - pince.pivote(0.5); - } - } - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) { - pince.pivote(0); - } - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} From 126058e9d49a804835868fc8f73bf84bde136d61 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 19:01:51 -0500 Subject: [PATCH 14/43] touche --- src/main/java/frc/robot/RobotContainer.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index de2c9d0..a66c3f2 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -6,13 +6,27 @@ package frc.robot; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; +import edu.wpi.first.wpilibj2.command.button.CommandXboxController; +import frc.robot.command.AlgueExpire; +import frc.robot.command.CoralAlgueInspire; +import frc.robot.command.CoralExpire; +import frc.robot.subsystems.Elevateur; +import frc.robot.subsystems.Pince; public class RobotContainer { + CommandXboxController manette = new CommandXboxController(0); + Pince pince = new Pince(); + Elevateur elevateur = new Elevateur(); public RobotContainer() { configureBindings(); } - private void configureBindings() {} + private void configureBindings() { + manette.a().whileTrue(new AlgueExpire(pince)); + manette.b().whileTrue(new CoralAlgueInspire(pince)); + manette.x().whileTrue(new CoralExpire(pince)); + manette.y().whileTrue(new CoralExpire(pince)); + } public Command getAutonomousCommand() { return Commands.print("No autonomous command configured"); From afaec61f6d9558e473cecc9dbd39837356e99e26 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 19:19:14 -0500 Subject: [PATCH 15/43] touche pince+elevateur --- src/main/java/frc/robot/RobotContainer.java | 30 +++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index a66c3f2..f8ae3d7 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,28 +4,48 @@ package frc.robot; +import edu.wpi.first.math.MathUtil; 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.command.AlgueExpire; import frc.robot.command.CoralAlgueInspire; import frc.robot.command.CoralExpire; +import frc.robot.command.Depart; +import frc.robot.command.DepartPince; +import frc.robot.command.ElevateurManuel; +import frc.robot.command.L2; +import frc.robot.command.L3; +import frc.robot.command.L4; +import frc.robot.command.StationPince; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; public class RobotContainer { - CommandXboxController manette = new CommandXboxController(0); + CommandXboxController manette1 = new CommandXboxController(0); + CommandXboxController manette2 = new CommandXboxController(0); Pince pince = new Pince(); Elevateur elevateur = new Elevateur(); + ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); public RobotContainer() { configureBindings(); + elevateur.setDefaultCommand(new RunCommand(()->{ + elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); + }, elevateur)); } private void configureBindings() { - manette.a().whileTrue(new AlgueExpire(pince)); - manette.b().whileTrue(new CoralAlgueInspire(pince)); - manette.x().whileTrue(new CoralExpire(pince)); - manette.y().whileTrue(new CoralExpire(pince)); + manette1.a().whileTrue(new AlgueExpire(pince)); + manette1.b().whileTrue(new CoralAlgueInspire(pince)); + manette1.x().whileTrue(new CoralExpire(pince)); + manette1.y().whileTrue(new CoralExpire(pince)); + manette1.povUp().toggleOnTrue(new L4(elevateur, pince)); + manette1.povRight().toggleOnTrue(new L2(elevateur, pince)); + manette1.povLeft().toggleOnTrue(new L3(elevateur, pince)); + manette1.povDown().toggleOnTrue(new Depart(elevateur, pince)); + manette2.leftBumper().toggleOnTrue(new DepartPince(pince)); + manette2.a().whileTrue(new StationPince(pince)); } public Command getAutonomousCommand() { From 4869632d6d22d6aac07f32dda373aede45909674 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 19:29:01 -0500 Subject: [PATCH 16/43] manette pince elevateur --- src/main/java/frc/robot/RobotContainer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index f8ae3d7..f2d6b80 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -12,6 +12,7 @@ import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import frc.robot.command.AlgueExpire; import frc.robot.command.CoralAlgueInspire; import frc.robot.command.CoralExpire; +import frc.robot.command.CoralInspire; import frc.robot.command.Depart; import frc.robot.command.DepartPince; import frc.robot.command.ElevateurManuel; @@ -36,14 +37,16 @@ public class RobotContainer { } private void configureBindings() { + // manette1 manette1.a().whileTrue(new AlgueExpire(pince)); manette1.b().whileTrue(new CoralAlgueInspire(pince)); - manette1.x().whileTrue(new CoralExpire(pince)); + manette1.x().whileTrue(new CoralInspire(pince)); manette1.y().whileTrue(new CoralExpire(pince)); manette1.povUp().toggleOnTrue(new L4(elevateur, pince)); manette1.povRight().toggleOnTrue(new L2(elevateur, pince)); manette1.povLeft().toggleOnTrue(new L3(elevateur, pince)); manette1.povDown().toggleOnTrue(new Depart(elevateur, pince)); + //manette2 manette2.leftBumper().toggleOnTrue(new DepartPince(pince)); manette2.a().whileTrue(new StationPince(pince)); } From 20c95efe93ba8306b2b4930c8fc540110084d712 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 19:35:13 -0500 Subject: [PATCH 17/43] --- src/main/java/frc/robot/RobotContainer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index f2d6b80..bb8c7a6 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -24,8 +24,7 @@ import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; public class RobotContainer { - CommandXboxController manette1 = new CommandXboxController(0); - CommandXboxController manette2 = new CommandXboxController(0); + Pince pince = new Pince(); Elevateur elevateur = new Elevateur(); ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); From ee2c9ff4b2d6a231c0ffed69059423e15c925809 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 19:37:35 -0500 Subject: [PATCH 18/43] manette --- src/main/java/frc/robot/RobotContainer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index bb8c7a6..f2d6b80 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -24,7 +24,8 @@ import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; public class RobotContainer { - + CommandXboxController manette1 = new CommandXboxController(0); + CommandXboxController manette2 = new CommandXboxController(0); Pince pince = new Pince(); Elevateur elevateur = new Elevateur(); ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); From b3845852244322af7be020128903ebee78ead2e8 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 20:13:38 -0500 Subject: [PATCH 19/43] pince mieux --- src/main/java/frc/robot/RobotContainer.java | 2 +- .../java/frc/robot/command/StationPince.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index f2d6b80..1e2ae3b 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -48,7 +48,7 @@ public class RobotContainer { manette1.povDown().toggleOnTrue(new Depart(elevateur, pince)); //manette2 manette2.leftBumper().toggleOnTrue(new DepartPince(pince)); - manette2.a().whileTrue(new StationPince(pince)); + manette2.a().whileTrue(new StationPince(pince,elevateur)); } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/command/StationPince.java b/src/main/java/frc/robot/command/StationPince.java index 9721590..2f72e07 100644 --- a/src/main/java/frc/robot/command/StationPince.java +++ b/src/main/java/frc/robot/command/StationPince.java @@ -5,15 +5,18 @@ package frc.robot.command; import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Elevateur; 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 StationPince extends Command { private Pince pince; + private Elevateur elevateur; /** Creates a new L2Pince. */ - public StationPince(Pince pince) { + public StationPince(Pince pince,Elevateur elevateur) { + this.elevateur = elevateur; this.pince = pince; - addRequirements(pince); + addRequirements(pince,elevateur); // Use addRequirements() here to declare subsystem dependencies. } @@ -33,6 +36,15 @@ public class StationPince extends Command { else{ pince.pivote(0.5); } + if(elevateur.position()>=400 && elevateur.position()<=410){ + elevateur.vitesse(0); + } + else if(elevateur.position()>=510){ + elevateur.vitesse(-0.3); + } + else{ + elevateur.vitesse(.3); + } } // Called once the command ends or is interrupted. From 26a4b9f9a3827698295a4bff6ec8f2db4759eedb Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 29 Jan 2025 20:15:07 -0500 Subject: [PATCH 20/43] touche --- src/main/java/frc/robot/command/StationPince.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/command/StationPince.java b/src/main/java/frc/robot/command/StationPince.java index 2f72e07..bb26c6c 100644 --- a/src/main/java/frc/robot/command/StationPince.java +++ b/src/main/java/frc/robot/command/StationPince.java @@ -39,7 +39,7 @@ public class StationPince extends Command { if(elevateur.position()>=400 && elevateur.position()<=410){ elevateur.vitesse(0); } - else if(elevateur.position()>=510){ + else if(elevateur.position()>=410){ elevateur.vitesse(-0.3); } else{ From 06abfa4dbbc82bc70666961719e5a685f2026be9 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Thu, 30 Jan 2025 20:18:15 -0500 Subject: [PATCH 21/43] Named Commands --- src/main/java/frc/robot/RobotContainer.java | 14 ++++++++++++++ src/main/java/frc/robot/command/CoralExpire.java | 2 +- src/main/java/frc/robot/command/StationPince.java | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 1e2ae3b..fbb1cd2 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,7 +4,12 @@ package frc.robot; +import com.pathplanner.lib.auto.AutoBuilder; +import com.pathplanner.lib.auto.NamedCommands; +import com.pathplanner.lib.auto.AutoBuilder; +import com.pathplanner.lib.auto.NamedCommands; import edu.wpi.first.math.MathUtil; +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; @@ -24,8 +29,10 @@ import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; public class RobotContainer { + CommandXboxController manette1 = new CommandXboxController(0); CommandXboxController manette2 = new CommandXboxController(0); + private final SendableChooser autoChooser; Pince pince = new Pince(); Elevateur elevateur = new Elevateur(); ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); @@ -34,6 +41,13 @@ public class RobotContainer { elevateur.setDefaultCommand(new RunCommand(()->{ elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); }, elevateur)); + NamedCommands.registerCommand("Station",new StationPince(pince, elevateur)); + NamedCommands.registerCommand("L4", new L4(elevateur, pince)); + NamedCommands.registerCommand("L3", new L3(elevateur, pince)); + NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince)); + NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince)); + NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince)); + autoChooser = AutoBuilder.buildAutoChooser(); } private void configureBindings() { diff --git a/src/main/java/frc/robot/command/CoralExpire.java b/src/main/java/frc/robot/command/CoralExpire.java index f4fc090..ec53a3d 100644 --- a/src/main/java/frc/robot/command/CoralExpire.java +++ b/src/main/java/frc/robot/command/CoralExpire.java @@ -24,7 +24,7 @@ public class CoralExpire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - pince.aspirecoral(.5); + pince.aspirecoral(-.5); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/command/StationPince.java b/src/main/java/frc/robot/command/StationPince.java index bb26c6c..2f00f4f 100644 --- a/src/main/java/frc/robot/command/StationPince.java +++ b/src/main/java/frc/robot/command/StationPince.java @@ -10,6 +10,7 @@ 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 StationPince extends Command { + private Pince pince; private Elevateur elevateur; /** Creates a new L2Pince. */ From 210d2197930a06606d7e578b4c0c515ee4b34f17 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 3 Feb 2025 17:49:34 -0500 Subject: [PATCH 22/43] simulation --- simgui-ds.json | 92 +++++++++++++++++++ src/main/java/frc/robot/RobotContainer.java | 2 +- .../java/frc/robot/subsystems/Elevateur.java | 4 +- .../java/frc/robot/subsystems/Grimpeur.java | 4 +- 4 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 simgui-ds.json diff --git a/simgui-ds.json b/simgui-ds.json new file mode 100644 index 0000000..73cc713 --- /dev/null +++ b/simgui-ds.json @@ -0,0 +1,92 @@ +{ + "keyboardJoysticks": [ + { + "axisConfig": [ + { + "decKey": 65, + "incKey": 68 + }, + { + "decKey": 87, + "incKey": 83 + }, + { + "decKey": 69, + "decayRate": 0.0, + "incKey": 82, + "keyRate": 0.009999999776482582 + } + ], + "axisCount": 3, + "buttonCount": 4, + "buttonKeys": [ + 90, + 88, + 67, + 86 + ], + "povConfig": [ + { + "key0": 328, + "key135": 323, + "key180": 322, + "key225": 321, + "key270": 324, + "key315": 327, + "key45": 329, + "key90": 326 + } + ], + "povCount": 1 + }, + { + "axisConfig": [ + { + "decKey": 74, + "incKey": 76 + }, + { + "decKey": 73, + "incKey": 75 + } + ], + "axisCount": 2, + "buttonCount": 4, + "buttonKeys": [ + 77, + 44, + 46, + 47 + ], + "povCount": 0 + }, + { + "axisConfig": [ + { + "decKey": 263, + "incKey": 262 + }, + { + "decKey": 265, + "incKey": 264 + } + ], + "axisCount": 2, + "buttonCount": 6, + "buttonKeys": [ + 260, + 268, + 266, + 261, + 269, + 267 + ], + "povCount": 0 + }, + { + "axisCount": 0, + "buttonCount": 0, + "povCount": 0 + } + ] +} diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index fbb1cd2..0cd68f6 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -31,7 +31,7 @@ import frc.robot.subsystems.Pince; public class RobotContainer { CommandXboxController manette1 = new CommandXboxController(0); - CommandXboxController manette2 = new CommandXboxController(0); + CommandXboxController manette2 = new CommandXboxController(1); private final SendableChooser autoChooser; Pince pince = new Pince(); Elevateur elevateur = new Elevateur(); diff --git a/src/main/java/frc/robot/subsystems/Elevateur.java b/src/main/java/frc/robot/subsystems/Elevateur.java index b37f6f0..8caad7a 100644 --- a/src/main/java/frc/robot/subsystems/Elevateur.java +++ b/src/main/java/frc/robot/subsystems/Elevateur.java @@ -11,8 +11,8 @@ import com.revrobotics.spark.SparkLowLevel.MotorType; public class Elevateur extends SubsystemBase { /** Creates a new Elevateur. */ public Elevateur() {} - final SparkMax monte = new SparkMax(0, MotorType.kBrushless); - final DigitalInput limit2 = new DigitalInput(0); + final SparkMax monte = new SparkMax(3, MotorType.kBrushless); + final DigitalInput limit2 = new DigitalInput(1); public double position(){ return monte.getEncoder().getPosition(); } diff --git a/src/main/java/frc/robot/subsystems/Grimpeur.java b/src/main/java/frc/robot/subsystems/Grimpeur.java index 7e55e0b..14b4fb1 100644 --- a/src/main/java/frc/robot/subsystems/Grimpeur.java +++ b/src/main/java/frc/robot/subsystems/Grimpeur.java @@ -11,8 +11,8 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Grimpeur extends SubsystemBase { /** Creates a new Grimpeur. */ public Grimpeur() {} - final Spark grimpeur = new Spark(0); - final DigitalInput limit1 = new DigitalInput(0); + final Spark grimpeur = new Spark(2); + final DigitalInput limit1 = new DigitalInput(3); public void grimpe(double vitesse){ grimpeur.set(vitesse); } From 6f75b9cc4253a3259223381c480bd4b9bb02f3df Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 3 Feb 2025 17:51:57 -0500 Subject: [PATCH 23/43] id --- src/main/java/frc/robot/RobotContainer.java | 2 +- src/main/java/frc/robot/subsystems/Pince.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 0cd68f6..6c56874 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -66,6 +66,6 @@ public class RobotContainer { } public Command getAutonomousCommand() { - return Commands.print("No autonomous command configured"); + return autoChooser.getSelected(); } } diff --git a/src/main/java/frc/robot/subsystems/Pince.java b/src/main/java/frc/robot/subsystems/Pince.java index e2ec30e..50bcfe7 100644 --- a/src/main/java/frc/robot/subsystems/Pince.java +++ b/src/main/java/frc/robot/subsystems/Pince.java @@ -13,11 +13,11 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Pince extends SubsystemBase { /** Creates a new Pince. */ public Pince() {} - final SparkMax coral = new SparkMax(0, MotorType.kBrushless); - final SparkMax pivoti = new SparkMax(0, MotorType.kBrushless); - final SparkMax algue1 = new SparkMax(0, MotorType.kBrushless); - final SparkMax algue2 = new SparkMax(0, MotorType.kBrushless); - final DigitalInput limit6 = new DigitalInput(0); + final SparkMax coral = new SparkMax(1, MotorType.kBrushless); + final SparkMax pivoti = new SparkMax(2, MotorType.kBrushless); + final SparkMax algue1 = new SparkMax(4, MotorType.kBrushless); + final SparkMax algue2 = new SparkMax(5, MotorType.kBrushless); + final DigitalInput limit6 = new DigitalInput(2); public void aspirecoral(double vitesse){ coral.set(vitesse); } From 44f6030e992e43797db2a51ccd20cb75660d90ba Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 3 Feb 2025 18:19:29 -0500 Subject: [PATCH 24/43] simulation fait --- simgui-ds.json | 10 ++++++++++ src/main/java/frc/robot/RobotContainer.java | 16 ++++++++-------- src/main/java/frc/robot/command/L4.java | 6 +++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/simgui-ds.json b/simgui-ds.json index 73cc713..1ba71ce 100644 --- a/simgui-ds.json +++ b/simgui-ds.json @@ -1,4 +1,14 @@ { + "Joysticks": { + "window": { + "visible": false + } + }, + "System Joysticks": { + "window": { + "enabled": false + } + }, "keyboardJoysticks": [ { "axisConfig": [ diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 6c56874..ae083bf 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -32,7 +32,7 @@ public class RobotContainer { CommandXboxController manette1 = new CommandXboxController(0); CommandXboxController manette2 = new CommandXboxController(1); - private final SendableChooser autoChooser; + // private final SendableChooser autoChooser; Pince pince = new Pince(); Elevateur elevateur = new Elevateur(); ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); @@ -41,13 +41,13 @@ public class RobotContainer { elevateur.setDefaultCommand(new RunCommand(()->{ elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); }, elevateur)); - NamedCommands.registerCommand("Station",new StationPince(pince, elevateur)); + /* NamedCommands.registerCommand("Station",new StationPince(pince, elevateur)); NamedCommands.registerCommand("L4", new L4(elevateur, pince)); NamedCommands.registerCommand("L3", new L3(elevateur, pince)); NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince)); NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince)); NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince)); - autoChooser = AutoBuilder.buildAutoChooser(); + autoChooser = AutoBuilder.buildAutoChooser();*/ } private void configureBindings() { @@ -56,16 +56,16 @@ public class RobotContainer { manette1.b().whileTrue(new CoralAlgueInspire(pince)); manette1.x().whileTrue(new CoralInspire(pince)); manette1.y().whileTrue(new CoralExpire(pince)); - manette1.povUp().toggleOnTrue(new L4(elevateur, pince)); - manette1.povRight().toggleOnTrue(new L2(elevateur, pince)); - manette1.povLeft().toggleOnTrue(new L3(elevateur, pince)); - manette1.povDown().toggleOnTrue(new Depart(elevateur, pince)); + manette1.povUp().whileTrue(new L4(elevateur, pince)); + manette1.povRight().whileTrue(new L2(elevateur, pince)); + manette1.povLeft().whileTrue(new L3(elevateur, pince)); + manette1.povDown().whileTrue(new Depart(elevateur, pince)); //manette2 manette2.leftBumper().toggleOnTrue(new DepartPince(pince)); manette2.a().whileTrue(new StationPince(pince,elevateur)); } public Command getAutonomousCommand() { - return autoChooser.getSelected(); + return null;// autoChooser.getSelected(); } } diff --git a/src/main/java/frc/robot/command/L4.java b/src/main/java/frc/robot/command/L4.java index ec79016..b14d515 100644 --- a/src/main/java/frc/robot/command/L4.java +++ b/src/main/java/frc/robot/command/L4.java @@ -27,7 +27,7 @@ public class L4 extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(elevateur.position()>=800 && elevateur.position()<=810){ + if(elevateur.position()>=800 && elevateur.position()<=809){ elevateur.vitesse(0); } else if(elevateur.position()>=810){ @@ -36,7 +36,7 @@ public class L4 extends Command { else{ elevateur.vitesse(.5); } - if(pince.encodeurpivot()>=800 && pince.encodeurpivot()<=810){ + if(pince.encodeurpivot()>=800 && pince.encodeurpivot()<=809){ pince.pivote(0); } else if(pince.encodeurpivot()>=810){ @@ -57,6 +57,6 @@ public class L4 extends Command { // Returns true when the command should end. @Override public boolean isFinished() { - return elevateur.position()>=800; + return false; } } From 8aca411a238e999a29aa68657d84b0628c62cb63 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 3 Feb 2025 18:26:54 -0500 Subject: [PATCH 25/43] id --- src/main/java/frc/robot/subsystems/Grimpeur.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/Grimpeur.java b/src/main/java/frc/robot/subsystems/Grimpeur.java index 14b4fb1..a36f37f 100644 --- a/src/main/java/frc/robot/subsystems/Grimpeur.java +++ b/src/main/java/frc/robot/subsystems/Grimpeur.java @@ -11,7 +11,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Grimpeur extends SubsystemBase { /** Creates a new Grimpeur. */ public Grimpeur() {} - final Spark grimpeur = new Spark(2); + final Spark grimpeur = new Spark(10); final DigitalInput limit1 = new DigitalInput(3); public void grimpe(double vitesse){ grimpeur.set(vitesse); From 9cd08cf07c21d9aa8bf0cf9e2b248aabb9ee260a Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 3 Feb 2025 18:32:34 -0500 Subject: [PATCH 26/43] --- src/main/java/frc/robot/subsystems/Grimpeur.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/Grimpeur.java b/src/main/java/frc/robot/subsystems/Grimpeur.java index a36f37f..e20eef5 100644 --- a/src/main/java/frc/robot/subsystems/Grimpeur.java +++ b/src/main/java/frc/robot/subsystems/Grimpeur.java @@ -4,14 +4,17 @@ 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.motorcontrol.Spark; + import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Grimpeur extends SubsystemBase { /** Creates a new Grimpeur. */ public Grimpeur() {} - final Spark grimpeur = new Spark(10); + final SparkMax grimpeur = new SparkMax(1,MotorType.kBrushless); final DigitalInput limit1 = new DigitalInput(3); public void grimpe(double vitesse){ grimpeur.set(vitesse); From 2260580c8181aa4638c8518acaf05fc13ff40cfd Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 3 Feb 2025 18:37:36 -0500 Subject: [PATCH 27/43] marche mieux --- .../java/frc/robot/subsystems/Grimpeur.java | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/main/java/frc/robot/subsystems/Grimpeur.java diff --git a/src/main/java/frc/robot/subsystems/Grimpeur.java b/src/main/java/frc/robot/subsystems/Grimpeur.java deleted file mode 100644 index e20eef5..0000000 --- a/src/main/java/frc/robot/subsystems/Grimpeur.java +++ /dev/null @@ -1,29 +0,0 @@ -// 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.wpilibj2.command.SubsystemBase; - -public class Grimpeur extends SubsystemBase { - /** Creates a new Grimpeur. */ - public Grimpeur() {} - final SparkMax grimpeur = new SparkMax(1,MotorType.kBrushless); - final DigitalInput limit1 = new DigitalInput(3); - public void grimpe(double vitesse){ - grimpeur.set(vitesse); - } - final void stop(){ - limit1.get(); - } - @Override - public void periodic() { - // This method will be called once per scheduler run - } -} From 451d3c6e208e1c7e7c287fc9d1d28ba0827a3559 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Thu, 6 Feb 2025 17:50:24 -0500 Subject: [PATCH 28/43] command -> commands --- src/main/java/frc/robot/RobotContainer.java | 22 +++++++++---------- .../{command => commands}/AlgueExpire.java | 2 +- .../CoralAlgueInspire.java | 2 +- .../{command => commands}/CoralExpire.java | 2 +- .../{command => commands}/CoralInspire.java | 2 +- .../robot/{command => commands}/Depart.java | 2 +- .../{command => commands}/DepartPince.java | 2 +- .../ElevateurManuel.java | 2 +- .../frc/robot/{command => commands}/L2.java | 2 +- .../frc/robot/{command => commands}/L3.java | 2 +- .../frc/robot/{command => commands}/L4.java | 2 +- .../{command => commands}/StationPince.java | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) rename src/main/java/frc/robot/{command => commands}/AlgueExpire.java (97%) rename src/main/java/frc/robot/{command => commands}/CoralAlgueInspire.java (98%) rename src/main/java/frc/robot/{command => commands}/CoralExpire.java (97%) rename src/main/java/frc/robot/{command => commands}/CoralInspire.java (97%) rename src/main/java/frc/robot/{command => commands}/Depart.java (98%) rename src/main/java/frc/robot/{command => commands}/DepartPince.java (97%) rename src/main/java/frc/robot/{command => commands}/ElevateurManuel.java (98%) rename src/main/java/frc/robot/{command => commands}/L2.java (98%) rename src/main/java/frc/robot/{command => commands}/L3.java (98%) rename src/main/java/frc/robot/{command => commands}/L4.java (98%) rename src/main/java/frc/robot/{command => commands}/StationPince.java (98%) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index ae083bf..9ae7628 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -14,17 +14,17 @@ 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.command.AlgueExpire; -import frc.robot.command.CoralAlgueInspire; -import frc.robot.command.CoralExpire; -import frc.robot.command.CoralInspire; -import frc.robot.command.Depart; -import frc.robot.command.DepartPince; -import frc.robot.command.ElevateurManuel; -import frc.robot.command.L2; -import frc.robot.command.L3; -import frc.robot.command.L4; -import frc.robot.command.StationPince; +import frc.robot.commands.AlgueExpire; +import frc.robot.commands.CoralAlgueInspire; +import frc.robot.commands.CoralExpire; +import frc.robot.commands.CoralInspire; +import frc.robot.commands.Depart; +import frc.robot.commands.DepartPince; +import frc.robot.commands.ElevateurManuel; +import frc.robot.commands.L2; +import frc.robot.commands.L3; +import frc.robot.commands.L4; +import frc.robot.commands.StationPince; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/command/AlgueExpire.java b/src/main/java/frc/robot/commands/AlgueExpire.java similarity index 97% rename from src/main/java/frc/robot/command/AlgueExpire.java rename to src/main/java/frc/robot/commands/AlgueExpire.java index 00559dd..5b34608 100644 --- a/src/main/java/frc/robot/command/AlgueExpire.java +++ b/src/main/java/frc/robot/commands/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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/command/CoralAlgueInspire.java b/src/main/java/frc/robot/commands/CoralAlgueInspire.java similarity index 98% rename from src/main/java/frc/robot/command/CoralAlgueInspire.java rename to src/main/java/frc/robot/commands/CoralAlgueInspire.java index d8007fc..7382f67 100644 --- a/src/main/java/frc/robot/command/CoralAlgueInspire.java +++ b/src/main/java/frc/robot/commands/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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/command/CoralExpire.java b/src/main/java/frc/robot/commands/CoralExpire.java similarity index 97% rename from src/main/java/frc/robot/command/CoralExpire.java rename to src/main/java/frc/robot/commands/CoralExpire.java index ec53a3d..8acf1a3 100644 --- a/src/main/java/frc/robot/command/CoralExpire.java +++ b/src/main/java/frc/robot/commands/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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/command/CoralInspire.java b/src/main/java/frc/robot/commands/CoralInspire.java similarity index 97% rename from src/main/java/frc/robot/command/CoralInspire.java rename to src/main/java/frc/robot/commands/CoralInspire.java index 3a9a7c7..80f14b9 100644 --- a/src/main/java/frc/robot/command/CoralInspire.java +++ b/src/main/java/frc/robot/commands/CoralInspire.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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/command/Depart.java b/src/main/java/frc/robot/commands/Depart.java similarity index 98% rename from src/main/java/frc/robot/command/Depart.java rename to src/main/java/frc/robot/commands/Depart.java index 5a9f11e..4d53236 100644 --- a/src/main/java/frc/robot/command/Depart.java +++ b/src/main/java/frc/robot/commands/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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; diff --git a/src/main/java/frc/robot/command/DepartPince.java b/src/main/java/frc/robot/commands/DepartPince.java similarity index 97% rename from src/main/java/frc/robot/command/DepartPince.java rename to src/main/java/frc/robot/commands/DepartPince.java index f47c0cb..a8c621e 100644 --- a/src/main/java/frc/robot/command/DepartPince.java +++ b/src/main/java/frc/robot/commands/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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/command/ElevateurManuel.java b/src/main/java/frc/robot/commands/ElevateurManuel.java similarity index 98% rename from src/main/java/frc/robot/command/ElevateurManuel.java rename to src/main/java/frc/robot/commands/ElevateurManuel.java index c75b4f9..0a52684 100644 --- a/src/main/java/frc/robot/command/ElevateurManuel.java +++ b/src/main/java/frc/robot/commands/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.command; +package frc.robot.commands; import java.util.function.DoubleSupplier; diff --git a/src/main/java/frc/robot/command/L2.java b/src/main/java/frc/robot/commands/L2.java similarity index 98% rename from src/main/java/frc/robot/command/L2.java rename to src/main/java/frc/robot/commands/L2.java index dea2746..179742a 100644 --- a/src/main/java/frc/robot/command/L2.java +++ b/src/main/java/frc/robot/commands/L2.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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; diff --git a/src/main/java/frc/robot/command/L3.java b/src/main/java/frc/robot/commands/L3.java similarity index 98% rename from src/main/java/frc/robot/command/L3.java rename to src/main/java/frc/robot/commands/L3.java index e83b28e..273a609 100644 --- a/src/main/java/frc/robot/command/L3.java +++ b/src/main/java/frc/robot/commands/L3.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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; diff --git a/src/main/java/frc/robot/command/L4.java b/src/main/java/frc/robot/commands/L4.java similarity index 98% rename from src/main/java/frc/robot/command/L4.java rename to src/main/java/frc/robot/commands/L4.java index b14d515..b55fc3d 100644 --- a/src/main/java/frc/robot/command/L4.java +++ b/src/main/java/frc/robot/commands/L4.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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; diff --git a/src/main/java/frc/robot/command/StationPince.java b/src/main/java/frc/robot/commands/StationPince.java similarity index 98% rename from src/main/java/frc/robot/command/StationPince.java rename to src/main/java/frc/robot/commands/StationPince.java index 2f00f4f..f0c3ccf 100644 --- a/src/main/java/frc/robot/command/StationPince.java +++ b/src/main/java/frc/robot/commands/StationPince.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.command; +package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Elevateur; From 319c370c6e42a96b5c2aa9e7fe880ab2967743d3 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 10 Feb 2025 19:49:13 -0500 Subject: [PATCH 29/43] Bougie(pas fini) --- src/main/java/frc/robot/RobotContainer.java | 25 +++++-------- .../java/frc/robot/commands/CoralExpire.java | 13 +++++-- .../java/frc/robot/commands/CoralInspire.java | 9 +++-- .../java/frc/robot/subsystems/Bougie.java | 37 +++++++++++++++++++ 4 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 src/main/java/frc/robot/subsystems/Bougie.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 9ae7628..886718b 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,14 +4,9 @@ package frc.robot; -import com.pathplanner.lib.auto.AutoBuilder; -import com.pathplanner.lib.auto.NamedCommands; -import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.auto.NamedCommands; import edu.wpi.first.math.MathUtil; -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.AlgueExpire; @@ -27,12 +22,12 @@ import frc.robot.commands.L4; import frc.robot.commands.StationPince; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; - +import frc.robot.subsystems.Bougie; public class RobotContainer { CommandXboxController manette1 = new CommandXboxController(0); CommandXboxController manette2 = new CommandXboxController(1); - // private final SendableChooser autoChooser; + Bougie bougie = new Bougie(); Pince pince = new Pince(); Elevateur elevateur = new Elevateur(); ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); @@ -41,21 +36,21 @@ public class RobotContainer { elevateur.setDefaultCommand(new RunCommand(()->{ elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); }, elevateur)); - /* NamedCommands.registerCommand("Station",new StationPince(pince, elevateur)); + NamedCommands.registerCommand("Station",new StationPince(pince, elevateur)); NamedCommands.registerCommand("L4", new L4(elevateur, pince)); NamedCommands.registerCommand("L3", new L3(elevateur, pince)); - NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince)); - NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince)); + NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince,bougie)); + NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince,bougie)); NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince)); - autoChooser = AutoBuilder.buildAutoChooser();*/ + } private void configureBindings() { // manette1 manette1.a().whileTrue(new AlgueExpire(pince)); manette1.b().whileTrue(new CoralAlgueInspire(pince)); - manette1.x().whileTrue(new CoralInspire(pince)); - manette1.y().whileTrue(new CoralExpire(pince)); + manette1.x().whileTrue(new CoralInspire(pince,bougie)); + manette1.y().whileTrue(new CoralExpire(pince,bougie)); manette1.povUp().whileTrue(new L4(elevateur, pince)); manette1.povRight().whileTrue(new L2(elevateur, pince)); manette1.povLeft().whileTrue(new L3(elevateur, pince)); @@ -64,8 +59,8 @@ public class RobotContainer { manette2.leftBumper().toggleOnTrue(new DepartPince(pince)); manette2.a().whileTrue(new StationPince(pince,elevateur)); } - + public Command getAutonomousCommand() { - return null;// autoChooser.getSelected(); + return Command() } } diff --git a/src/main/java/frc/robot/commands/CoralExpire.java b/src/main/java/frc/robot/commands/CoralExpire.java index 8acf1a3..ebb90db 100644 --- a/src/main/java/frc/robot/commands/CoralExpire.java +++ b/src/main/java/frc/robot/commands/CoralExpire.java @@ -6,14 +6,16 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; - +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 CoralExpire extends Command { private Pince pince; + Bougie bougie; /** Creates a new CoralAlgue. */ - public CoralExpire(Pince pince) { + public CoralExpire(Pince pince, Bougie bougie) { this.pince = pince; - addRequirements(pince); + this.bougie = bougie; + addRequirements(pince,bougie); // Use addRequirements() here to declare subsystem dependencies. } @@ -24,7 +26,12 @@ public class CoralExpire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { + if(pince.emperagecoral() > 8){ + pince.aspirecoral(-.5); + } + else{ pince.aspirecoral(-.5); + bougie.Rouge();} } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/CoralInspire.java b/src/main/java/frc/robot/commands/CoralInspire.java index 80f14b9..5255d2f 100644 --- a/src/main/java/frc/robot/commands/CoralInspire.java +++ b/src/main/java/frc/robot/commands/CoralInspire.java @@ -6,14 +6,16 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Pince; - +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 CoralInspire extends Command { private Pince pince; + Bougie bougie; /** Creates a new CoralAlgue. */ - public CoralInspire(Pince pince) { + public CoralInspire(Pince pince, Bougie bougie) { this.pince = pince; - addRequirements(pince); + this.bougie = bougie; + addRequirements(pince,bougie); // Use addRequirements() here to declare subsystem dependencies. } @@ -25,6 +27,7 @@ public class CoralInspire extends Command { @Override public void execute() { if(pince.emperagecoral()>8){ + bougie.Vert(); pince.aspirecoral(0); } else{ diff --git a/src/main/java/frc/robot/subsystems/Bougie.java b/src/main/java/frc/robot/subsystems/Bougie.java new file mode 100644 index 0000000..5dfcf91 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Bougie.java @@ -0,0 +1,37 @@ +// 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.ctre.phoenix.led.CANdle; +import com.ctre.phoenix.led.CANdleConfiguration; +import com.ctre.phoenix.led.RainbowAnimation; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Bougie extends SubsystemBase { + CANdle candle = new CANdle(5); + CANdleConfiguration config = new CANdleConfiguration(); + RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 64); + /** Creates a new Bougie. */ + public Bougie() { + config.brightnessScalar = 0.5; + candle.configAllSettings(config); + } + public void Rouge() { + candle.setLEDs(255, 0, 0); + } + public void Vert() { + candle.setLEDs(0, 255, 0); + } + public void Bleu() { + candle.setLEDs(0, 0, 255); + } + 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 + } +} From 53adcf57011187190c80424b7147cf07df587b80 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 10 Feb 2025 19:53:34 -0500 Subject: [PATCH 30/43] Bougie finie --- src/main/java/frc/robot/RobotContainer.java | 3 ++- src/main/java/frc/robot/commands/CoralInspire.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 886718b..0295b88 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -7,6 +7,7 @@ package frc.robot; import com.pathplanner.lib.auto.NamedCommands; import edu.wpi.first.math.MathUtil; 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.AlgueExpire; @@ -61,6 +62,6 @@ public class RobotContainer { } public Command getAutonomousCommand() { - return Command() + return Commands.print("No autonomous command configured"); } } diff --git a/src/main/java/frc/robot/commands/CoralInspire.java b/src/main/java/frc/robot/commands/CoralInspire.java index 5255d2f..2ec67f3 100644 --- a/src/main/java/frc/robot/commands/CoralInspire.java +++ b/src/main/java/frc/robot/commands/CoralInspire.java @@ -32,6 +32,7 @@ public class CoralInspire extends Command { } else{ pince.aspirecoral(.5); + bougie.Bleu(); } } From 0e04704942223878f9f262179244a10795fb4e0f Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Tue, 11 Feb 2025 19:22:25 -0500 Subject: [PATCH 31/43] leds pince --- src/main/java/frc/robot/RobotContainer.java | 6 +++--- .../java/frc/robot/commands/AlgueExpire.java | 16 +++++++++++--- .../frc/robot/commands/CoralAlgueInspire.java | 8 +++++-- .../java/frc/robot/commands/CoralExpire.java | 2 +- .../java/frc/robot/commands/CoralInspire.java | 1 - src/main/java/frc/robot/commands/L2.java | 3 +++ src/main/java/frc/robot/commands/L3.java | 3 ++- src/main/java/frc/robot/commands/L4.java | 1 + .../java/frc/robot/subsystems/Bougie.java | 21 ++++++++++++++++--- 9 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 0295b88..57b9cea 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -42,14 +42,14 @@ public class RobotContainer { NamedCommands.registerCommand("L3", new L3(elevateur, pince)); NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince,bougie)); NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince,bougie)); - NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince)); + NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince,bougie)); } private void configureBindings() { // manette1 - manette1.a().whileTrue(new AlgueExpire(pince)); - manette1.b().whileTrue(new CoralAlgueInspire(pince)); + manette1.a().whileTrue(new AlgueExpire(pince,bougie)); + manette1.b().whileTrue(new CoralAlgueInspire(pince,bougie)); manette1.x().whileTrue(new CoralInspire(pince,bougie)); manette1.y().whileTrue(new CoralExpire(pince,bougie)); manette1.povUp().whileTrue(new L4(elevateur, pince)); diff --git a/src/main/java/frc/robot/commands/AlgueExpire.java b/src/main/java/frc/robot/commands/AlgueExpire.java index 5b34608..077fa7d 100644 --- a/src/main/java/frc/robot/commands/AlgueExpire.java +++ b/src/main/java/frc/robot/commands/AlgueExpire.java @@ -5,15 +5,18 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; 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 AlgueExpire extends Command { private Pince pince; + private Bougie bougie; /** Creates a new CoralAlgue. */ - public AlgueExpire(Pince pince) { + public AlgueExpire(Pince pince,Bougie bougie) { this.pince = pince; - addRequirements(pince); + this.bougie = bougie; + addRequirements(pince,bougie); // Use addRequirements() here to declare subsystem dependencies. } @@ -24,7 +27,14 @@ public class AlgueExpire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - pince.aspirealgue(0.5); + if(pince.emperagealgue()>8){ + pince.aspirealgue(0.5); + } + else{ + pince.aspirealgue(0.5); + bougie.Jaune(); + } + } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/CoralAlgueInspire.java b/src/main/java/frc/robot/commands/CoralAlgueInspire.java index 7382f67..4697090 100644 --- a/src/main/java/frc/robot/commands/CoralAlgueInspire.java +++ b/src/main/java/frc/robot/commands/CoralAlgueInspire.java @@ -5,15 +5,18 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; 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 CoralAlgueInspire extends Command { private Pince pince; + private Bougie bougie; /** Creates a new CoralAlgue. */ - public CoralAlgueInspire(Pince pince) { + public CoralAlgueInspire(Pince pince, Bougie bougie) { this.pince = pince; - addRequirements(pince); + this.bougie = bougie; + addRequirements(pince,bougie); // Use addRequirements() here to declare subsystem dependencies. } @@ -27,6 +30,7 @@ public class CoralAlgueInspire extends Command { pince.aspirecoral(-.5); if(pince.emperagealgue()>8){ pince.aspirealgue(0); + bougie.Bleu(); } else{ pince.aspirealgue(0.5); diff --git a/src/main/java/frc/robot/commands/CoralExpire.java b/src/main/java/frc/robot/commands/CoralExpire.java index ebb90db..c2932e5 100644 --- a/src/main/java/frc/robot/commands/CoralExpire.java +++ b/src/main/java/frc/robot/commands/CoralExpire.java @@ -31,7 +31,7 @@ public class CoralExpire extends Command { } else{ pince.aspirecoral(-.5); - bougie.Rouge();} + bougie.Jaune();} } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/CoralInspire.java b/src/main/java/frc/robot/commands/CoralInspire.java index 2ec67f3..fc249ba 100644 --- a/src/main/java/frc/robot/commands/CoralInspire.java +++ b/src/main/java/frc/robot/commands/CoralInspire.java @@ -27,7 +27,6 @@ public class CoralInspire extends Command { @Override public void execute() { if(pince.emperagecoral()>8){ - bougie.Vert(); pince.aspirecoral(0); } else{ diff --git a/src/main/java/frc/robot/commands/L2.java b/src/main/java/frc/robot/commands/L2.java index 179742a..ca5b8ec 100644 --- a/src/main/java/frc/robot/commands/L2.java +++ b/src/main/java/frc/robot/commands/L2.java @@ -5,6 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; @@ -38,6 +39,7 @@ public class L2 extends Command { } if(pince.encodeurpivot()>=500 && pince.encodeurpivot()<=510){ pince.pivote(0); + } else if(pince.encodeurpivot()>=510){ pince.pivote(-0.3); @@ -45,6 +47,7 @@ public class L2 extends Command { else{ pince.pivote(0.3); } + } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/L3.java b/src/main/java/frc/robot/commands/L3.java index 273a609..c933027 100644 --- a/src/main/java/frc/robot/commands/L3.java +++ b/src/main/java/frc/robot/commands/L3.java @@ -5,6 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; @@ -15,7 +16,7 @@ public class L3 extends Command { /** Creates a new L2. */ public L3(Elevateur elevateur,Pince pince) { this.elevateur = elevateur; - this.pince = pince; + this.pince = pince; addRequirements(elevateur,pince); // Use addRequirements() here to declare subsystem dependencies. } diff --git a/src/main/java/frc/robot/commands/L4.java b/src/main/java/frc/robot/commands/L4.java index b55fc3d..9cbcaf0 100644 --- a/src/main/java/frc/robot/commands/L4.java +++ b/src/main/java/frc/robot/commands/L4.java @@ -5,6 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Bougie; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/subsystems/Bougie.java b/src/main/java/frc/robot/subsystems/Bougie.java index 5dfcf91..98bdf49 100644 --- a/src/main/java/frc/robot/subsystems/Bougie.java +++ b/src/main/java/frc/robot/subsystems/Bougie.java @@ -20,14 +20,29 @@ public class Bougie extends SubsystemBase { candle.configAllSettings(config); } public void Rouge() { - candle.setLEDs(255, 0, 0); + candle.setLEDs(255, 0, 0,0,8,8); + candle.setLEDs(255, 0, 0,0,24,8); + candle.setLEDs(255, 0, 0,0,40,8); + candle.setLEDs(255, 0, 0,0,56,8); } public void Vert() { - candle.setLEDs(0, 255, 0); + candle.setLEDs(0, 255, 0,0,8,8); + candle.setLEDs(0, 255, 0,0,24,8); + candle.setLEDs(0, 255, 0,0,40,8); + candle.setLEDs(0, 255, 0,0,56,8); } public void Bleu() { - candle.setLEDs(0, 0, 255); + candle.setLEDs(0, 0, 255,0,16,8); + candle.setLEDs(0, 0, 255,0,32,8); + candle.setLEDs(0, 0, 255,0,48,8); + candle.setLEDs(0, 0, 255,0,64,8); } + public void Jaune() { + candle.setLEDs(255, 215, 0,0,16,8); + candle.setLEDs(255, 215, 0,0,32,8); + 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);} @Override From c1bdf0aab733e5edd809263f6e6c1598762a60b7 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Wed, 12 Feb 2025 16:54:47 -0500 Subject: [PATCH 32/43] modif --- src/main/java/frc/robot/commands/AlgueExpire.java | 2 +- src/main/java/frc/robot/commands/CoralExpire.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/commands/AlgueExpire.java b/src/main/java/frc/robot/commands/AlgueExpire.java index 077fa7d..c40fab2 100644 --- a/src/main/java/frc/robot/commands/AlgueExpire.java +++ b/src/main/java/frc/robot/commands/AlgueExpire.java @@ -28,7 +28,7 @@ public class AlgueExpire extends Command { @Override public void execute() { if(pince.emperagealgue()>8){ - pince.aspirealgue(0.5); + pince.aspirealgue(0); } else{ pince.aspirealgue(0.5); diff --git a/src/main/java/frc/robot/commands/CoralExpire.java b/src/main/java/frc/robot/commands/CoralExpire.java index c2932e5..15ec3c8 100644 --- a/src/main/java/frc/robot/commands/CoralExpire.java +++ b/src/main/java/frc/robot/commands/CoralExpire.java @@ -27,7 +27,7 @@ public class CoralExpire extends Command { @Override public void execute() { if(pince.emperagecoral() > 8){ - pince.aspirecoral(-.5); + pince.aspirecoral(0); } else{ pince.aspirecoral(-.5); From 16277705723d438e53e2d7784cfff447f0dee50e Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Thu, 20 Feb 2025 20:17:00 -0500 Subject: [PATCH 33/43] code mieux --- .../java/frc/robot/commands/AlgueExpire.java | 2 +- .../java/frc/robot/commands/PinceManuel.java | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/main/java/frc/robot/commands/PinceManuel.java diff --git a/src/main/java/frc/robot/commands/AlgueExpire.java b/src/main/java/frc/robot/commands/AlgueExpire.java index c40fab2..ab177d4 100644 --- a/src/main/java/frc/robot/commands/AlgueExpire.java +++ b/src/main/java/frc/robot/commands/AlgueExpire.java @@ -31,7 +31,7 @@ public class AlgueExpire extends Command { pince.aspirealgue(0); } else{ - pince.aspirealgue(0.5); + pince.aspirealgue(-0.5); bougie.Jaune(); } diff --git a/src/main/java/frc/robot/commands/PinceManuel.java b/src/main/java/frc/robot/commands/PinceManuel.java new file mode 100644 index 0000000..526e743 --- /dev/null +++ b/src/main/java/frc/robot/commands/PinceManuel.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; + +import java.util.function.DoubleSupplier; + +import edu.wpi.first.wpilibj2.command.Command; +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 PinceManuel extends Command { + private Pince pince; + private DoubleSupplier doubleSupplier; + /** Creates a new PinceManuel. */ + public PinceManuel(Pince pince, DoubleSupplier doubleSupplier) { + this.pince = pince; + this.doubleSupplier = doubleSupplier; + addRequirements(pince); + // 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() {} + + // 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; + } +} From 0be9356fa910c3748f248f547bb33831e980ec4e Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Thu, 20 Feb 2025 20:25:59 -0500 Subject: [PATCH 34/43] code mieux --- src/main/java/frc/robot/RobotContainer.java | 5 +++++ src/main/java/frc/robot/commands/L2.java | 2 +- src/main/java/frc/robot/commands/L3.java | 2 +- src/main/java/frc/robot/commands/L4.java | 2 +- src/main/java/frc/robot/commands/PinceManuel.java | 9 ++++++++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 57b9cea..be01536 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -20,6 +20,7 @@ import frc.robot.commands.ElevateurManuel; import frc.robot.commands.L2; import frc.robot.commands.L3; import frc.robot.commands.L4; +import frc.robot.commands.PinceManuel; import frc.robot.commands.StationPince; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; @@ -32,11 +33,15 @@ public class RobotContainer { Pince pince = new Pince(); Elevateur elevateur = new Elevateur(); ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); + PinceManuel pinceManuel = new PinceManuel(pince, manette2::getRightY); public RobotContainer() { configureBindings(); elevateur.setDefaultCommand(new RunCommand(()->{ elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); }, elevateur)); + pince.setDefaultCommand(new RunCommand(()->{ + pince.pivote(MathUtil.applyDeadband(manette2.getRightY(), 0.2)); + }, pince)); NamedCommands.registerCommand("Station",new StationPince(pince, elevateur)); NamedCommands.registerCommand("L4", new L4(elevateur, pince)); NamedCommands.registerCommand("L3", new L3(elevateur, pince)); diff --git a/src/main/java/frc/robot/commands/L2.java b/src/main/java/frc/robot/commands/L2.java index ca5b8ec..8cca282 100644 --- a/src/main/java/frc/robot/commands/L2.java +++ b/src/main/java/frc/robot/commands/L2.java @@ -5,7 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.subsystems.Bougie; + import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/L3.java b/src/main/java/frc/robot/commands/L3.java index c933027..c92e442 100644 --- a/src/main/java/frc/robot/commands/L3.java +++ b/src/main/java/frc/robot/commands/L3.java @@ -5,7 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.subsystems.Bougie; + import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/L4.java b/src/main/java/frc/robot/commands/L4.java index 9cbcaf0..f32bf81 100644 --- a/src/main/java/frc/robot/commands/L4.java +++ b/src/main/java/frc/robot/commands/L4.java @@ -5,7 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.subsystems.Bougie; + import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; diff --git a/src/main/java/frc/robot/commands/PinceManuel.java b/src/main/java/frc/robot/commands/PinceManuel.java index 526e743..b30eed5 100644 --- a/src/main/java/frc/robot/commands/PinceManuel.java +++ b/src/main/java/frc/robot/commands/PinceManuel.java @@ -27,7 +27,14 @@ public class PinceManuel extends Command { // Called every time the scheduler runs while the command is scheduled. @Override - public void execute() {} + public void execute() { + if(pince.position()){ + pince.pivote(0); + } + else{ + pince.pivote(doubleSupplier.getAsDouble()); + } + } // Called once the command ends or is interrupted. @Override From 69ef6b69824758cee5b3824d693c7060863d9535 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Sat, 22 Feb 2025 09:55:55 -0500 Subject: [PATCH 35/43] pince mieux --- .SysId/sysid.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 .SysId/sysid.json diff --git a/.SysId/sysid.json b/.SysId/sysid.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/.SysId/sysid.json @@ -0,0 +1 @@ +{} From bb9d5a5550fe3d26faeedc991a0921cc28230ef3 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Sat, 22 Feb 2025 10:30:20 -0500 Subject: [PATCH 36/43] touche --- src/main/java/frc/robot/RobotContainer.java | 21 ++++---- .../java/frc/robot/commands/CoralInspire.java | 49 ------------------- .../java/frc/robot/commands/StationPince.java | 2 + 3 files changed, 11 insertions(+), 61 deletions(-) delete mode 100644 src/main/java/frc/robot/commands/CoralInspire.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index be01536..4bba20b 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -13,7 +13,6 @@ import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import frc.robot.commands.AlgueExpire; import frc.robot.commands.CoralAlgueInspire; import frc.robot.commands.CoralExpire; -import frc.robot.commands.CoralInspire; import frc.robot.commands.Depart; import frc.robot.commands.DepartPince; import frc.robot.commands.ElevateurManuel; @@ -46,24 +45,22 @@ public class RobotContainer { NamedCommands.registerCommand("L4", new L4(elevateur, pince)); NamedCommands.registerCommand("L3", new L3(elevateur, pince)); NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince,bougie)); - NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince,bougie)); NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince,bougie)); } private void configureBindings() { // manette1 - manette1.a().whileTrue(new AlgueExpire(pince,bougie)); - manette1.b().whileTrue(new CoralAlgueInspire(pince,bougie)); - manette1.x().whileTrue(new CoralInspire(pince,bougie)); - manette1.y().whileTrue(new CoralExpire(pince,bougie)); - manette1.povUp().whileTrue(new L4(elevateur, pince)); - manette1.povRight().whileTrue(new L2(elevateur, pince)); - manette1.povLeft().whileTrue(new L3(elevateur, pince)); - manette1.povDown().whileTrue(new Depart(elevateur, pince)); + 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)); + manette1.leftTrigger().whileTrue(new CoralExpire(pince, bougie)); + manette1.rightTrigger().whileTrue(new CoralAlgueInspire(pince, bougie)); + manette1.rightBumper().whileTrue(new StationPince(pince, elevateur)); //manette2 - manette2.leftBumper().toggleOnTrue(new DepartPince(pince)); - manette2.a().whileTrue(new StationPince(pince,elevateur)); + manette2.leftTrigger().toggleOnTrue(new AlgueExpire(pince, bougie)); + } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/commands/CoralInspire.java b/src/main/java/frc/robot/commands/CoralInspire.java deleted file mode 100644 index fc249ba..0000000 --- a/src/main/java/frc/robot/commands/CoralInspire.java +++ /dev/null @@ -1,49 +0,0 @@ -// 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.Pince; -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 CoralInspire extends Command { - private Pince pince; - Bougie bougie; - /** Creates a new CoralAlgue. */ - public CoralInspire(Pince pince, Bougie bougie) { - this.pince = pince; - this.bougie = bougie; - addRequirements(pince,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(pince.emperagecoral()>8){ - pince.aspirecoral(0); - } - else{ - pince.aspirecoral(.5); - bougie.Bleu(); - } - } - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) { - pince.aspirecoral(0); - } - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/frc/robot/commands/StationPince.java b/src/main/java/frc/robot/commands/StationPince.java index f0c3ccf..1bd807d 100644 --- a/src/main/java/frc/robot/commands/StationPince.java +++ b/src/main/java/frc/robot/commands/StationPince.java @@ -28,6 +28,7 @@ public class StationPince extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { + pince.aspirecoral(0.5); if(pince.encodeurpivot()>=900 && pince.encodeurpivot()<=910){ pince.pivote(0); } @@ -52,6 +53,7 @@ public class StationPince extends Command { @Override public void end(boolean interrupted) { pince.pivote(0); + pince.aspirecoral(0); } // Returns true when the command should end. From 1f4111ef6dbb8495cee7d83339212a535b62778f Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Sat, 22 Feb 2025 11:41:37 -0500 Subject: [PATCH 37/43] id --- src/main/java/frc/robot/subsystems/Pince.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/Pince.java b/src/main/java/frc/robot/subsystems/Pince.java index 50bcfe7..22b50ed 100644 --- a/src/main/java/frc/robot/subsystems/Pince.java +++ b/src/main/java/frc/robot/subsystems/Pince.java @@ -13,10 +13,10 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Pince extends SubsystemBase { /** Creates a new Pince. */ public Pince() {} - final SparkMax coral = new SparkMax(1, MotorType.kBrushless); - final SparkMax pivoti = new SparkMax(2, MotorType.kBrushless); - final SparkMax algue1 = new SparkMax(4, MotorType.kBrushless); - final SparkMax algue2 = new SparkMax(5, MotorType.kBrushless); + final SparkMax coral = new SparkMax(20, MotorType.kBrushless); + final SparkMax pivoti = new SparkMax(14, MotorType.kBrushless); + final SparkMax algue1 = new SparkMax(16, MotorType.kBrushless); + final SparkMax algue2 = new SparkMax(19, MotorType.kBrushless); final DigitalInput limit6 = new DigitalInput(2); public void aspirecoral(double vitesse){ coral.set(vitesse); From 26d32e370713f7ed9e2773ee1c3c1a9db1e6046f Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Sat, 22 Feb 2025 12:48:56 -0500 Subject: [PATCH 38/43] amperage --- src/main/java/frc/robot/commands/AlgueExpire.java | 4 ++-- .../java/frc/robot/commands/CoralAlgueInspire.java | 2 +- src/main/java/frc/robot/commands/CoralExpire.java | 11 ++++++----- src/main/java/frc/robot/subsystems/Bougie.java | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/frc/robot/commands/AlgueExpire.java b/src/main/java/frc/robot/commands/AlgueExpire.java index ab177d4..49606d7 100644 --- a/src/main/java/frc/robot/commands/AlgueExpire.java +++ b/src/main/java/frc/robot/commands/AlgueExpire.java @@ -27,8 +27,8 @@ public class AlgueExpire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(pince.emperagealgue()>8){ - pince.aspirealgue(0); + if(pince.emperagealgue()>60){ + pince.aspirealgue(-0.5); } else{ pince.aspirealgue(-0.5); diff --git a/src/main/java/frc/robot/commands/CoralAlgueInspire.java b/src/main/java/frc/robot/commands/CoralAlgueInspire.java index 4697090..b64185b 100644 --- a/src/main/java/frc/robot/commands/CoralAlgueInspire.java +++ b/src/main/java/frc/robot/commands/CoralAlgueInspire.java @@ -28,7 +28,7 @@ public class CoralAlgueInspire extends Command { @Override public void execute() { pince.aspirecoral(-.5); - if(pince.emperagealgue()>8){ + if(pince.emperagealgue()>60){ pince.aspirealgue(0); bougie.Bleu(); } diff --git a/src/main/java/frc/robot/commands/CoralExpire.java b/src/main/java/frc/robot/commands/CoralExpire.java index 15ec3c8..0879f50 100644 --- a/src/main/java/frc/robot/commands/CoralExpire.java +++ b/src/main/java/frc/robot/commands/CoralExpire.java @@ -26,12 +26,13 @@ public class CoralExpire extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(pince.emperagecoral() > 8){ - pince.aspirecoral(0); - } - else{ + //if(pince.emperagecoral() > 60){ + // pince.aspirecoral(0); + //} + //else{ pince.aspirecoral(-.5); - bougie.Jaune();} + //bougie.Jaune(); + // } } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/subsystems/Bougie.java b/src/main/java/frc/robot/subsystems/Bougie.java index 98bdf49..02cd2a8 100644 --- a/src/main/java/frc/robot/subsystems/Bougie.java +++ b/src/main/java/frc/robot/subsystems/Bougie.java @@ -11,7 +11,7 @@ import com.ctre.phoenix.led.RainbowAnimation; import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Bougie extends SubsystemBase { - CANdle candle = new CANdle(5); + CANdle candle = new CANdle(23); CANdleConfiguration config = new CANdleConfiguration(); RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 64); /** Creates a new Bougie. */ From 7be5f8c2fcb5954e9d0915c0f8482fb7611d4166 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Sat, 22 Feb 2025 14:46:41 -0500 Subject: [PATCH 39/43] pince --- src/main/java/frc/robot/RobotContainer.java | 11 +++-- .../java/frc/robot/commands/DepartPince.java | 2 +- src/main/java/frc/robot/commands/L2.java | 4 +- src/main/java/frc/robot/commands/L3.java | 4 +- src/main/java/frc/robot/commands/L4.java | 4 +- .../java/frc/robot/commands/PinceManuel.java | 8 ++-- .../java/frc/robot/commands/PinceManuel2.java | 48 +++++++++++++++++++ .../java/frc/robot/commands/StationPince.java | 4 +- .../java/frc/robot/subsystems/Elevateur.java | 2 +- src/main/java/frc/robot/subsystems/Pince.java | 2 +- 10 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 src/main/java/frc/robot/commands/PinceManuel2.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 4bba20b..5ec0c08 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -20,6 +20,7 @@ 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.StationPince; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; @@ -32,14 +33,15 @@ public class RobotContainer { Pince pince = new Pince(); Elevateur elevateur = new Elevateur(); ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY); - PinceManuel pinceManuel = new PinceManuel(pince, manette2::getRightY); + PinceManuel pinceManuel = new PinceManuel(pince); + PinceManuel2 pinceManuel2 = new PinceManuel2(pince); public RobotContainer() { configureBindings(); elevateur.setDefaultCommand(new RunCommand(()->{ elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); }, elevateur)); pince.setDefaultCommand(new RunCommand(()->{ - pince.pivote(MathUtil.applyDeadband(manette2.getRightY(), 0.2)); + pince.pivote(MathUtil.applyDeadband(manette2.getRightY()/5, 0.2)); }, pince)); NamedCommands.registerCommand("Station",new StationPince(pince, elevateur)); NamedCommands.registerCommand("L4", new L4(elevateur, pince)); @@ -59,8 +61,9 @@ public class RobotContainer { manette1.rightTrigger().whileTrue(new CoralAlgueInspire(pince, bougie)); manette1.rightBumper().whileTrue(new StationPince(pince, elevateur)); //manette2 - manette2.leftTrigger().toggleOnTrue(new AlgueExpire(pince, bougie)); - + manette2.leftTrigger().whileTrue(new AlgueExpire(pince, bougie)); + manette2.povUp().whileTrue(new PinceManuel(pince)); + manette2.povDown().whileTrue(new PinceManuel2(pince)); } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/commands/DepartPince.java b/src/main/java/frc/robot/commands/DepartPince.java index a8c621e..12a69dd 100644 --- a/src/main/java/frc/robot/commands/DepartPince.java +++ b/src/main/java/frc/robot/commands/DepartPince.java @@ -29,7 +29,7 @@ public class DepartPince extends Command { pince.reset(); } else{ - pince.pivote(.5); + pince.pivote(.2); } } diff --git a/src/main/java/frc/robot/commands/L2.java b/src/main/java/frc/robot/commands/L2.java index 8cca282..abae929 100644 --- a/src/main/java/frc/robot/commands/L2.java +++ b/src/main/java/frc/robot/commands/L2.java @@ -42,10 +42,10 @@ public class L2 extends Command { } else if(pince.encodeurpivot()>=510){ - pince.pivote(-0.3); + pince.pivote(-0.2); } else{ - pince.pivote(0.3); + pince.pivote(0.2); } } diff --git a/src/main/java/frc/robot/commands/L3.java b/src/main/java/frc/robot/commands/L3.java index c92e442..8786079 100644 --- a/src/main/java/frc/robot/commands/L3.java +++ b/src/main/java/frc/robot/commands/L3.java @@ -41,10 +41,10 @@ public class L3 extends Command { pince.pivote(0); } else if(pince.encodeurpivot()>=710){ - pince.pivote(-0.5); + pince.pivote(-0.2); } else{ - pince.pivote(0.5); + pince.pivote(0.2); } } diff --git a/src/main/java/frc/robot/commands/L4.java b/src/main/java/frc/robot/commands/L4.java index f32bf81..7794fc3 100644 --- a/src/main/java/frc/robot/commands/L4.java +++ b/src/main/java/frc/robot/commands/L4.java @@ -41,10 +41,10 @@ public class L4 extends Command { pince.pivote(0); } else if(pince.encodeurpivot()>=810){ - pince.pivote(-0.5); + pince.pivote(-0.2); } else{ - pince.pivote(0.5); + pince.pivote(0.2); } } diff --git a/src/main/java/frc/robot/commands/PinceManuel.java b/src/main/java/frc/robot/commands/PinceManuel.java index b30eed5..164fd42 100644 --- a/src/main/java/frc/robot/commands/PinceManuel.java +++ b/src/main/java/frc/robot/commands/PinceManuel.java @@ -14,9 +14,11 @@ public class PinceManuel extends Command { private Pince pince; private DoubleSupplier doubleSupplier; /** Creates a new PinceManuel. */ - public PinceManuel(Pince pince, DoubleSupplier doubleSupplier) { + public PinceManuel(Pince pince + //, DoubleSupplier doubleSupplier + ) { this.pince = pince; - this.doubleSupplier = doubleSupplier; + //this.doubleSupplier = doubleSupplier; addRequirements(pince); // Use addRequirements() here to declare subsystem dependencies. } @@ -32,7 +34,7 @@ public class PinceManuel extends Command { pince.pivote(0); } else{ - pince.pivote(doubleSupplier.getAsDouble()); + pince.pivote(0.2); } } diff --git a/src/main/java/frc/robot/commands/PinceManuel2.java b/src/main/java/frc/robot/commands/PinceManuel2.java new file mode 100644 index 0000000..03edffa --- /dev/null +++ b/src/main/java/frc/robot/commands/PinceManuel2.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.commands; + +import java.util.function.DoubleSupplier; + +import edu.wpi.first.wpilibj2.command.Command; +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 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); + // 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() { + + pince.pivote(-0.2); + + } + + // 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/StationPince.java b/src/main/java/frc/robot/commands/StationPince.java index 1bd807d..9e11f99 100644 --- a/src/main/java/frc/robot/commands/StationPince.java +++ b/src/main/java/frc/robot/commands/StationPince.java @@ -33,10 +33,10 @@ public class StationPince extends Command { pince.pivote(0); } else if(pince.encodeurpivot()>=910){ - pince.pivote(-0.5); + pince.pivote(-0.2); } else{ - pince.pivote(0.5); + pince.pivote(0.2); } if(elevateur.position()>=400 && elevateur.position()<=410){ elevateur.vitesse(0); diff --git a/src/main/java/frc/robot/subsystems/Elevateur.java b/src/main/java/frc/robot/subsystems/Elevateur.java index 8caad7a..2efe36e 100644 --- a/src/main/java/frc/robot/subsystems/Elevateur.java +++ b/src/main/java/frc/robot/subsystems/Elevateur.java @@ -11,7 +11,7 @@ import com.revrobotics.spark.SparkLowLevel.MotorType; public class Elevateur extends SubsystemBase { /** Creates a new Elevateur. */ public Elevateur() {} - final SparkMax monte = new SparkMax(3, MotorType.kBrushless); + final SparkMax monte = new SparkMax(22, MotorType.kBrushless); final DigitalInput limit2 = new DigitalInput(1); public double position(){ return monte.getEncoder().getPosition(); diff --git a/src/main/java/frc/robot/subsystems/Pince.java b/src/main/java/frc/robot/subsystems/Pince.java index 22b50ed..2428fbd 100644 --- a/src/main/java/frc/robot/subsystems/Pince.java +++ b/src/main/java/frc/robot/subsystems/Pince.java @@ -17,7 +17,7 @@ public class Pince extends SubsystemBase { final SparkMax pivoti = new SparkMax(14, MotorType.kBrushless); final SparkMax algue1 = new SparkMax(16, MotorType.kBrushless); final SparkMax algue2 = new SparkMax(19, MotorType.kBrushless); - final DigitalInput limit6 = new DigitalInput(2); + final DigitalInput limit6 = new DigitalInput(0); public void aspirecoral(double vitesse){ coral.set(vitesse); } From 93e5bb0b467d9f4095f68161fab0fedf2dd04026 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 24 Feb 2025 18:15:32 -0500 Subject: [PATCH 40/43] pince mieux --- src/main/java/frc/robot/RobotContainer.java | 12 +++++- .../java/frc/robot/commands/Algue1Test.java | 41 ++++++++++++++++++ .../java/frc/robot/commands/Algue2Test.java | 41 ++++++++++++++++++ .../java/frc/robot/commands/CorailAspir.java | 42 +++++++++++++++++++ .../java/frc/robot/commands/CorailTest.java | 41 ++++++++++++++++++ .../frc/robot/commands/ElevateurManuel.java | 2 +- .../java/frc/robot/commands/PinceManuel.java | 18 ++++---- .../java/frc/robot/commands/PinceManuel2.java | 7 ++-- .../java/frc/robot/commands/StationPince.java | 8 ++-- src/main/java/frc/robot/subsystems/Pince.java | 6 +++ 10 files changed, 197 insertions(+), 21 deletions(-) create mode 100644 src/main/java/frc/robot/commands/Algue1Test.java create mode 100644 src/main/java/frc/robot/commands/Algue2Test.java create mode 100644 src/main/java/frc/robot/commands/CorailAspir.java create mode 100644 src/main/java/frc/robot/commands/CorailTest.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 5ec0c08..923373b 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -10,7 +10,11 @@ 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.Algue1Test; +import frc.robot.commands.Algue2Test; import frc.robot.commands.AlgueExpire; +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; @@ -38,7 +42,7 @@ public class RobotContainer { public RobotContainer() { configureBindings(); elevateur.setDefaultCommand(new RunCommand(()->{ - elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); + elevateur.vitesse(MathUtil.applyDeadband(-manette2.getLeftY(), 0.2)); }, elevateur)); pince.setDefaultCommand(new RunCommand(()->{ pince.pivote(MathUtil.applyDeadband(manette2.getRightY()/5, 0.2)); @@ -57,13 +61,17 @@ public class RobotContainer { manette1.b().whileTrue(new L2(elevateur,pince)); manette1.x().whileTrue(new L3(elevateur, pince)); manette1.y().whileTrue(new L4(elevateur, pince)); - manette1.leftTrigger().whileTrue(new CoralExpire(pince, bougie)); manette1.rightTrigger().whileTrue(new CoralAlgueInspire(pince, bougie)); manette1.rightBumper().whileTrue(new StationPince(pince, elevateur)); //manette2 manette2.leftTrigger().whileTrue(new AlgueExpire(pince, bougie)); manette2.povUp().whileTrue(new PinceManuel(pince)); manette2.povDown().whileTrue(new PinceManuel2(pince)); + manette2.a().whileTrue(new CorailAspir(pince)); + manette2.b().whileTrue(new CoralExpire(pince, bougie)); + manette2.povLeft().whileTrue(new Algue1Test(pince)); + manette2.povRight().whileTrue(new Algue2Test(pince)); + manette2.x().whileTrue(new CorailTest(pince)); } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/commands/Algue1Test.java b/src/main/java/frc/robot/commands/Algue1Test.java new file mode 100644 index 0000000..f79faa6 --- /dev/null +++ b/src/main/java/frc/robot/commands/Algue1Test.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; + +import edu.wpi.first.wpilibj2.command.Command; +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 Algue1Test extends Command { + private Pince pince; + /** Creates a new AlgueTest. */ + public Algue1Test(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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() { + pince.algue1Test(0.2); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.algue1Test(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/Algue2Test.java b/src/main/java/frc/robot/commands/Algue2Test.java new file mode 100644 index 0000000..5f0e758 --- /dev/null +++ b/src/main/java/frc/robot/commands/Algue2Test.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; + +import edu.wpi.first.wpilibj2.command.Command; +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 Algue2Test extends Command { + private Pince pince; + /** Creates a new AlgueTest. */ + public Algue2Test(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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() { + pince.algue2Test(0.2); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.algue2Test(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/CorailAspir.java b/src/main/java/frc/robot/commands/CorailAspir.java new file mode 100644 index 0000000..8199c75 --- /dev/null +++ b/src/main/java/frc/robot/commands/CorailAspir.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.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 CorailAspir extends Command { + /** Creates a new CorailAspir. */ + private Pince pince; + public CorailAspir(Pince pince) { + // Use addRequirements() here to declare subsystem dependencies. + this.pince = pince; + addRequirements(pince); + } + + // 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() { + + pince.aspirecoral(0.5); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.aspirecoral(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/CorailTest.java b/src/main/java/frc/robot/commands/CorailTest.java new file mode 100644 index 0000000..5e947d2 --- /dev/null +++ b/src/main/java/frc/robot/commands/CorailTest.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; + +import edu.wpi.first.wpilibj2.command.Command; +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 CorailTest extends Command { + private Pince pince; + /** Creates a new AlgueTest. */ + public CorailTest(Pince pince) { + this.pince = pince; + addRequirements(pince); + // 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() { + pince.aspirecoral(0.2); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + pince.aspirecoral(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/commands/ElevateurManuel.java b/src/main/java/frc/robot/commands/ElevateurManuel.java index 0a52684..ce00534 100644 --- a/src/main/java/frc/robot/commands/ElevateurManuel.java +++ b/src/main/java/frc/robot/commands/ElevateurManuel.java @@ -31,7 +31,7 @@ public class ElevateurManuel extends Command { if(elevateur.limit2()==true){ elevateur.vitesse(0); } - elevateur.vitesse(doubleSupplier.getAsDouble()); + elevateur.vitesse(doubleSupplier.getAsDouble()/5); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/PinceManuel.java b/src/main/java/frc/robot/commands/PinceManuel.java index 164fd42..acb39a3 100644 --- a/src/main/java/frc/robot/commands/PinceManuel.java +++ b/src/main/java/frc/robot/commands/PinceManuel.java @@ -3,16 +3,12 @@ // 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.Command; 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 PinceManuel extends Command { private Pince pince; - private DoubleSupplier doubleSupplier; /** Creates a new PinceManuel. */ public PinceManuel(Pince pince //, DoubleSupplier doubleSupplier @@ -30,17 +26,19 @@ public class PinceManuel extends Command { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(pince.position()){ - pince.pivote(0); - } - else{ + // if(pince.position()){ + // pince.pivote(0); + // } + // else{ pince.pivote(0.2); - } + // } } // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + pince.pivote(0); + } // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/commands/PinceManuel2.java b/src/main/java/frc/robot/commands/PinceManuel2.java index 03edffa..bf8d1e4 100644 --- a/src/main/java/frc/robot/commands/PinceManuel2.java +++ b/src/main/java/frc/robot/commands/PinceManuel2.java @@ -3,9 +3,6 @@ // 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.Command; import frc.robot.subsystems.Pince; @@ -38,7 +35,9 @@ public class PinceManuel2 extends Command { // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + pince.pivote(0); + } // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/commands/StationPince.java b/src/main/java/frc/robot/commands/StationPince.java index 9e11f99..59527d5 100644 --- a/src/main/java/frc/robot/commands/StationPince.java +++ b/src/main/java/frc/robot/commands/StationPince.java @@ -33,19 +33,19 @@ public class StationPince extends Command { pince.pivote(0); } else if(pince.encodeurpivot()>=910){ - pince.pivote(-0.2); + pince.pivote(0.2); } else{ - pince.pivote(0.2); + pince.pivote(-0.2); } if(elevateur.position()>=400 && elevateur.position()<=410){ elevateur.vitesse(0); } else if(elevateur.position()>=410){ - elevateur.vitesse(-0.3); + elevateur.vitesse(0.3); } else{ - elevateur.vitesse(.3); + elevateur.vitesse(-.3); } } diff --git a/src/main/java/frc/robot/subsystems/Pince.java b/src/main/java/frc/robot/subsystems/Pince.java index 2428fbd..3e04f48 100644 --- a/src/main/java/frc/robot/subsystems/Pince.java +++ b/src/main/java/frc/robot/subsystems/Pince.java @@ -42,6 +42,12 @@ public double emperagecoral(){ } public double emperagealgue(){ return algue1.getOutputCurrent(); +} +public void algue1Test(double vitesse){ + algue1.set(vitesse); +} +public void algue2Test(double vitesse){ + algue2.set(vitesse); } @Override public void periodic() { From 87c3abcb65b42fd47c494fa0cc7e0cd19613ca65 Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 24 Feb 2025 18:18:14 -0500 Subject: [PATCH 41/43] encodeurs --- src/main/java/frc/robot/subsystems/Elevateur.java | 5 +++++ src/main/java/frc/robot/subsystems/Pince.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/frc/robot/subsystems/Elevateur.java b/src/main/java/frc/robot/subsystems/Elevateur.java index 2efe36e..49928f3 100644 --- a/src/main/java/frc/robot/subsystems/Elevateur.java +++ b/src/main/java/frc/robot/subsystems/Elevateur.java @@ -4,7 +4,9 @@ package frc.robot.subsystems; +import edu.wpi.first.networktables.GenericEntry; import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; import com.revrobotics.spark.SparkMax; import com.revrobotics.spark.SparkLowLevel.MotorType; @@ -13,6 +15,9 @@ public class Elevateur extends SubsystemBase { public Elevateur() {} final SparkMax monte = new SparkMax(22, MotorType.kBrushless); final DigitalInput limit2 = new DigitalInput(1); + GenericEntry teb = Shuffleboard.getTab("teb") + .add("elevateur encodeur",position()) + .getEntry(); public double position(){ return monte.getEncoder().getPosition(); } diff --git a/src/main/java/frc/robot/subsystems/Pince.java b/src/main/java/frc/robot/subsystems/Pince.java index 3e04f48..8cea49b 100644 --- a/src/main/java/frc/robot/subsystems/Pince.java +++ b/src/main/java/frc/robot/subsystems/Pince.java @@ -7,7 +7,9 @@ package frc.robot.subsystems; import com.revrobotics.spark.SparkLowLevel.MotorType; import com.revrobotics.spark.SparkMax; +import edu.wpi.first.networktables.GenericEntry; import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Pince extends SubsystemBase { @@ -18,6 +20,9 @@ public class Pince extends SubsystemBase { final SparkMax algue1 = new SparkMax(16, MotorType.kBrushless); final SparkMax algue2 = new SparkMax(19, MotorType.kBrushless); final DigitalInput limit6 = new DigitalInput(0); + GenericEntry teb = Shuffleboard.getTab("teb") + .add("pince encodeur",encodeurpivot()) + .getEntry(); public void aspirecoral(double vitesse){ coral.set(vitesse); } From 5d84d83f7dd47c4032143843de65ffcd0c13b0df Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 24 Feb 2025 19:13:12 -0500 Subject: [PATCH 42/43] k --- src/main/java/frc/robot/RobotContainer.java | 4 +- src/main/java/frc/robot/commands/Depart.java | 12 +----- src/main/java/frc/robot/commands/L2.java | 6 +-- src/main/java/frc/robot/commands/L3.java | 8 ++-- src/main/java/frc/robot/commands/L4.java | 6 +-- src/main/java/frc/robot/commands/reset.java | 41 ++++++++++++++++++++ 6 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 src/main/java/frc/robot/commands/reset.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 923373b..9893719 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -26,6 +26,7 @@ import frc.robot.commands.L4; import frc.robot.commands.PinceManuel; import frc.robot.commands.PinceManuel2; import frc.robot.commands.StationPince; +import frc.robot.commands.reset; import frc.robot.subsystems.Elevateur; import frc.robot.subsystems.Pince; import frc.robot.subsystems.Bougie; @@ -42,7 +43,7 @@ public class RobotContainer { public RobotContainer() { configureBindings(); elevateur.setDefaultCommand(new RunCommand(()->{ - elevateur.vitesse(MathUtil.applyDeadband(-manette2.getLeftY(), 0.2)); + elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2)); }, elevateur)); pince.setDefaultCommand(new RunCommand(()->{ pince.pivote(MathUtil.applyDeadband(manette2.getRightY()/5, 0.2)); @@ -72,6 +73,7 @@ public class RobotContainer { manette2.povLeft().whileTrue(new Algue1Test(pince)); manette2.povRight().whileTrue(new Algue2Test(pince)); manette2.x().whileTrue(new CorailTest(pince)); + manette2.start().whileTrue(new reset(elevateur)); } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/commands/Depart.java b/src/main/java/frc/robot/commands/Depart.java index 4d53236..f5322dd 100644 --- a/src/main/java/frc/robot/commands/Depart.java +++ b/src/main/java/frc/robot/commands/Depart.java @@ -32,17 +32,9 @@ public class Depart extends Command { elevateur.reset(); } else{ - elevateur.vitesse(-.5); - } - if(pince.encodeurpivot()>=900 && pince.encodeurpivot()<=910){ - pince.pivote(0); - } - else if(pince.encodeurpivot()>=910){ - pince.pivote(-0.5); - } - else{ - pince.pivote(0.5); + elevateur.vitesse(.5); } + } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/L2.java b/src/main/java/frc/robot/commands/L2.java index abae929..0cc7048 100644 --- a/src/main/java/frc/robot/commands/L2.java +++ b/src/main/java/frc/robot/commands/L2.java @@ -32,7 +32,7 @@ public class L2 extends Command { elevateur.vitesse(0); } else if(elevateur.position()>=510){ - elevateur.vitesse(-0.3); + elevateur.vitesse(0.3); } else{ elevateur.vitesse(.3); @@ -42,10 +42,10 @@ public class L2 extends Command { } else if(pince.encodeurpivot()>=510){ - pince.pivote(-0.2); + pince.pivote(0.2); } else{ - pince.pivote(0.2); + pince.pivote(-0.2); } } diff --git a/src/main/java/frc/robot/commands/L3.java b/src/main/java/frc/robot/commands/L3.java index 8786079..a0fc189 100644 --- a/src/main/java/frc/robot/commands/L3.java +++ b/src/main/java/frc/robot/commands/L3.java @@ -32,19 +32,19 @@ public class L3 extends Command { elevateur.vitesse(0); } else if(elevateur.position()>=510){ - elevateur.vitesse(-0.5); + elevateur.vitesse(0.5); } else{ - elevateur.vitesse(.5); + elevateur.vitesse(-.5); } if(pince.encodeurpivot()>=700 && pince.encodeurpivot()<=710){ pince.pivote(0); } else if(pince.encodeurpivot()>=710){ - pince.pivote(-0.2); + pince.pivote(0.2); } else{ - pince.pivote(0.2); + pince.pivote(-0.2); } } diff --git a/src/main/java/frc/robot/commands/L4.java b/src/main/java/frc/robot/commands/L4.java index 7794fc3..5bec009 100644 --- a/src/main/java/frc/robot/commands/L4.java +++ b/src/main/java/frc/robot/commands/L4.java @@ -32,7 +32,7 @@ public class L4 extends Command { elevateur.vitesse(0); } else if(elevateur.position()>=810){ - elevateur.vitesse(-0.5); + elevateur.vitesse(0.5); } else{ elevateur.vitesse(.5); @@ -41,10 +41,10 @@ public class L4 extends Command { pince.pivote(0); } else if(pince.encodeurpivot()>=810){ - pince.pivote(-0.2); + pince.pivote(0.2); } else{ - pince.pivote(0.2); + pince.pivote(-0.2); } } diff --git a/src/main/java/frc/robot/commands/reset.java b/src/main/java/frc/robot/commands/reset.java new file mode 100644 index 0000000..f49fe97 --- /dev/null +++ b/src/main/java/frc/robot/commands/reset.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; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Elevateur; + + + +/* 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 reset extends Command { + /** Creates a new reset. */ + private Elevateur elevateur; + public reset(Elevateur elevateur) { + // Use addRequirements() here to declare subsystem dependencies. + this.elevateur = elevateur; + addRequirements(elevateur); + } + + // 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() { + elevateur.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; + } +} From 9f83b61c466ded0633b93842a5b399242b084cdb Mon Sep 17 00:00:00 2001 From: Antoine PerreaultE Date: Mon, 24 Feb 2025 19:52:02 -0500 Subject: [PATCH 43/43] manuel --- src/main/java/frc/robot/commands/ElevateurManuel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/commands/ElevateurManuel.java b/src/main/java/frc/robot/commands/ElevateurManuel.java index ce00534..2eb17ab 100644 --- a/src/main/java/frc/robot/commands/ElevateurManuel.java +++ b/src/main/java/frc/robot/commands/ElevateurManuel.java @@ -31,7 +31,7 @@ public class ElevateurManuel extends Command { if(elevateur.limit2()==true){ elevateur.vitesse(0); } - elevateur.vitesse(doubleSupplier.getAsDouble()/5); + elevateur.vitesse(doubleSupplier.getAsDouble()/7); } // Called once the command ends or is interrupted.