modif debug

This commit is contained in:
EdwardFaucher 2023-03-15 20:26:42 -04:00
parent 90540ccbd0
commit 5b2606140f
13 changed files with 40 additions and 29 deletions

View File

@ -65,9 +65,9 @@ ShuffleboardLayout layoutauto = Shuffleboard.getTab("teb").getLayout("auto",Buil
.withSize(2, 2).withProperties(Map.of("Label position","LEFT")); .withSize(2, 2).withProperties(Map.of("Label position","LEFT"));
GenericEntry autobalance = layoutauto.add("choix balance",true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); GenericEntry autobalance = layoutauto.add("choix balance",true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
GenericEntry autosortir = layoutauto.add("choix sortir",false).withWidget(BuiltInWidgets.kToggleSwitch).getEntry(); GenericEntry autosortir = layoutauto.add("choix sortir",false).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
GenericEntry reculerdistances = layoutauto.addPersistent("reculerdistancesortir",0).getEntry(); GenericEntry reculerdistances = layoutauto.addPersistent("reculerdistancesortir",-66).getEntry();
GenericEntry reculerdistanceb = layoutauto.addPersistent("reculerdistancebalance", 0).getEntry(); GenericEntry reculerdistanceb = layoutauto.addPersistent("reculerdistancebalance", -31).getEntry();
GenericEntry avancerdistance = layoutauto.addPersistent("avancer",0).getEntry(); GenericEntry avancerdistance = layoutauto.addPersistent("avancer",-35).getEntry();
// subsystems // subsystems
BasePilotable basePilotable = new BasePilotable(); BasePilotable basePilotable = new BasePilotable();
Gratte gratte = new Gratte(); Gratte gratte = new Gratte();
@ -133,13 +133,14 @@ public RobotContainer() {
manette2.start().onTrue(new InstantCommand(basePilotable::resetGyro)); manette2.start().onTrue(new InstantCommand(basePilotable::resetGyro));
manette2.a().whileTrue(gratteMonte); manette2.a().whileTrue(gratteMonte);
manette2.b().whileTrue(gratteBaisser); manette2.b().whileTrue(gratteBaisser);
manette2.back().onTrue(new InstantCommand(basePilotable::Reset));
} }
public Command getAutonomousCommand() { public Command getAutonomousCommand() {
chooser.getSelected(); chooser.getSelected();
autobalance.getBoolean(true); autobalance.getBoolean(true);
return new SequentialCommandGroup( return Commands.waitSeconds(14).deadlineWith( new SequentialCommandGroup(
Commands.select(Map.ofEntries( Commands.select(Map.ofEntries(
Map.entry(enhaut,pivoteBrasHaut), Map.entry(enhaut,pivoteBrasHaut),
Map.entry(aumilieux,pivoteBrasMilieux), Map.entry(aumilieux,pivoteBrasMilieux),
@ -147,10 +148,14 @@ public RobotContainer() {
Map.entry(nulpart,pivotBrasRentre) Map.entry(nulpart,pivotBrasRentre)
), chooser::getSelected), ), chooser::getSelected),
ouvrePince.unless(()->chooser.getSelected().equals(nulpart)), ouvrePince.unless(()->chooser.getSelected().equals(nulpart)),
Commands.waitSeconds(1),
fermePince.unless(()->chooser.getSelected().equals(nulpart)),
new PivotBrasRentre(brasTelescopique , pivot).unless(()->chooser.getSelected().equals(nulpart)),
Commands.waitSeconds(1),
Commands.either(reculers, reculerb,()-> autosortir.getBoolean(true)), Commands.either(reculers, reculerb,()-> autosortir.getBoolean(true)),
avancer.unless(()->!autosortir.getBoolean(true)|| !autobalance.getBoolean(false)), avancer.unless(()->!autosortir.getBoolean(true)|| !autobalance.getBoolean(false)),
Commands.either(gyro, Commands.none(),()-> autobalance.getBoolean(true)) Commands.either(gyro, Commands.none(),()-> autobalance.getBoolean(true))
).deadlineWith(Commands.waitSeconds(14.6)).andThen(brakeOuvre); )).andThen(brakeOuvre);
} }

View File

@ -37,6 +37,6 @@ public class BrakeFerme extends CommandBase {
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return false; return true;
} }
} }

View File

@ -37,6 +37,6 @@ public class BrakeOuvre extends CommandBase {
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return false; return true;
} }
} }

View File

@ -30,7 +30,7 @@ public class Reculer extends CommandBase {
// Called every time the scheduler runs while the command is scheduled. // Called every time the scheduler runs while the command is scheduled.
@Override @Override
public void execute() { public void execute() {
basePilotable.drive(-0.3,0); basePilotable.drive(-0.5,0);
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.

View File

@ -29,9 +29,12 @@ public class BrasManuel extends CommandBase {
// Called every time the scheduler runs while the command is scheduled. // Called every time the scheduler runs while the command is scheduled.
@Override @Override
public void execute() { public void execute() {
if(doubleSupplier.getAsDouble()>0.2 && doubleSupplier.getAsDouble()<-0.2){
brasTelescopique.AvanceRecule(doubleSupplier.getAsDouble()); brasTelescopique.AvanceRecule(doubleSupplier.getAsDouble());
} }
}
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.
@Override @Override
public void end(boolean interrupted) {} public void end(boolean interrupted) {}

View File

@ -33,6 +33,6 @@ public class FermePince extends CommandBase {
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return false; return true;
} }
} }

View File

@ -33,6 +33,6 @@ public class OuvrePince extends CommandBase {
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return false; return true;
} }
} }

