This commit is contained in:
samuel desharnais 2023-12-04 18:58:37 -05:00
parent 5f64677db7
commit ee7d39effc
3 changed files with 55 additions and 12 deletions

View File

@ -16,6 +16,7 @@ import edu.wpi.first.wpilibj2.command.button.CommandJoystick;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.commands.Avancer; import frc.robot.commands.Avancer;
import frc.robot.commands.Lancer; import frc.robot.commands.Lancer;
import frc.robot.commands.LancerTest;
import frc.robot.commands.Force2; import frc.robot.commands.Force2;
import frc.robot.commands.Force3; import frc.robot.commands.Force3;
import frc.robot.commands.Force4; import frc.robot.commands.Force4;
@ -39,12 +40,12 @@ public class RobotContainer {
.getLayout("forces", BuiltInLayouts.kList) .getLayout("forces", BuiltInLayouts.kList)
.withSize(3, 7); .withSize(3, 7);
GenericEntry force1 = forces.add("Force1", 2).getEntry(); GenericEntry force1 = forces.add("Force1", 2).getEntry();
GenericEntry force2 = forces.add("Force2", 0).getEntry(); GenericEntry force2 = forces.add("Force2", 4).getEntry();
GenericEntry force3 = forces.add("Force3", 0).getEntry(); GenericEntry force3 = forces.add("Force3", 6).getEntry();
GenericEntry force4 = forces.add("Force4", 0).getEntry(); GenericEntry force4 = forces.add("Force4", 8).getEntry();
GenericEntry force5 = forces.add("Force5", 0).getEntry(); GenericEntry force5 = forces.add("Force5", 10).getEntry();
GenericEntry force6 = forces.add("Force6", 0).getEntry(); GenericEntry force6 = forces.add("Force6", 12).getEntry();
GenericEntry force7 = forces.add("Force7", 0).getEntry(); GenericEntry force7 = forces.add("Force7", 14).getEntry();
CommandXboxController manette = new CommandXboxController(0); CommandXboxController manette = new CommandXboxController(0);
CommandJoystick joystick1 = new CommandJoystick(0); CommandJoystick joystick1 = new CommandJoystick(0);
@ -60,14 +61,16 @@ public class RobotContainer {
private void configureBindings() { private void configureBindings() {
accumulateurtest accumulateurtest = new accumulateurtest(accumulateur); accumulateurtest accumulateurtest = new accumulateurtest(accumulateur);
joystick1.button(7).onTrue(new Lancer(lanceur, accumulateur, force1)); LancerTest lancertest = new LancerTest(lanceur);
joystick1.button(8).onTrue(new Lancer(lanceur, accumulateur, force2)); // joystick1.button(7).onTrue(new Lancer(lanceur, accumulateur, force1));
/* joystick1.button(8).onTrue(new Lancer(lanceur, accumulateur, force2));
joystick1.button(9).onTrue(new Lancer(lanceur, accumulateur, force3)); joystick1.button(9).onTrue(new Lancer(lanceur, accumulateur, force3));
joystick1.button(10).onTrue(new Lancer(lanceur, accumulateur, force4)); joystick1.button(10).onTrue(new Lancer(lanceur, accumulateur, force4));
joystick1.button(11).onTrue(new Lancer(lanceur, accumulateur, force5)); joystick1.button(11).onTrue(new Lancer(lanceur, accumulateur, force5));
joystick1.button(12).onTrue(new Lancer(lanceur, accumulateur, force6)); joystick1.button(12).onTrue(new Lancer(lanceur, accumulateur, force6));*/
joystick1.button(3).onTrue(new Lancer(lanceur, accumulateur, force7)); // joystick1.button(3).onTrue(new Lancer(lanceur, accumulateur, force7));
joystick1.button(5).toggleOnTrue(accumulateurtest); joystick1.button(5).whileTrue(accumulateurtest);
joystick1.button(1).whileTrue(lancertest);
} }

View File

@ -28,7 +28,7 @@ public class Lancer extends ParallelCommandGroup {
// Add your commands in the addCommands() call, e.g. // Add your commands in the addCommands() call, e.g.
// addCommands(new FooCommand(), new BarCommand()); // addCommands(new FooCommand(), new BarCommand());
addCommands(new Lancez(lanceur), addCommands(new Lancez(lanceur),
new SequentialCommandGroup(new WaitUntilCommand(()->lanceur.vitesse()>vitesse.getDouble(0))) new SequentialCommandGroup(new WaitUntilCommand(()->lanceur.vitesse()>vitesse.getDouble(1)))
,new AccAvancer(accumulateur),new AccReculer(accumulateur)); ,new AccAvancer(accumulateur),new AccReculer(accumulateur));
} }
} }

View File

@ -0,0 +1,40 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.Lanceur;
public class LancerTest extends CommandBase {
private Lanceur lanceur;
/** Creates a new LancerTest. */
public LancerTest(Lanceur lanceur) {
this.lanceur = lanceur;
addRequirements(lanceur);
// Use addRequirements() here to declare subsystem dependencies.
}
// Called when the command is initially scheduled.
@Override
public void initialize() {}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
lanceur.lancer(0.5);
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
lanceur.lancer(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}