This commit is contained in:
samuel desharnais 2023-02-13 19:51:56 -05:00
parent 1dc859cb74
commit 77b894194e
3 changed files with 92 additions and 6 deletions

View File

@ -4,12 +4,22 @@
package frc.robot.commands.bras;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pivot;
public class PivoteBrasBas extends CommandBase {
private BrasTelescopique brasTelescopique;
private Pivot pivot;
/** Creates a new PivoteBrasBas. */
public PivoteBrasBas() {
public PivoteBrasBas(BrasTelescopique brasTelescopique, Pivot pivot) {
this.brasTelescopique = brasTelescopique;
this.pivot = pivot;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(brasTelescopique);
addRequirements(pivot);
}
// Called when the command is initially scheduled.
@ -18,7 +28,28 @@ public class PivoteBrasBas extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}
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);
}
}
// Called once the command ends or is interrupted.
@Override

View File

@ -5,11 +5,19 @@
package frc.robot.commands.bras;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pivot;
public class PivoteBrasHaut extends CommandBase {
private BrasTelescopique brasTelescopique;
private Pivot pivot;
/** Creates a new PivoteBrasHaut. */
public PivoteBrasHaut() {
public PivoteBrasHaut(BrasTelescopique brasTelescopique, Pivot pivot) {
this.brasTelescopique = brasTelescopique;
this.pivot = pivot;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(brasTelescopique);
addRequirements(pivot);
}
// Called when the command is initially scheduled.
@ -18,7 +26,26 @@ public class PivoteBrasHaut extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}
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);
}
}
// Called once the command ends or is interrupted.
@Override

View File

@ -5,11 +5,19 @@
package frc.robot.commands.bras;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pivot;
public class PivoteBrasMilieux extends CommandBase {
private BrasTelescopique brasTelescopique;
private Pivot pivot;
/** Creates a new PivoteBrasMilieux. */
public PivoteBrasMilieux() {
public PivoteBrasMilieux(BrasTelescopique brasTelescopique, Pivot pivot) {
this.brasTelescopique = brasTelescopique;
this.pivot = pivot;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(brasTelescopique);
addRequirements(pivot);
}
// Called when the command is initially scheduled.
@ -18,7 +26,27 @@ public class PivoteBrasMilieux extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}
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);
}
}
// Called once the command ends or is interrupted.
@Override