This commit is contained in:
EdwardFaucher 2023-04-11 17:51:42 -04:00
commit 470debb148
5 changed files with 25 additions and 20 deletions

View File

@ -6,6 +6,7 @@ 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;
@ -64,7 +65,6 @@ public class RobotContainer {
GenericEntry reculerdistances = layoutauto.addPersistent("reculerdistancesortir", -66).getEntry();
GenericEntry reculerdistanceb = layoutauto.addPersistent("reculerdistancebalance", -31).getEntry();
GenericEntry avancerdistance = layoutauto.addPersistent("avancer", 35).getEntry();
// subsystems
BasePilotable basePilotable = new BasePilotable();
Gratte gratte = new Gratte();
@ -87,7 +87,7 @@ public class RobotContainer {
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());
Tape tape = new Tape(limelight, basePilotable, () -> manette1.getLeftY());
PivotManuel pivotManuel = new PivotManuel(pivot, manette1::getRightY);
BrasManuel brasManuel = new BrasManuel(brasTelescopique, manette1::getRightX);
ActiverLimeLight activerLimeLight = new ActiverLimeLight(limelight);
@ -110,22 +110,25 @@ public class RobotContainer {
private void configureBindings() {
// manette 1
manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince));
manette1.b().whileTrue(gratteMonte);
manette1.x().whileTrue(gratteBaisser);
manette2.a().onTrue(brakeOuvre);
manette2.b().onTrue(brakeFerme);
manette1.leftBumper().whileTrue(aprilTag);
manette1.rightBumper().whileTrue(tape);
manette1.povUp().whileTrue(creerCommandBras(51, -37));
manette1.povDown().whileTrue(creerCommandBras(12, -9));
manette1.povRight().whileTrue(creerCommandBras(45, -13));
manette1.povUp().whileTrue(creerCommandBras(51, -40));
manette1.povDown().whileTrue(creerCommandBras(9, -14));
manette1.povRight().whileTrue(creerCommandBras(44, -17));
manette1.povLeft().whileTrue(creerCommandBras(0, 0));
manette1.y().whileTrue(activerLimeLight);
//manette 2
manette2.povDown().whileTrue(creerCommandBras(5, -12));
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));
manette2.a().onTrue(brakeOuvre);
manette2.b().onTrue(brakeFerme);
manette1.b().whileTrue(gratteMonte);
manette1.x().whileTrue(gratteBaisser);
}
private Command creerCommandBras(double distancePivot, double distanceBras) {
@ -136,15 +139,15 @@ public class RobotContainer {
}
public Command getAutonomousCommand() {
chooser.getSelected();
autobalance.getBoolean(true);
return Commands.deadline(
Commands.waitSeconds(14),
Commands.waitSeconds(14.6),
new SequentialCommandGroup(
new BrakeFerme(basePilotable),
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),
new OuvrePince(pince).unless(() -> chooser.getSelected().equals(nulpart)),
Commands.waitSeconds(1),
@ -153,8 +156,8 @@ public class RobotContainer {
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(new Gyro(basePilotable), Commands.none(), () -> autobalance.getBoolean(true))))
.andThen(new BrakeOuvre(basePilotable));
Commands.either(gyro, Commands.none(), () -> autobalance.getBoolean(true))))
.andThen(brakeOuvre);
}
}

View File

@ -5,6 +5,7 @@
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.Gratte;

View File

@ -4,6 +4,7 @@
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.BasePilotable;

View File

@ -28,11 +28,11 @@ public class Bougerbras extends CommandBase {
@Override
public void execute() {
if(brasTelescopique.distance()>distance+0.5 ) {
brasTelescopique.AvanceRecule(-0.3);
brasTelescopique.AvanceRecule(-0.35);
}
else if(brasTelescopique.distance()<distance-0.5) {
brasTelescopique.AvanceRecule(0.3);
brasTelescopique.AvanceRecule(0.35);
}
else {
brasTelescopique.AvanceRecule(0);

View File

@ -17,7 +17,7 @@ import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
import frc.robot.commands.bras.Bougerbras;
public class BasePilotable extends SubsystemBase {
final CANSparkMax avantdroit = new CANSparkMax(Constants.avantdroit, MotorType.kBrushless);