yfcghjhfhcgvnm
This commit is contained in:
parent
94ac975b75
commit
a1062d3ae3
@ -13,6 +13,7 @@ import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.Commands;
|
||||
@ -60,6 +61,10 @@ public class RobotContainer {
|
||||
String aumilieux = "au milieux";
|
||||
String enbas = "en bas";
|
||||
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)
|
||||
.withSize(2, 2).withProperties(Map.of("Label position", "LEFT"));
|
||||
GenericEntry autobalance = layoutauto.add("choix balance", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
|
||||
@ -68,7 +73,9 @@ public class RobotContainer {
|
||||
GenericEntry reculerdistanceb = layoutauto.addPersistent("reculer distance balance", -31).getEntry();
|
||||
GenericEntry avancerdistance = layoutauto.addPersistent("avancer", 35).getEntry();
|
||||
GenericEntry avancerforce = layoutauto.addPersistent("avancer force", 0.4).getEntry();
|
||||
GenericEntry reculerforce = layoutauto.addPersistent("reculerforce", 0.4).getEntry();
|
||||
GenericEntry reculerforce = layoutauto.addPersistent("reculer force", -0.45).getEntry();
|
||||
GenericEntry gyroforce = layoutauto.addPersistent("gyro force", 0.3).getEntry();
|
||||
|
||||
// subsystems
|
||||
BasePilotable basePilotable = new BasePilotable();
|
||||
Gratte gratte = new Gratte();
|
||||
@ -82,13 +89,13 @@ public class RobotContainer {
|
||||
BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable);
|
||||
GratteBaisser gratteBaisser = new GratteBaisser(gratte);
|
||||
GratteMonte gratteMonte = new GratteMonte(gratte);
|
||||
Gyro gyro = new Gyro(basePilotable);
|
||||
Gyro gyro = new Gyro(basePilotable,()->gyroforce.getDouble(0));
|
||||
FermePince fermePince = new FermePince(pince);
|
||||
OuvrePince ouvrePince = new OuvrePince(pince);
|
||||
Cone cone = new Cone(limelight, basePilotable, () -> -manette1.getLeftY());
|
||||
Reculer reculers = new Reculer(basePilotable, () -> reculerdistances.getDouble(0));
|
||||
Reculer reculerb = new Reculer(basePilotable, () -> reculerdistanceb.getDouble(0));
|
||||
Avancer avancer = new Avancer(basePilotable, () -> avancerdistance.getDouble(0));
|
||||
Reculer reculers = new Reculer(basePilotable, () -> reculerdistances.getDouble(0),()->reculerforce.getDouble(0));
|
||||
Reculer reculerb = new Reculer(basePilotable, () -> reculerdistanceb.getDouble(0),()->reculerforce.getDouble(0));
|
||||
Avancer avancer = new Avancer(basePilotable, () -> avancerdistance.getDouble(0),()-> avancerforce.getDouble(0));
|
||||
Cube cube = new Cube(limelight, basePilotable, () -> manette1.getLeftY());
|
||||
Apriltag aprilTag = new Apriltag(limelight, basePilotable, () -> manette1.getLeftY());
|
||||
Tape tape = new Tape(limelight, basePilotable, () -> manette1.getLeftY());
|
||||
@ -137,8 +144,8 @@ public class RobotContainer {
|
||||
|
||||
private Command creerCommandBras(double distancePivot, double distanceBras) {
|
||||
return Commands.either(
|
||||
new MonterPivotBras(brasTelescopique, pivot, distanceBras, distancePivot),
|
||||
new DescendrePivotBras(brasTelescopique, pivot, distanceBras, distancePivot),
|
||||
new MonterPivotBras(brasTelescopique, pivot, distanceBras, distancePivot,forcebrasmonter,forcebrasdescendre,forcepivotmonter,forcepivotdescendre),
|
||||
new DescendrePivotBras(brasTelescopique, pivot, distanceBras, distancePivot,forcebrasmonter,forcebrasdescendre,forcepivotmonter,forcepivotdescendre),
|
||||
() -> pivot.distance() < distancePivot);
|
||||
}
|
||||
|
||||
@ -160,7 +167,7 @@ public class RobotContainer {
|
||||
new FermePince(pince).unless(() -> chooser.getSelected().equals(nulpart)),
|
||||
new ParallelCommandGroup (creerCommandBras(0, 0).unless(() -> chooser.getSelected().equals(nulpart)),
|
||||
Commands.either(reculers, reculerb, () -> autosortir.getBoolean(true))),
|
||||
new Avancer(basePilotable, () -> avancerdistance.getDouble(0)).unless(() -> !autosortir.getBoolean(true) || !autobalance.getBoolean(false)),
|
||||
new Avancer(basePilotable, () -> avancerdistance.getDouble(0),()->avancerforce.getDouble(0)).unless(() -> !autosortir.getBoolean(true) || !autobalance.getBoolean(false)),
|
||||
Commands.either(gyro, Commands.none(), () -> autobalance.getBoolean(true))))
|
||||
.andThen(brakeOuvre);
|
||||
|
||||
|
@ -7,17 +7,18 @@ package frc.robot.commands;
|
||||
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.BasePilotable;
|
||||
|
||||
public class Avancer extends CommandBase {
|
||||
BasePilotable basePilotable;
|
||||
DoubleSupplier distance;
|
||||
DoubleSupplier force;
|
||||
/** Creates a new Reculer. */
|
||||
public Avancer(BasePilotable basePilotable, DoubleSupplier distance) {
|
||||
public Avancer(BasePilotable basePilotable, DoubleSupplier distance, DoubleSupplier force) {
|
||||
this.basePilotable = basePilotable;
|
||||
this.distance = distance;
|
||||
this.force = force;
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
addRequirements(basePilotable);
|
||||
}
|
||||
@ -31,7 +32,7 @@ public class Avancer extends CommandBase {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
basePilotable.drive(0.4,0);
|
||||
basePilotable.drive(force.getAsDouble(),0);
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
|
@ -5,14 +5,18 @@
|
||||
package frc.robot.commands;
|
||||
|
||||
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.BasePilotable;
|
||||
|
||||
public class Gyro extends CommandBase {
|
||||
private BasePilotable basePilotable;
|
||||
DoubleSupplier force;
|
||||
/** Creates a new Gyro. */
|
||||
public Gyro(BasePilotable basePilotable) {
|
||||
public Gyro(BasePilotable basePilotable,DoubleSupplier force) {
|
||||
this.basePilotable = basePilotable;
|
||||
this.force = force;
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
addRequirements(basePilotable);
|
||||
}
|
||||
@ -26,11 +30,11 @@ public class Gyro extends CommandBase {
|
||||
public void execute() {
|
||||
if(basePilotable.getpitch()>6)
|
||||
{
|
||||
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0);
|
||||
basePilotable.drive(force.getAsDouble()*basePilotable.getpitch()/12, 0);
|
||||
}
|
||||
else if(basePilotable.getpitch()<-6)
|
||||
{
|
||||
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0);
|
||||
basePilotable.drive(force.getAsDouble()*basePilotable.getpitch()/12, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -13,10 +13,12 @@ import frc.robot.subsystems.BasePilotable;
|
||||
public class Reculer extends CommandBase {
|
||||
BasePilotable basePilotable;
|
||||
DoubleSupplier distance;
|
||||
DoubleSupplier force;
|
||||
/** Creates a new Reculer. */
|
||||
public Reculer(BasePilotable basePilotable, DoubleSupplier distance) {
|
||||
public Reculer(BasePilotable basePilotable, DoubleSupplier distance,DoubleSupplier force) {
|
||||
this.basePilotable = basePilotable;
|
||||
this.distance = distance;
|
||||
this.force = force;
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
addRequirements(basePilotable);
|
||||
}
|
||||
@ -30,7 +32,7 @@ public class Reculer extends CommandBase {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
basePilotable.drive(-0.45,0);
|
||||
basePilotable.drive(force.getAsDouble(),0);
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
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 frc.robot.subsystems.bras.BrasTelescopique;
|
||||
|
||||
@ -11,9 +13,14 @@ public class Bougerbras extends CommandBase {
|
||||
/** Creates a new bougerbras. */
|
||||
double distance;
|
||||
BrasTelescopique brasTelescopique;
|
||||
public Bougerbras(BrasTelescopique brasTelescopique,double distance) {
|
||||
private GenericEntry forcebrasdescendre;
|
||||
private GenericEntry forcebrasmonter;
|
||||
|
||||
public Bougerbras(BrasTelescopique brasTelescopique,double distance,GenericEntry forcebrasdescendre, GenericEntry forcebrasmonter) {
|
||||
this.brasTelescopique = brasTelescopique;
|
||||
this.distance = distance;
|
||||
this.forcebrasdescendre = forcebrasdescendre;
|
||||
this.forcebrasmonter = forcebrasmonter;
|
||||
addRequirements(brasTelescopique);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
}
|
||||
@ -28,11 +35,11 @@ public class Bougerbras extends CommandBase {
|
||||
@Override
|
||||
public void execute() {
|
||||
if(brasTelescopique.distance()>distance+0.5 ) {
|
||||
brasTelescopique.AvanceRecule(-0.35);
|
||||
brasTelescopique.AvanceRecule(forcebrasdescendre.getDouble(-0.35));
|
||||
|
||||
}
|
||||
else if(brasTelescopique.distance()<distance-0.5) {
|
||||
brasTelescopique.AvanceRecule(0.35);
|
||||
brasTelescopique.AvanceRecule(forcebrasmonter.getDouble(0.35));
|
||||
}
|
||||
else {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
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 frc.robot.subsystems.bras.Pivot;
|
||||
|
||||
@ -11,10 +13,15 @@ public class Bougerpivot extends CommandBase {
|
||||
/** Creates a new Bougerpivot. */
|
||||
Pivot pivot;
|
||||
double distance;
|
||||
public Bougerpivot(Pivot pivot,double distance) {
|
||||
private GenericEntry forcepivotmonter;
|
||||
private GenericEntry forcepivotdescendre;
|
||||
public Bougerpivot(Pivot pivot,double distance,GenericEntry forcepivotdescendre, GenericEntry forcepivotmonter) {
|
||||
this.pivot = pivot;
|
||||
this.distance = distance;
|
||||
this.forcepivotdescendre = forcepivotdescendre;
|
||||
this.forcepivotmonter = forcepivotmonter;
|
||||
addRequirements(pivot);
|
||||
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
}
|
||||
|
||||
@ -26,10 +33,10 @@ public class Bougerpivot extends CommandBase {
|
||||
@Override
|
||||
public void execute() {
|
||||
if(pivot.distance()>distance+0.5 ) {
|
||||
pivot.monteDescendre(-0.5);
|
||||
pivot.monteDescendre(forcepivotdescendre.getDouble(-0.5));
|
||||
}
|
||||
else if(pivot.distance()<distance-0.5) {
|
||||
pivot.monteDescendre(0.5);
|
||||
pivot.monteDescendre(forcepivotmonter.getDouble(0.5));
|
||||
}
|
||||
else {
|
||||
pivot.monteDescendre(0);
|
||||
|
@ -5,6 +5,7 @@
|
||||
package frc.robot.commands.bras;
|
||||
|
||||
|
||||
import edu.wpi.first.networktables.GenericEntry;
|
||||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
import frc.robot.subsystems.bras.Pivot;
|
||||
@ -14,13 +15,13 @@ import frc.robot.subsystems.bras.Pivot;
|
||||
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
|
||||
public class DescendrePivotBras extends SequentialCommandGroup {
|
||||
/** Creates a new DescendrePivotBras. */
|
||||
public DescendrePivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot) {
|
||||
public DescendrePivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot,GenericEntry forcebrasmonter, GenericEntry forcebrasdescendre,GenericEntry forcepivotmonter,GenericEntry forcepivotdescendre ) {
|
||||
// Add your commands in the addCommands() call, e.g.
|
||||
// addCommands(new FooCommand(), new BarCommand());
|
||||
addCommands(
|
||||
|
||||
new Bougerbras(brasTelescopique, distanceBras),
|
||||
new Bougerpivot(pivot, distancePivot)
|
||||
new Bougerbras(brasTelescopique, distanceBras,forcebrasdescendre,forcebrasmonter),
|
||||
new Bougerpivot(pivot, distancePivot,forcepivotdescendre,forcepivotmonter)
|
||||
|
||||
);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
package frc.robot.commands.bras;
|
||||
|
||||
|
||||
import edu.wpi.first.networktables.GenericEntry;
|
||||
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
|
||||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
@ -15,14 +16,14 @@ import frc.robot.subsystems.bras.Pivot;
|
||||
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
|
||||
public class MonterPivotBras extends SequentialCommandGroup {
|
||||
/** Creates a new Sequancepivotbras. */
|
||||
public MonterPivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot) {
|
||||
public MonterPivotBras(BrasTelescopique brasTelescopique, Pivot pivot, double distanceBras, double distancePivot,GenericEntry forcebrasmonter, GenericEntry forcebrasdescendre,GenericEntry forcepivotmonter,GenericEntry forcepivotdescendre) {
|
||||
|
||||
// Add your commands in the addCommands() call, e.g.
|
||||
// addCommands(new FooCommand(), new BarCommand());
|
||||
addCommands(
|
||||
new Bougerpivot(pivot, 10).unless(()->pivot.distance()>10),
|
||||
new ParallelCommandGroup(new Bougerpivot(pivot, distancePivot)),
|
||||
new ParallelCommandGroup(new Bougerbras(brasTelescopique, distanceBras))
|
||||
new Bougerpivot(pivot, 10, forcepivotdescendre, forcepivotdescendre).unless(()->pivot.distance()>10),
|
||||
new ParallelCommandGroup(new Bougerpivot(pivot, distancePivot,forcepivotdescendre,forcepivotmonter)),
|
||||
new ParallelCommandGroup(new Bougerbras(brasTelescopique, distanceBras,forcebrasdescendre,forcebrasmonter))
|
||||
|
||||
|
||||
);
|
||||
|
@ -74,6 +74,7 @@ public void BrakeFerme(){
|
||||
teb.add(drive);
|
||||
teb.addDouble("distancerobot",this::distance);
|
||||
teb.addDouble("angle gyro", this::getpitch);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user