2023-02-06 19:14:41 -05:00
|
|
|
// 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.bras;
|
|
|
|
|
|
|
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
2023-02-13 19:51:56 -05:00
|
|
|
import frc.robot.subsystems.bras.BrasTelescopique;
|
|
|
|
import frc.robot.subsystems.bras.Pivot;
|
2023-02-06 19:14:41 -05:00
|
|
|
|
|
|
|
public class PivoteBrasMilieux extends CommandBase {
|
2023-02-13 19:51:56 -05:00
|
|
|
private BrasTelescopique brasTelescopique;
|
|
|
|
private Pivot pivot;
|
2023-02-06 19:14:41 -05:00
|
|
|
/** Creates a new PivoteBrasMilieux. */
|
2023-02-13 19:51:56 -05:00
|
|
|
public PivoteBrasMilieux(BrasTelescopique brasTelescopique, Pivot pivot) {
|
|
|
|
this.brasTelescopique = brasTelescopique;
|
|
|
|
this.pivot = pivot;
|
2023-02-06 19:14:41 -05:00
|
|
|
// Use addRequirements() here to declare subsystem dependencies.
|
2023-02-13 19:51:56 -05:00
|
|
|
addRequirements(brasTelescopique);
|
|
|
|
addRequirements(pivot);
|
2023-02-06 19:14:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Called when the command is initially scheduled.
|
|
|
|
@Override
|
|
|
|
public void initialize() {}
|
|
|
|
|
|
|
|
// Called every time the scheduler runs while the command is scheduled.
|
|
|
|
@Override
|
2023-02-13 19:51:56 -05:00
|
|
|
public void execute() {
|
|
|
|
if(brasTelescopique.distance()<10){
|
|
|
|
brasTelescopique.AvanceRecule(0.5);
|
|
|
|
}
|
|
|
|
else if(brasTelescopique.distance()>11) {
|
|
|
|
brasTelescopique.AvanceRecule(-0.5);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
brasTelescopique.AvanceRecule(0);
|
|
|
|
}
|
|
|
|
if (pivot.distance()<10){
|
|
|
|
pivot.monteDescendre(0.5);
|
|
|
|
}
|
|
|
|
else if(pivot.distance()>11) {
|
|
|
|
pivot.monteDescendre(-0.5);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
pivot.monteDescendre(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-06 19:14:41 -05:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|