fhcgjvhbm,

This commit is contained in:
samuel desharnais 2023-04-13 18:25:05 -04:00
parent a1062d3ae3
commit 59a7c30154
5 changed files with 17 additions and 34 deletions

View File

@ -61,10 +61,6 @@ public class RobotContainer {
String aumilieux = "au milieux"; String aumilieux = "au milieux";
String enbas = "en bas"; String enbas = "en bas";
String nulpart = "nul part"; String nulpart = "nul part";
GenericEntry forcebrasmonter = Shuffleboard.getTab("teb").addPersistent("force bras monter", 0.35).getEntry();
GenericEntry forcebrasdescendre = Shuffleboard.getTab("teb").addPersistent("force bras descendre", -0.35).getEntry();
GenericEntry forcepivotmonter = Shuffleboard.getTab("teb").addPersistent("force pivot monter", 0.5).getEntry();
GenericEntry forcepivotdescendre = Shuffleboard.getTab("teb").addPersistent("force pivot descendre", -0.5).getEntry();
ShuffleboardLayout layoutauto = Shuffleboard.getTab("teb").getLayout("auto", BuiltInLayouts.kList) ShuffleboardLayout layoutauto = Shuffleboard.getTab("teb").getLayout("auto", BuiltInLayouts.kList)
.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();
@ -144,8 +140,8 @@ public class RobotContainer {
private Command creerCommandBras(double distancePivot, double distanceBras) { private Command creerCommandBras(double distancePivot, double distanceBras) {
return Commands.either( return Commands.either(
new MonterPivotBras(brasTelescopique, pivot, distanceBras, distancePivot,forcebrasmonter,forcebrasdescendre,forcepivotmonter,forcepivotdescendre), new MonterPivotBras(brasTelescopique, pivot, distanceBras, distancePivot),
new DescendrePivotBras(brasTelescopique, pivot, distanceBras, distancePivot,forcebrasmonter,forcebrasdescendre,forcepivotmonter,forcepivotdescendre), new DescendrePivotBras(brasTelescopique, pivot, distanceBras, distancePivot),
() -> pivot.distance() < distancePivot); () -> pivot.distance() < distancePivot);
} }

View File

@ -4,8 +4,6 @@
package frc.robot.commands.bras; package frc.robot.commands.bras;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj2.command.CommandBase; import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.bras.BrasTelescopique; import frc.robot.subsystems.bras.BrasTelescopique;
@ -13,14 +11,11 @@ public class Bougerbras extends CommandBase {
/** Creates a new bougerbras. */ /** Creates a new bougerbras. */
double distance; double distance;
BrasTelescopique brasTelescopique; BrasTelescopique brasTelescopique;
private GenericEntry forcebrasdescendre;
private GenericEntry forcebrasmonter;
public Bougerbras(BrasTelescopique brasTelescopique,double distance,GenericEntry forcebrasdescendre, GenericEntry forcebrasmonter) { public Bougerbras(BrasTelescopique brasTelescopique,double distance) {
this.brasTelescopique = brasTelescopique; this.brasTelescopique = brasTelescopique;
this.distance = distance; this.distance = distance;
this.forcebrasdescendre = forcebrasdescendre;
this.forcebrasmonter = forcebrasmonter;
addRequirements(brasTelescopique); addRequirements(brasTelescopique);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
} }
@ -35,11 +30,11 @@ public class Bougerbras extends CommandBase {
@Override @Override
public void execute() { public void execute() {
if(brasTelescopique.distance()>distance+0.5 ) { if(brasTelescopique.distance()>distance+0.5 ) {
brasTelescopique.AvanceRecule(forcebrasdescendre.getDouble(-0.35)); brasTelescopique.AvanceRecule(0.35);
} }
else if(brasTelescopique.distance()<distance-0.5) { else if(brasTelescopique.distance()<distance-0.5) {
brasTelescopique.AvanceRecule(forcebrasmonter.getDouble(0.35)); brasTelescopique.AvanceRecule(-0.35);
} }
else { else {
brasTelescopique.AvanceRecule(0); brasTelescopique.AvanceRecule(0);

View File

@ -4,8 +4,6 @@
package frc.robot.commands.bras; package frc.robot.commands.bras;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj2.command.CommandBase; import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.bras.Pivot; import frc.robot.subsystems.bras.Pivot;
@ -13,13 +11,9 @@ public class Bougerpivot extends CommandBase {
/** Creates a new Bougerpivot. */ /** Creates a new Bougerpivot. */
Pivot pivot; Pivot pivot;
double distance; double distance;
private GenericEntry forcepivotmonter; public Bougerpivot(Pivot pivot,double distance) {
private GenericEntry forcepivotdescendre;
public Bougerpivot(Pivot pivot,double distance,GenericEntry forcepivotdescendre, GenericEntry forcepivotmonter) {
this.pivot = pivot; this.pivot = pivot;
this.distance = distance; this.distance = distance;
this.forcepivotdescendre = forcepivotdescendre;
this.forcepivotmonter = forcepivotmonter;
addRequirements(pivot); addRequirements(pivot);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
@ -33,10 +27,10 @@ public class Bougerpivot extends CommandBase {
@Override @Override
public void execute() { public void execute() {
if(pivot.distance()>distance+0.5 ) { if(pivot.distance()>distance+0.5 ) {
pivot.monteDescendre(forcepivotdescendre.getDouble(-0.5)); pivot.monteDescendre(0.5);
} }
else if(pivot.distance()<distance-0.5) { else if(pivot.distance()<distance-0.5) {
pivot.monteDescendre(forcepivotmonter.getDouble(0.5)); pivot.monteDescendre(-0.5);
} }
else { else {
pivot.monteDescendre(0); pivot.monteDescendre(0);

View File

@ -4,8 +4,6 @@
package frc.robot.commands.bras; package frc.robot.commands.bras;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import frc.robot.subsystems.bras.BrasTelescopique; import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pivot; import frc.robot.subsystems.bras.Pivot;
@ -15,13 +13,13 @@ import frc.robot.subsystems.bras.Pivot;
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html // https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
public class DescendrePivotBras extends SequentialCommandGroup { public class DescendrePivotBras extends SequentialCommandGroup {
/** Creates a new DescendrePivotBras. */ /** Creates a new DescendrePivotBras. */
public DescendrePivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot,GenericEntry forcebrasmonter, GenericEntry forcebrasdescendre,GenericEntry forcepivotmonter,GenericEntry forcepivotdescendre ) { public DescendrePivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot) {
// Add your commands in the addCommands() call, e.g. // Add your commands in the addCommands() call, e.g.
// addCommands(new FooCommand(), new BarCommand()); // addCommands(new FooCommand(), new BarCommand());
addCommands( addCommands(
new Bougerbras(brasTelescopique, distanceBras,forcebrasdescendre,forcebrasmonter), new Bougerbras(brasTelescopique, distanceBras),
new Bougerpivot(pivot, distancePivot,forcepivotdescendre,forcepivotmonter) new Bougerpivot(pivot, distancePivot)
); );
} }

View File

@ -5,7 +5,7 @@
package frc.robot.commands.bras; package frc.robot.commands.bras;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import frc.robot.subsystems.bras.BrasTelescopique; import frc.robot.subsystems.bras.BrasTelescopique;
@ -16,14 +16,14 @@ import frc.robot.subsystems.bras.Pivot;
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html // https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
public class MonterPivotBras extends SequentialCommandGroup { public class MonterPivotBras extends SequentialCommandGroup {
/** Creates a new Sequancepivotbras. */ /** Creates a new Sequancepivotbras. */
public MonterPivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot,GenericEntry forcebrasmonter, GenericEntry forcebrasdescendre,GenericEntry forcepivotmonter,GenericEntry forcepivotdescendre) { public MonterPivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot) {
// Add your commands in the addCommands() call, e.g. // Add your commands in the addCommands() call, e.g.
// addCommands(new FooCommand(), new BarCommand()); // addCommands(new FooCommand(), new BarCommand());
addCommands( addCommands(
new Bougerpivot(pivot, 10, forcepivotdescendre, forcepivotdescendre).unless(()->pivot.distance()>10), new Bougerpivot(pivot, 10).unless(()->pivot.distance()>10),
new ParallelCommandGroup(new Bougerpivot(pivot, distancePivot,forcepivotdescendre,forcepivotmonter)), new ParallelCommandGroup(new Bougerpivot(pivot, distancePivot)),
new ParallelCommandGroup(new Bougerbras(brasTelescopique, distanceBras,forcebrasdescendre,forcebrasmonter)) new ParallelCommandGroup(new Bougerbras(brasTelescopique, distanceBras))
); );