This commit is contained in:
Antoine PerreaultE
2026-03-26 17:49:01 -04:00
21 changed files with 806 additions and 145 deletions

View File

@@ -4,10 +4,8 @@
package frc.robot.commands;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Balayeuse;
import frc.robot.subsystems.Led;
/* 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 Aspirer extends Command {

View File

@@ -7,9 +7,7 @@ package frc.robot.commands;
import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Balayeuse;
import frc.robot.subsystems.Lanceur;
import frc.robot.subsystems.Led;
import frc.robot.subsystems.Limelight3G;
/* 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 */
@@ -18,15 +16,12 @@ public class Lancer extends Command {
private PIDController pidController;
private Limelight3G limeLight3G;
private Timer timer;
private double temp;
/** Creates a new Lancer. */
public Lancer(Lanceur lanceur, Limelight3G limeLight3G) {
this.lanceur = lanceur;
this.timer = new Timer();
this.limeLight3G = new Limelight3G();
addRequirements(lanceur, limeLight3G);
this.temp = 0;
// Use addRequirements() here to declare subsystem dependencies.
}
@@ -34,8 +29,7 @@ public class Lancer extends Command {
@Override
public void initialize() {
pidController = new PIDController(0.0007, 0,0, 0.001);
timer.reset();
temp = lanceur.Amp();
timer.reset();
}
// Called every time the scheduler runs while the command is scheduled.

View File

@@ -7,8 +7,6 @@ package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import frc.robot.subsystems.Balayeuse;
import frc.robot.subsystems.Lanceur;
import frc.robot.subsystems.Led;
import frc.robot.subsystems.LimeLight3;
import frc.robot.subsystems.Limelight3G;

View File

@@ -5,25 +5,22 @@
package frc.robot.commands;
import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Lanceur;
import frc.robot.subsystems.LimeLight3;
import frc.robot.subsystems.Limelight3G;
/* 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 LancerBaseVitesse extends Command {
private Lanceur lanceur;
private PIDController pidController;
private Limelight3G limeLight3G;
private Timer timer;
private double temp;
double tempsDebut = 0;
/** Creates a new Lancer. */
public LancerBaseVitesse(Lanceur lanceur, Limelight3G limeLight3G) {
public LancerBaseVitesse(Lanceur lanceur) {
this.lanceur = lanceur;
this.timer = new Timer();
this.limeLight3G = new Limelight3G();
addRequirements(lanceur, limeLight3G);
addRequirements(lanceur);
//this.temp = 0;
// Use addRequirements() here to declare subsystem dependencies.
}
@@ -34,38 +31,18 @@ public class LancerBaseVitesse extends Command {
pidController = new PIDController(0.0007, 0,0, 0.001);
timer.reset();
timer.start();
//temp = lanceur.Amp();
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
// int nbFois = 0;
// double moyenneAmp = 0;
// if(timer.get() < 3){
// nbFois++;
// moyenneAmp += balayeuse.Amp() / nbFois;
// }
// else{
// nbFois++;
// moyenneAmp -= temp;
// moyenneAmp += balayeuse.Amp() / nbFois;
// temp = balayeuse.Amp();
// }
// if(moyenneAmp > 30 && nbFois > 10){
// timer.reset();
// balayeuse.Balayer(0.5);
// led.Jaune2();
// }
// else{
System.out.println(DriverStation.getMatchTime());
double vitesse = lanceur.vitesseDemander();
double output = pidController.calculate(lanceur.Vitesse(),vitesse);
lanceur.Lancer(output);
if(timer.get() >1){
if(timer.get() > 1){
lanceur.Demeler(1);
}
// }
}
}

View File

@@ -9,7 +9,6 @@ import com.ctre.phoenix6.swerve.SwerveRequest;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.generated.TunerConstants;
import frc.robot.subsystems.CommandSwerveDrivetrain;
@@ -20,7 +19,6 @@ import java.util.Optional;
/* 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 Limelighter extends Command {
Timer timer;
Limelight3G limelight3g;
CommandSwerveDrivetrain drivetrain;
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
@@ -39,20 +37,18 @@ public class Limelighter extends Command {
this.limelight3g = limelight3g;
this.drivetrain = drivetrain;
addRequirements(drivetrain, limelight3g);
timer = new Timer();
// Use addRequirements() here to declare subsystem dependencies.
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
timer.reset();
}
public void initialize() {}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
double[] BotPose = new double[6];
System.out.println("e");
if (limelight3g.getV()) {
if(alliance.get() == Alliance.Blue){
BotPose = limelight3g.getBotPoseBlue();
@@ -72,12 +68,6 @@ public class Limelighter extends Command {
drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
System.out.println(calcul);
if (calcul < 0.2 && calcul > -0.2) {
// timer.start();
// } else {
// timer.reset();
// }
// } else {
// timer.stop();
drivetrain.setControl(drive.withRotationalRate(0));
}
}
@@ -91,7 +81,6 @@ public class Limelighter extends Command {
@Override
public void end(boolean interrupted) {
drivetrain.setControl(drive.withRotationalRate(0));
timer.stop();
}
// Returns true when the command should end.

View File

@@ -28,7 +28,6 @@ public class RetourMilieuDroite extends Command {
double x;
double y;
double angle;
double force;
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
Pigeon2 pigeon2;
@@ -54,16 +53,10 @@ public class RetourMilieuDroite extends Command {
if(angle < 0){
angle = angle + 360;
}
double[] BotPose = new double[6];
BotPose = limelight3g.getBotPoseBlue();
botx = BotPose[0];
boty = BotPose[1];
if(alliance.get() == Alliance.Blue){
y = 0.639;
x = 2.305;
angle = 0;
force = 0.5;
if(limelight3g.getV()){
if(pigeon2.getYaw().getValueAsDouble() >355 || pigeon2.getYaw().getValueAsDouble() < 5){
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
@@ -93,34 +86,16 @@ public class RetourMilieuDroite extends Command {
y = 7.380;
x = 13.963;
angle = 180;
force = -0.5;
if(limelight3g.getV()){
if(pigeon2.getYaw().getValueAsDouble() >175 && pigeon2.getYaw().getValueAsDouble() < 185){
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0));
}
else{
if(botx > 10){
drivetrain.setControl(drive.withVelocityX(y-boty));
}
else{
drivetrain.setControl(drive.withVelocityX(y-boty).withVelocityY(x-botx));
}
}
}
else{
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
drivetrain.setControl(drive.withRotationalRate(0.5));
}
else if(pigeon2.getYaw().getValueAsDouble() >=180){
drivetrain.setControl(drive.withRotationalRate(-0.5));
}
}
}
}
}
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
drivetrain.setControl(drive.withRotationalRate(0.5));
}
else if(pigeon2.getYaw().getValueAsDouble() >180){
drivetrain.setControl(drive.withRotationalRate(-0.5));
}
}
}
// Called once the command ends or is interrupted.
@Override

View File

@@ -6,7 +6,6 @@ package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Balayeuse;
import frc.robot.subsystems.Lanceur;
/* 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 ModeOposerBalayeuse extends Command {
private Balayeuse balayeuse;