pid d`édouard
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package frc.robot.commands.Elevateur;
|
||||
import edu.wpi.first.math.controller.PIDController;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import frc.robot.subsystems.Elevateur;
|
||||
import frc.robot.subsystems.Pince;
|
||||
@@ -11,6 +12,8 @@ import frc.robot.subsystems.Pince;
|
||||
public class L2 extends Command {
|
||||
private Elevateur elevateur;
|
||||
private Pince pince;
|
||||
private PIDController pidController;
|
||||
private double output;
|
||||
/** Creates a new L2. */
|
||||
public L2(Elevateur elevateur,Pince pince) {
|
||||
this.elevateur = elevateur;
|
||||
@@ -21,20 +24,24 @@ public class L2 extends Command {
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {}
|
||||
public void initialize() {
|
||||
pidController = new PIDController(0.025, 0.00125,0.001, 0.01);
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
if(pince.encodeurpivot()>=15 && pince.encodeurpivot()<=16.5){
|
||||
pince.pivote(0);
|
||||
}
|
||||
else if(pince.encodeurpivot()>=15){
|
||||
pince.pivote(-0.2);
|
||||
}
|
||||
else{
|
||||
pince.pivote(0.1);
|
||||
}
|
||||
output = pidController.calculate(pince.encodeurpivot(),15);
|
||||
pince.pivote(output);
|
||||
// if(pince.encodeurpivot()>=15 && pince.encodeurpivot()<=16.5){
|
||||
// pince.pivote(0);
|
||||
// }
|
||||
// else if(pince.encodeurpivot()>=15){
|
||||
// pince.pivote(-0.2);
|
||||
// }
|
||||
// else{
|
||||
// pince.pivote(0.1);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user