View File

@ -42,7 +42,7 @@ public class PivotBrasRentre extends CommandBase {
pivot.monteDescendre(0); pivot.monteDescendre(0);
} }
else{ else{
pivot.monteDescendre(-0.3); pivot.monteDescendre(-0.5);
} }
} }
@ -57,6 +57,6 @@ public class PivotBrasRentre extends CommandBase {
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return false; return brasTelescopique.photocell() && pivot.limitpivot();
} }
} }

View File

@ -38,10 +38,10 @@ public class PivotChercheHaut extends CommandBase {
brasTelescopique.AvanceRecule(0.3); brasTelescopique.AvanceRecule(0.3);
} }
if (pivot.distance()<43.5){ if (pivot.distance()<43.5){
pivot.monteDescendre(0.4); pivot.monteDescendre(0.5);
} }
else if(pivot.distance()>44.5) { else if(pivot.distance()>44.5) {
pivot.monteDescendre(-0.4); pivot.monteDescendre(-0.5);
} }
else{ else{
pivot.monteDescendre(0); pivot.monteDescendre(0);

View File

@ -27,7 +27,8 @@ public class PivotManuel extends CommandBase {
// Called every time the scheduler runs while the command is scheduled. // Called every time the scheduler runs while the command is scheduled.
@Override @Override
public void execute() { public void execute() {
pivot.monteDescendre(doubleSupplier.getAsDouble()); if(doubleSupplier.getAsDouble()>0.2 && doubleSupplier.getAsDouble()<-0.2){
pivot.monteDescendre(doubleSupplier.getAsDouble());}
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.

View File

@ -43,10 +43,10 @@ public class PivoteBrasBas extends CommandBase {
brasTelescopique.ouvrir(); brasTelescopique.ouvrir();
} }
if (pivot.distance()<8.5){ if (pivot.distance()<8.5){
pivot.monteDescendre(0.3); pivot.monteDescendre(0.4);
} }
else if(pivot.distance()>10.5) { else if(pivot.distance()>10.5) {
pivot.monteDescendre(-0.3); pivot.monteDescendre(-0.4);
} }
else{ else{
pivot.monteDescendre(0); pivot.monteDescendre(0);
@ -65,6 +65,7 @@ public class PivoteBrasBas extends CommandBase {
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return false; return brasTelescopique.distance()>-13.5 && brasTelescopique.distance() <-15.5 && pivot.distance()<8.5 && pivot.distance()>10.5;
} }
} }

View File

@ -33,7 +33,7 @@ public class PivoteBrasHaut extends CommandBase {
brasTelescopique.AvanceRecule(-0.15); brasTelescopique.AvanceRecule(-0.15);
brasTelescopique.fermer(); brasTelescopique.fermer();
} }
else if(brasTelescopique.distance()<41.5) { else if(brasTelescopique.distance()<-41.5) {
brasTelescopique.AvanceRecule(-0.15); brasTelescopique.AvanceRecule(-0.15);
} }
else { else {
@ -41,10 +41,10 @@ public class PivoteBrasHaut extends CommandBase {
brasTelescopique.ouvrir(); brasTelescopique.ouvrir();
} }
if (pivot.distance()<50.5){ if (pivot.distance()<50.5){
pivot.monteDescendre(0.4); pivot.monteDescendre(0.5);
} }
else if(pivot.distance()>52.5) { else if(pivot.distance()>52.5) {
pivot.monteDescendre(-0.4); pivot.monteDescendre(-0.5);
} }
else{ else{
pivot.monteDescendre(0); pivot.monteDescendre(0);
@ -62,6 +62,6 @@ public class PivoteBrasHaut extends CommandBase {
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return false; return brasTelescopique.distance()>-39.5 && brasTelescopique.distance() <-41.5 && pivot.distance()<50.5 && pivot.distance()>52.5;
} }
} }

View File

@ -30,21 +30,21 @@ public class PivoteBrasMilieux extends CommandBase {
@Override @Override
public void execute() { public void execute() {
if(brasTelescopique.distance()>-16.5){ if(brasTelescopique.distance()>-16.5){
brasTelescopique.AvanceRecule(-0.2); brasTelescopique.AvanceRecule(-0.15);
brasTelescopique.fermer(); brasTelescopique.fermer();
} }
else if(brasTelescopique.distance()<-17.5) { else if(brasTelescopique.distance()<-17.5) {
brasTelescopique.AvanceRecule(0.2); brasTelescopique.AvanceRecule(0.15);
} }
else { else {
brasTelescopique.AvanceRecule(0); brasTelescopique.AvanceRecule(0);
brasTelescopique.ouvrir(); brasTelescopique.ouvrir();
} }
if (pivot.distance()<43.5){ if (pivot.distance()<43.5){
pivot.monteDescendre(0.4); pivot.monteDescendre(0.6);
} }
else if(pivot.distance()>44.5) { else if(pivot.distance()>44.5) {
pivot.monteDescendre(-0.4); pivot.monteDescendre(-0.6);
} }
else{ else{
pivot.monteDescendre(0); pivot.monteDescendre(0);
@ -63,6 +63,7 @@ public class PivoteBrasMilieux extends CommandBase {
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return false; return brasTelescopique.distance()>-16.5 && brasTelescopique.distance() <-15.5 && pivot.distance()<44.5 && pivot.distance()>43.5;
} }
} }