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.
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<String> 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)
);
}
}

View File

@ -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.