touche, amperage, distance
This commit is contained in:
		@@ -11,10 +11,12 @@ 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, Pince pince) {
 | 
			
		||||
    this.elevateur = elevateur;
 | 
			
		||||
    addRequirements(elevateur);
 | 
			
		||||
    this.pince = pince;
 | 
			
		||||
    addRequirements(elevateur, pince);
 | 
			
		||||
    // Use addRequirements() here to declare subsystem dependencies.
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -25,20 +27,27 @@ public class Depart extends Command {
 | 
			
		||||
  // Called every time the scheduler runs while the command is scheduled.
 | 
			
		||||
  @Override
 | 
			
		||||
  public void execute() {
 | 
			
		||||
    if(pince.position()){
 | 
			
		||||
      pince.pivote(0);
 | 
			
		||||
      pince.reset();
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
      pince.pivote(-0.2);
 | 
			
		||||
    }
 | 
			
		||||
    if(elevateur.limit2()==true){
 | 
			
		||||
      elevateur.vitesse(0);
 | 
			
		||||
      elevateur.reset();
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
      elevateur.vitesse(.3);
 | 
			
		||||
      elevateur.vitesse(.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.
 | 
			
		||||
 
 | 
			
		||||
@@ -26,11 +26,11 @@ public class L2 extends Command {
 | 
			
		||||
  // Called every time the scheduler runs while the command is scheduled.
 | 
			
		||||
  @Override
 | 
			
		||||
  public void execute() {
 | 
			
		||||
     if(pince.encodeurpivot()>=15.6 && pince.encodeurpivot()<=16){
 | 
			
		||||
     if(pince.encodeurpivot()>=16 && pince.encodeurpivot()<=17){
 | 
			
		||||
       pince.pivote(0);
 | 
			
		||||
     
 | 
			
		||||
     }
 | 
			
		||||
     else if(pince.encodeurpivot()>=16){
 | 
			
		||||
     else if(pince.encodeurpivot()>=17){
 | 
			
		||||
       pince.pivote(-0.1);
 | 
			
		||||
     }
 | 
			
		||||
     else{
 | 
			
		||||
 
 | 
			
		||||
@@ -30,22 +30,23 @@ public class L3 extends Command {
 | 
			
		||||
  public void execute() {
 | 
			
		||||
    if(elevateur.position()<=elevateur.encodeurelevateurL3bas() && elevateur.position()>=elevateur.encodeurelevateurL3haut()){
 | 
			
		||||
      elevateur.vitesse(0);
 | 
			
		||||
    }
 | 
			
		||||
        pince.pivote(-0.15);
 | 
			
		||||
        if(pince.encodeurpivot()>=20 && pince.encodeurpivot()<=21){
 | 
			
		||||
          pince.pivote(0);
 | 
			
		||||
        }
 | 
			
		||||
        else if(pince.encodeurpivot()>=20){
 | 
			
		||||
          pince.pivote(-0.15);
 | 
			
		||||
        }
 | 
			
		||||
        else{
 | 
			
		||||
          pince.pivote(0.15);
 | 
			
		||||
        }
 | 
			
		||||
  }
 | 
			
		||||
    else if(elevateur.position()>=elevateur.encodeurelevateurL3bas()){
 | 
			
		||||
      elevateur.vitesse(-0.5);
 | 
			
		||||
      elevateur.vitesse(-0.7);
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
      elevateur.vitesse(0.5);
 | 
			
		||||
      elevateur.vitesse(0.25);
 | 
			
		||||
    }
 | 
			
		||||
     if(pince.encodeurpivot()>=15.6 && pince.encodeurpivot()<=16){
 | 
			
		||||
       pince.pivote(0);
 | 
			
		||||
     }
 | 
			
		||||
     else if(pince.encodeurpivot()>=16){
 | 
			
		||||
       pince.pivote(-0.1);
 | 
			
		||||
     }
 | 
			
		||||
     else{
 | 
			
		||||
       pince.pivote(0.1);
 | 
			
		||||
     }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Called once the command ends or is interrupted.
 | 
			
		||||
 
 | 
			
		||||
@@ -28,24 +28,24 @@ public class L4 extends Command {
 | 
			
		||||
  @Override
 | 
			
		||||
  public void execute() {
 | 
			
		||||
    if(elevateur.position()<=elevateur.encodeurelevateurL4bas() && elevateur.position()>=elevateur.encodeurelevateurL4haut()){
 | 
			
		||||
      elevateur.vitesse(0);
 | 
			
		||||
      
 | 
			
		||||
      elevateur.vitesse(0); 
 | 
			
		||||
      pince.pivote(-0.1);
 | 
			
		||||
      if(pince.encodeurpivot()>=22 && pince.encodeurpivot()<=23){
 | 
			
		||||
        pince.pivote(0);
 | 
			
		||||
      }
 | 
			
		||||
      else if(pince.encodeurpivot()>=22){
 | 
			
		||||
        pince.pivote(-0.15);
 | 
			
		||||
      }
 | 
			
		||||
      else{
 | 
			
		||||
        pince.pivote(0.15);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    else if(elevateur.position()>=elevateur.encodeurelevateurL4bas()){
 | 
			
		||||
      elevateur.vitesse(-0.5);
 | 
			
		||||
      elevateur.vitesse(-0.7);
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
      elevateur.vitesse(.5);
 | 
			
		||||
      elevateur.vitesse(.25);
 | 
			
		||||
    }
 | 
			
		||||
     if(pince.encodeurpivot()>=21.76 && pince.encodeurpivot()<=22.3){
 | 
			
		||||
       pince.pivote(0);
 | 
			
		||||
     }
 | 
			
		||||
     else if(pince.encodeurpivot()>=22.3){
 | 
			
		||||
       pince.pivote(-0.1);
 | 
			
		||||
     }
 | 
			
		||||
     else{
 | 
			
		||||
       pince.pivote(0.1);
 | 
			
		||||
     }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Called once the command ends or is interrupted.
 | 
			
		||||
 
 | 
			
		||||
@@ -28,26 +28,37 @@ public class StationPince extends Command {
 | 
			
		||||
 | 
			
		||||
  // Called when the command is initially scheduled.
 | 
			
		||||
  @Override
 | 
			
		||||
  public void initialize() {}
 | 
			
		||||
  public void initialize() {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Called every time the scheduler runs while the command is scheduled.
 | 
			
		||||
  @Override
 | 
			
		||||
  public void execute() {
 | 
			
		||||
    if(pince.emperagecoral() > 60){
 | 
			
		||||
      pince.aspirecoral(0);bougie.Bleu();
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
      pince.aspirecoral(0.5);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if(pince.encodeurpivot()<=11 && pince.encodeurpivot()>=12.6){
 | 
			
		||||
      pince.pivote(0);
 | 
			
		||||
    }
 | 
			
		||||
    else if(pince.encodeurpivot()>=9.8){
 | 
			
		||||
      pince.pivote(-0.1);
 | 
			
		||||
    if(pince.emperagecoral() >= 12){     
 | 
			
		||||
      pince.x = true;
 | 
			
		||||
    }
 | 
			
		||||
    if(pince.x){
 | 
			
		||||
      pince.aspirecoral(0);
 | 
			
		||||
      bougie.Bleu();
 | 
			
		||||
      pince.pivote(-0.2);
 | 
			
		||||
      if(pince.position()){
 | 
			
		||||
        pince.pivote(0);
 | 
			
		||||
      }
 | 
			
		||||
     }
 | 
			
		||||
    else{
 | 
			
		||||
      pince.pivote(0.1);
 | 
			
		||||
      pince.aspirecoral(0.1);
 | 
			
		||||
    }
 | 
			
		||||
    if (!pince.x){
 | 
			
		||||
      if(pince.encodeurpivot()>=10.5 && pince.encodeurpivot()<=11.5){
 | 
			
		||||
        pince.pivote(0);
 | 
			
		||||
      }
 | 
			
		||||
      else if(pince.encodeurpivot()>=11){
 | 
			
		||||
        pince.pivote(-0.1);
 | 
			
		||||
      }
 | 
			
		||||
      else{
 | 
			
		||||
        pince.pivote(0.1);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -56,6 +67,7 @@ public class StationPince extends Command {
 | 
			
		||||
  public void end(boolean interrupted) {
 | 
			
		||||
    pince.pivote(0);
 | 
			
		||||
    pince.aspirecoral(0);
 | 
			
		||||
    pince.x =false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Returns true when the command should end.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										49
									
								
								src/main/java/frc/robot/commands/Elevateur/balonL2.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								src/main/java/frc/robot/commands/Elevateur/balonL2.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
// Copyright (c) FIRST and other WPILib contributors.
 | 
			
		||||
// Open Source Software; you can modify and/or share it under the terms of
 | 
			
		||||
// the WPILib BSD license file in the root directory of this project.
 | 
			
		||||
 | 
			
		||||
package frc.robot.commands.Elevateur;
 | 
			
		||||
 | 
			
		||||
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 balonL2 extends Command {
 | 
			
		||||
  private Elevateur elevateur;
 | 
			
		||||
  /** Creates a new L2. */
 | 
			
		||||
  public balonL2(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()<=-2 && elevateur.position()>=-2.2){
 | 
			
		||||
      elevateur.vitesse(0);
 | 
			
		||||
    }
 | 
			
		||||
    else if(elevateur.position()>= -1.95){
 | 
			
		||||
      elevateur.vitesse(-0.7);
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
      elevateur.vitesse(0.25);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // 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;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										49
									
								
								src/main/java/frc/robot/commands/Elevateur/balonL3.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								src/main/java/frc/robot/commands/Elevateur/balonL3.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
// Copyright (c) FIRST and other WPILib contributors.
 | 
			
		||||
// Open Source Software; you can modify and/or share it under the terms of
 | 
			
		||||
// the WPILib BSD license file in the root directory of this project.
 | 
			
		||||
 | 
			
		||||
package frc.robot.commands.Elevateur;
 | 
			
		||||
 | 
			
		||||
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 balonL3 extends Command {
 | 
			
		||||
  private Elevateur elevateur;
 | 
			
		||||
  /** Creates a new L2. */
 | 
			
		||||
  public balonL3(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()<=-4 && elevateur.position()>=-4.1){
 | 
			
		||||
      elevateur.vitesse(0);
 | 
			
		||||
    }
 | 
			
		||||
    else if(elevateur.position()>= -4){
 | 
			
		||||
      elevateur.vitesse(-0.7);
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
      elevateur.vitesse(0.25);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // 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;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -49,8 +49,8 @@ public class AprilTag3G extends Command {
 | 
			
		||||
    if(limelight3g.getV() == true){
 | 
			
		||||
      drivetrain.setControl(drive.
 | 
			
		||||
      withRotationalRate(-a/7).
 | 
			
		||||
      withVelocityX(x.getAsDouble()).
 | 
			
		||||
      withVelocityY(y.getAsDouble()));  
 | 
			
		||||
      withVelocityY(x.getAsDouble()).
 | 
			
		||||
      withVelocityX(-y.getAsDouble()));  
 | 
			
		||||
       System.out.println(a/7);
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
@@ -73,6 +73,6 @@ public class AprilTag3G extends Command {
 | 
			
		||||
  // Returns true when the command should end.
 | 
			
		||||
  @Override
 | 
			
		||||
  public boolean isFinished() {
 | 
			
		||||
    return limelight3g.getX()<1 && limelight3g.getX()>-1;
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,6 @@ public class Algue_inspire extends Command {
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
      pince.aspirealgue(0.5);
 | 
			
		||||
      
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ public class DepartPince extends Command {
 | 
			
		||||
      pince.reset();
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
      pince.pivote(.2);
 | 
			
		||||
      pince.pivote(-0.2);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ public class BalayeuseBas extends Command {
 | 
			
		||||
  // Called every time the scheduler runs while the command is scheduled.
 | 
			
		||||
  @Override
 | 
			
		||||
  public void execute() {
 | 
			
		||||
  requin.rotationer(0.5);
 | 
			
		||||
  requin.rotationer(0.2);
 | 
			
		||||
  }
 | 
			
		||||
  // Called once the command ends or is interrupted.
 | 
			
		||||
  @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -29,28 +29,26 @@ public class BalayeuseCoral extends Command {
 | 
			
		||||
  public void execute() {
 | 
			
		||||
     if(requin.encodeur()<=1200 &&  requin.encodeur()>=1025){
 | 
			
		||||
       requin.rotationer(0);
 | 
			
		||||
      if(requin.amp()>60){
 | 
			
		||||
      requin.balaye(0);
 | 
			
		||||
       bougie.Vert();
 | 
			
		||||
       if(requin.enHaut()){
 | 
			
		||||
        requin.rotationer(0);
 | 
			
		||||
       }
 | 
			
		||||
        else{
 | 
			
		||||
          requin.rotationer(-0.5);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
     else{
 | 
			
		||||
      if(requin.amp()>=12){
 | 
			
		||||
        requin.xRequin = true;
 | 
			
		||||
      }
 | 
			
		||||
      if(requin.xRequin){
 | 
			
		||||
        requin.balaye(0);
 | 
			
		||||
        bougie.Vert();
 | 
			
		||||
      }
 | 
			
		||||
      else{
 | 
			
		||||
       requin.balaye(0.5);
 | 
			
		||||
     }
 | 
			
		||||
     }
 | 
			
		||||
     else if(requin.encodeur()>=1200){
 | 
			
		||||
     requin.rotationer(-0.5);
 | 
			
		||||
     }
 | 
			
		||||
     else{
 | 
			
		||||
       requin.rotationer(0.5);
 | 
			
		||||
     }
 | 
			
		||||
    
 | 
			
		||||
  }
 | 
			
		||||
      }
 | 
			
		||||
      }
 | 
			
		||||
      if (!requin.xRequin) {
 | 
			
		||||
        if(requin.encodeur()>=1200){
 | 
			
		||||
          requin.rotationer(-0.5);
 | 
			
		||||
          }
 | 
			
		||||
          else{
 | 
			
		||||
            requin.rotationer(0.5);
 | 
			
		||||
          }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  // Called once the command ends or is interrupted.
 | 
			
		||||
  @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,14 @@ public class exspire extends Command {
 | 
			
		||||
  // Called every time the scheduler runs while the command is scheduled.
 | 
			
		||||
  @Override
 | 
			
		||||
  public void execute() {
 | 
			
		||||
   requin.balaye(0.5);
 | 
			
		||||
   if(requin.amp()> 15)
 | 
			
		||||
   {
 | 
			
		||||
    requin.balaye(0.5);
 | 
			
		||||
   }
 | 
			
		||||
   else{
 | 
			
		||||
    bougie.Rouge();
 | 
			
		||||
    requin.balaye(0.5);
 | 
			
		||||
   }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Called once the command ends or is interrupted.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user