Compare commits

..

No commits in common. "2878aed0859a34699bf17e11f7d58e734349b23d" and "cd47b7709057cc8ff40f1041b31a7adbc756193e" have entirely different histories.

9 changed files with 29 additions and 48 deletions

View File

@ -6,18 +6,17 @@ package frc.robot;
import java.util.Map;
import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.networktables.GenericEntry;
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;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
@ -41,7 +40,8 @@ import frc.robot.commands.GratteMonte;
import frc.robot.commands.Gyro;
import frc.robot.commands.Reculer;
import frc.robot.commands.Tape;
import frc.robot.commands.bras.Bougerbras;
import frc.robot.commands.bras.Bougerpivot;
import frc.robot.commands.bras.BrasManuel;
import frc.robot.commands.bras.DescendrePivotBras;
import frc.robot.commands.bras.FermePince;
@ -49,7 +49,6 @@ import frc.robot.commands.bras.MonterPivotBras;
import frc.robot.commands.bras.OuvrePince;
import frc.robot.commands.bras.PivotManuel;
import frc.robot.commands.ActiverLimeLight;
public class RobotContainer {
CommandXboxController manette1 = new CommandXboxController(0);
@ -65,13 +64,9 @@ public class RobotContainer {
.withSize(2, 2).withProperties(Map.of("Label position", "LEFT"));
GenericEntry autobalance = layoutauto.add("choix balance", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
GenericEntry autosortir = layoutauto.add("choix sortir", false).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
GenericEntry reculerdistances = layoutauto.addPersistent("reculer distance sortir", -66).getEntry();
GenericEntry reculerdistanceb = layoutauto.addPersistent("reculer distance balance", -31).getEntry();
GenericEntry reculerdistances = layoutauto.addPersistent("reculerdistancesortir", -66).getEntry();
GenericEntry reculerdistanceb = layoutauto.addPersistent("reculerdistancebalance", -31).getEntry();
GenericEntry avancerdistance = layoutauto.addPersistent("avancer", 35).getEntry();
GenericEntry avancerforce = layoutauto.addPersistent("avancer force", 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();
@ -85,13 +80,13 @@ public class RobotContainer {
BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable);
GratteBaisser gratteBaisser = new GratteBaisser(gratte);
GratteMonte gratteMonte = new GratteMonte(gratte);
Gyro gyro = new Gyro(basePilotable, () -> gyroforce.getDouble(0));
Gyro gyro = new Gyro(basePilotable);
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), () -> 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));
Reculer reculers = new Reculer(basePilotable, () -> reculerdistances.getDouble(0));
Reculer reculerb = new Reculer(basePilotable, () -> reculerdistanceb.getDouble(0));
Avancer avancer = new Avancer(basePilotable, () -> avancerdistance.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());
@ -116,7 +111,7 @@ public class RobotContainer {
private void configureBindings() {
// manette 1
manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer, pince));
manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince));
manette2.a().onTrue(brakeOuvre);
manette2.b().onTrue(brakeFerme);
manette1.leftBumper().whileTrue(aprilTag);
@ -126,14 +121,14 @@ public class RobotContainer {
manette1.povRight().whileTrue(creerCommandBras(44, -17));
manette1.povLeft().whileTrue(creerCommandBras(0, 0));
manette1.y().whileTrue(activerLimeLight);
// manette 2
//manette 2
manette2.povDown().whileTrue(creerCommandBras(9, -18));
manette2.povUp().whileTrue(creerCommandBras(44, 0));
manette2.rightBumper().whileTrue(cube);
manette2.leftBumper().whileTrue(cone);
manette2.y().whileTrue(gyro);
manette2.start().onTrue(new InstantCommand(basePilotable::resetGyro));
manette1.x().whileTrue(gratteMonte);
manette1.b().whileTrue(gratteMonte);
manette1.x().whileTrue(gratteBaisser);
}
@ -153,20 +148,18 @@ public class RobotContainer {
new SequentialCommandGroup(
Commands.select(Map.ofEntries(
Map.entry(enhaut, creerCommandBras(51, -40)),
Map.entry(aumilieux, creerCommandBras(45, -13)),
Map.entry(enbas, creerCommandBras(12, -9)),
Map.entry(aumilieux, creerCommandBras(9, -14)),
Map.entry(enbas, creerCommandBras(44, -17)),
Map.entry(nulpart, creerCommandBras(0, 0))), chooser::getSelected),
// creerCommandBras(50, -40).unless(() ->
// !chooser.getSelected().equals(enhaut)),
// creerCommandBras(51, -40).unless(() ->
// !chooser.getSelected().equals(enhaut)),
creerCommandBras(49, 40).unless(() -> chooser.getSelected().equals(enhaut)),
creerCommandBras(51, 40).unless(() -> chooser.getSelected().equals(enhaut)),
new OuvrePince(pince).unless(() -> chooser.getSelected().equals(nulpart)),
Commands.waitSeconds(1),
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), () -> avancerforce.getDouble(0))
.unless(() -> !autosortir.getBoolean(true) || !autobalance.getBoolean(false)),
new FermePince(pince).unless(() -> chooser.getSelected().equals(nulpart)),
creerCommandBras(0, 0).unless(() -> chooser.getSelected().equals(nulpart)),
Commands.waitSeconds(1),
Commands.either(reculers, reculerb, () -> autosortir.getBoolean(true)),
new Avancer(basePilotable, () -> avancerdistance.getDouble(0)).unless(() -> !autosortir.getBoolean(true) || !autobalance.getBoolean(false)),
Commands.either(gyro, Commands.none(), () -> autobalance.getBoolean(true))))
.andThen(brakeOuvre);

