From 76db95987428fe8fa9059cc1d67ea877902c8dd4 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Wed, 6 Dec 2023 18:01:21 -0500 Subject: [PATCH] gfhgvbm --- src/main/java/frc/robot/RobotContainer.java | 28 ++++++++++++++----- .../{Reculer.java => AvancerGauche.java} | 14 +++++----- 2 files changed, 28 insertions(+), 14 deletions(-) rename src/main/java/frc/robot/commands/{Reculer.java => AvancerGauche.java} (84%) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index f3ed18d..ce14323 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -3,6 +3,8 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot; +import java.util.Map; + import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.math.MathUtil; import edu.wpi.first.networktables.GenericEntry; @@ -10,6 +12,7 @@ import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; 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.ParallelCommandGroup; @@ -29,18 +32,23 @@ import frc.robot.commands.Force6; import frc.robot.commands.Force7; import frc.robot.commands.LanceurAuto; import frc.robot.commands.Force1; -import frc.robot.commands.Reculer; +import frc.robot.commands.AvancerGauche; import frc.robot.commands.accumulateurtest; import frc.robot.subsystems.Accumulateur; import frc.robot.subsystems.Drive; import frc.robot.subsystems.Lanceur; public class RobotContainer { + +String avancergaucheString = "avancergaucheString"; +String avancerautoString = "avancerautoString"; + ShuffleboardLayout layoutauto = Shuffleboard.getTab("Dashboard").getLayout("auto", BuiltInLayouts.kList); + SendableChooser chooser = new SendableChooser<>(); Lanceur lanceur = new Lanceur(); Accumulateur accumulateur = new Accumulateur(); Drive drive = new Drive(); Avancer avancer = new Avancer(drive); - + AvancerGauche avancerGauche = new AvancerGauche(drive); ShuffleboardTab dashboard = Shuffleboard.getTab("Dashboard"); ShuffleboardLayout forces = Shuffleboard.getTab("Dashboard") @@ -67,7 +75,9 @@ public class RobotContainer { } private void configureBindings() { - + chooser.addOption(avancerautoString, avancerautoString); + chooser.addOption(avancergaucheString, avancergaucheString); + layoutauto.add("choix hauteur", chooser); accumulateurtest accumulateurtest = new accumulateurtest(accumulateur); Force1 Force1 = new Force1(lanceur, force1); Force2 Force2 = new Force2(lanceur, force2); @@ -91,10 +101,14 @@ public class RobotContainer { public Command getAutonomousCommand() { - return Commands.deadline(Commands.waitSeconds(12) - ,new SequentialCommandGroup(new ParallelCommandGroup(new LanceurAuto(lanceur).withTimeout(6) - ,new AccAuto(accumulateur).withTimeout(6)) - )).andThen(avancer); + chooser.getSelected(); + return new SequentialCommandGroup(new ParallelCommandGroup(new LanceurAuto(lanceur).withTimeout(6) + ,new AccAuto(accumulateur).withTimeout(6)), Commands.waitSeconds(6), + Commands.select(Map.ofEntries( + Map.entry(avancerautoString,avancer), + Map.entry(avancergaucheString, avancerGauche) + ), chooser::getSelected) + ); } } diff --git a/src/main/java/frc/robot/commands/Reculer.java b/src/main/java/frc/robot/commands/AvancerGauche.java similarity index 84% rename from src/main/java/frc/robot/commands/Reculer.java rename to src/main/java/frc/robot/commands/AvancerGauche.java index 9571c64..671bb93 100644 --- a/src/main/java/frc/robot/commands/Reculer.java +++ b/src/main/java/frc/robot/commands/AvancerGauche.java @@ -11,7 +11,7 @@ import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.subsystems.Drive; -public class Reculer extends CommandBase { +public class AvancerGauche extends CommandBase { private Drive drive; ShuffleboardTab dashboard = Shuffleboard.getTab("Dashboard"); ShuffleboardLayout reculer = Shuffleboard.getTab("Dashboard") @@ -19,11 +19,11 @@ public class Reculer extends CommandBase { .withSize(1, 4) .withPosition(6,0); /** Creates a new Reculer. */ - public Reculer(Drive drive) { - reculer.add("vitesse x", 1); - reculer.add("vitesse y", 2); - reculer.add("vitesse z", 3); - reculer.add("distance", 4); + public AvancerGauche(Drive drive) { + // reculer.add("vitesse x", 1); + //reculer.add("vitesse y", 2); + //reculer.add("vitesse z", 3); + //reculer.add("distance", 4); this.drive = drive; addRequirements(drive); // Use addRequirements() here to declare subsystem dependencies. @@ -36,7 +36,7 @@ public class Reculer extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - drive.drive(-0.5, -0.2, 0); + drive.drive(0.5, 0.2, 0); } // Called once the command ends or is interrupted.