This commit is contained in:
samuel desharnais 2023-12-06 18:01:21 -05:00
parent bfe69cdb13
commit 76db959874
2 changed files with 28 additions and 14 deletions

View File

@ -3,6 +3,8 @@
// the WPILib BSD license file in the root directory of this project. // the WPILib BSD license file in the root directory of this project.
package frc.robot; package frc.robot;
import java.util.Map;
import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.math.MathUtil; import edu.wpi.first.math.MathUtil;
import edu.wpi.first.networktables.GenericEntry; 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.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; 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.Command;
import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; 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.Force7;
import frc.robot.commands.LanceurAuto; import frc.robot.commands.LanceurAuto;
import frc.robot.commands.Force1; import frc.robot.commands.Force1;
import frc.robot.commands.Reculer; import frc.robot.commands.AvancerGauche;
import frc.robot.commands.accumulateurtest; import frc.robot.commands.accumulateurtest;
import frc.robot.subsystems.Accumulateur; import frc.robot.subsystems.Accumulateur;
import frc.robot.subsystems.Drive; import frc.robot.subsystems.Drive;
import frc.robot.subsystems.Lanceur; import frc.robot.subsystems.Lanceur;
public class RobotContainer { public class RobotContainer {
String avancergaucheString = "avancergaucheString";
String avancerautoString = "avancerautoString";
ShuffleboardLayout layoutauto = Shuffleboard.getTab("Dashboard").getLayout("auto", BuiltInLayouts.kList);
SendableChooser<String> chooser = new SendableChooser<>();
Lanceur lanceur = new Lanceur(); Lanceur lanceur = new Lanceur();
Accumulateur accumulateur = new Accumulateur(); Accumulateur accumulateur = new Accumulateur();
Drive drive = new Drive(); Drive drive = new Drive();
Avancer avancer = new Avancer(drive); Avancer avancer = new Avancer(drive);
AvancerGauche avancerGauche = new AvancerGauche(drive);
ShuffleboardTab dashboard = Shuffleboard.getTab("Dashboard"); ShuffleboardTab dashboard = Shuffleboard.getTab("Dashboard");
ShuffleboardLayout forces = Shuffleboard.getTab("Dashboard") ShuffleboardLayout forces = Shuffleboard.getTab("Dashboard")
@ -67,7 +75,9 @@ public class RobotContainer {
} }
private void configureBindings() { private void configureBindings() {
chooser.addOption(avancerautoString, avancerautoString);
chooser.addOption(avancergaucheString, avancergaucheString);
layoutauto.add("choix hauteur", chooser);
accumulateurtest accumulateurtest = new accumulateurtest(accumulateur); accumulateurtest accumulateurtest = new accumulateurtest(accumulateur);
Force1 Force1 = new Force1(lanceur, force1); Force1 Force1 = new Force1(lanceur, force1);
Force2 Force2 = new Force2(lanceur, force2); Force2 Force2 = new Force2(lanceur, force2);
@ -91,10 +101,14 @@ public class RobotContainer {
public Command getAutonomousCommand() { public Command getAutonomousCommand() {
return Commands.deadline(Commands.waitSeconds(12) chooser.getSelected();
,new SequentialCommandGroup(new ParallelCommandGroup(new LanceurAuto(lanceur).withTimeout(6) return new SequentialCommandGroup(new ParallelCommandGroup(new LanceurAuto(lanceur).withTimeout(6)
,new AccAuto(accumulateur).withTimeout(6)) ,new AccAuto(accumulateur).withTimeout(6)), Commands.waitSeconds(6),
)).andThen(avancer); Commands.select(Map.ofEntries(
Map.entry(avancerautoString,avancer),
Map.entry(avancergaucheString, avancerGauche)
), chooser::getSelected)
);
} }
} }

View File

@ -11,7 +11,7 @@ import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj2.command.CommandBase; import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.Drive; import frc.robot.subsystems.Drive;
public class Reculer extends CommandBase { public class AvancerGauche extends CommandBase {
private Drive drive; private Drive drive;
ShuffleboardTab dashboard = Shuffleboard.getTab("Dashboard"); ShuffleboardTab dashboard = Shuffleboard.getTab("Dashboard");
ShuffleboardLayout reculer = Shuffleboard.getTab("Dashboard") ShuffleboardLayout reculer = Shuffleboard.getTab("Dashboard")
@ -19,11 +19,11 @@ public class Reculer extends CommandBase {
.withSize(1, 4) .withSize(1, 4)
.withPosition(6,0); .withPosition(6,0);
/** Creates a new Reculer. */ /** Creates a new Reculer. */
public Reculer(Drive drive) { public AvancerGauche(Drive drive) {
reculer.add("vitesse x", 1); // reculer.add("vitesse x", 1);
reculer.add("vitesse y", 2); //reculer.add("vitesse y", 2);
reculer.add("vitesse z", 3); //reculer.add("vitesse z", 3);
reculer.add("distance", 4); //reculer.add("distance", 4);
this.drive = drive; this.drive = drive;
addRequirements(drive); addRequirements(drive);
// Use addRequirements() here to declare subsystem dependencies. // 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. // Called every time the scheduler runs while the command is scheduled.
@Override @Override
public void execute() { 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. // Called once the command ends or is interrupted.