Merge branch 'main' of https://git.demerso.net/PLS5618/pratique-2025
This commit is contained in:
		
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -6,19 +6,20 @@ package frc.robot.Commands;
 | 
			
		||||
 | 
			
		||||
import edu.wpi.first.wpilibj2.command.Command;
 | 
			
		||||
import frc.robot.Subsystems.Drive;
 | 
			
		||||
import frc.robot.Subsystems.Lanceur;
 | 
			
		||||
import frc.robot.Subsystems.Limelight3G;
 | 
			
		||||
 | 
			
		||||
public class FollowAprilTag extends Command {
 | 
			
		||||
 | 
			
		||||
  private Limelight3G enlignement;
 | 
			
		||||
  private Drive drive;
 | 
			
		||||
  private Lanceur lanceur;
 | 
			
		||||
  /** Creates a new Limelight3g. */
 | 
			
		||||
  public FollowAprilTag(Limelight3G enlignement, Drive drive) {
 | 
			
		||||
  public FollowAprilTag(Limelight3G enlignement, Lanceur lanceur) {
 | 
			
		||||
    // Use addRequirements() here to declare subsystem dependencies.
 | 
			
		||||
    this.drive = drive;
 | 
			
		||||
    this.lanceur = lanceur;
 | 
			
		||||
    this.enlignement = enlignement;
 | 
			
		||||
 | 
			
		||||
    addRequirements(drive, enlignement);
 | 
			
		||||
    addRequirements(lanceur, enlignement);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Called when the command is initially scheduled.
 | 
			
		||||
@@ -31,11 +32,11 @@ public class FollowAprilTag extends Command {
 | 
			
		||||
 | 
			
		||||
    if (enlignement.getv()==1)
 | 
			
		||||
    {
 | 
			
		||||
      drive.drive(0, 0, enlignement.getx()/30);
 | 
			
		||||
      lanceur.tourelRotation(0,0, enlignement.getx()/30);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      drive.drive(0, 0, 0);
 | 
			
		||||
      lanceur.tourelRotation(0, 0, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
@@ -43,7 +44,7 @@ public class FollowAprilTag extends Command {
 | 
			
		||||
  // Called once the command ends or is interrupted.
 | 
			
		||||
  @Override
 | 
			
		||||
  public void end(boolean interrupted) {
 | 
			
		||||
    drive.drive(0, 0, 0);
 | 
			
		||||
    lanceur.tourelRotation(0, 0, 0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Returns true when the command should end.
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ public class Lancer extends Command {
 | 
			
		||||
  // Called when the command is initially scheduled.
 | 
			
		||||
  @Override
 | 
			
		||||
  public void initialize() {
 | 
			
		||||
    lanceur.setPID(0, 0, 0);
 | 
			
		||||
    lanceur.PIDlanceur(0, 0, 0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Called every time the scheduler runs while the command is scheduled.
 | 
			
		||||
 
 | 
			
		||||
@@ -34,20 +34,28 @@ public class Lanceur extends SubsystemBase {
 | 
			
		||||
    lanceur1.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
 | 
			
		||||
    lanceur2.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative);
 | 
			
		||||
    lanceur1.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1);
 | 
			
		||||
    lanceur2.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1);
 | 
			
		||||
    
 | 
			
		||||
  }
 | 
			
		||||
  public void masterslave(){
 | 
			
		||||
    lanceur2.follow(lanceur1);
 | 
			
		||||
    lanceur2.setInverted(true);
 | 
			
		||||
  }
 | 
			
		||||
  public void lance(double vitesse){
 | 
			
		||||
    lanceur1.set(vitesse);
 | 
			
		||||
    lanceur2.set(-vitesse);
 | 
			
		||||
  }
 | 
			
		||||
  public void lance(){
 | 
			
		||||
    lance(vitesse.getDouble(0.2));
 | 
			
		||||
  }
 | 
			
		||||
  public void tourelRotation(double vitesse){
 | 
			
		||||
    tourelle.set(vitesse);
 | 
			
		||||
  public void tourelRotation(double x, double y, double rotation){
 | 
			
		||||
    tourelle.set(rotation);
 | 
			
		||||
  }
 | 
			
		||||
  public void setPID(double p, double i, int d) {
 | 
			
		||||
  public double distancetourel(){
 | 
			
		||||
    return(tourelle.getEncoder().getPosition());
 | 
			
		||||
  }
 | 
			
		||||
  public void PIDlanceur(double p, double i, double d) {
 | 
			
		||||
   lanceur1.config_kP(0, p);
 | 
			
		||||
   lanceur1.config_kI(0, i);
 | 
			
		||||
   lanceur1.config_kD(0, d);
 | 
			
		||||
  }
 | 
			
		||||
  @Override
 | 
			
		||||
  public void periodic() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user