View File

@ -13,12 +13,10 @@ 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, DoubleSupplier force) {
public Avancer(BasePilotable basePilotable, DoubleSupplier distance) {
this.basePilotable = basePilotable;
this.distance = distance;
this.force = force;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(basePilotable);
}
@ -32,7 +30,7 @@ public class Avancer extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
basePilotable.drive(force.getAsDouble(),0);
basePilotable.drive(0.4,0);
}
// Called once the command ends or is interrupted.

View File

@ -5,18 +5,14 @@
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,DoubleSupplier force) {
public Gyro(BasePilotable basePilotable) {
this.basePilotable = basePilotable;
this.force = force;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(basePilotable);
}
@ -30,11 +26,11 @@ public class Gyro extends CommandBase {
public void execute() {
if(basePilotable.getpitch()>6)
{
basePilotable.drive(force.getAsDouble()*basePilotable.getpitch()/12, 0);
basePilotable.drive(0.4*basePilotable.getpitch()/12, 0);
}
else if(basePilotable.getpitch()<-6)
{
basePilotable.drive(force.getAsDouble()*basePilotable.getpitch()/12, 0);
basePilotable.drive(0.4*basePilotable.getpitch()/12, 0);
}
else
{

View File

@ -13,12 +13,10 @@ 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,DoubleSupplier force) {
public Reculer(BasePilotable basePilotable, DoubleSupplier distance) {
this.basePilotable = basePilotable;
this.distance = distance;
this.force = force;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(basePilotable);
}
@ -32,7 +30,7 @@ public class Reculer extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
basePilotable.drive(force.getAsDouble(),0);
basePilotable.drive(-0.4,0);
}
// Called once the command ends or is interrupted.

View File

@ -11,11 +11,9 @@ public class Bougerbras extends CommandBase {
/** Creates a new bougerbras. */
double distance;
BrasTelescopique brasTelescopique;
public Bougerbras(BrasTelescopique brasTelescopique,double distance) {
this.brasTelescopique = brasTelescopique;
this.distance = distance;
addRequirements(brasTelescopique);
// Use addRequirements() here to declare subsystem dependencies.
}

View File

@ -15,7 +15,6 @@ public class Bougerpivot extends CommandBase {
this.pivot = pivot;
this.distance = distance;
addRequirements(pivot);
// Use addRequirements() here to declare subsystem dependencies.
}

View File

@ -4,6 +4,7 @@
package frc.robot.commands.bras;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pivot;

View File

@ -5,7 +5,6 @@
package frc.robot.commands.bras;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import frc.robot.subsystems.bras.BrasTelescopique;

View File

@ -74,7 +74,6 @@ public void BrakeFerme(){
teb.add(drive);
teb.addDouble("distancerobot",this::distance);
teb.addDouble("angle gyro", this::getpitch);
}
@Override