This commit is contained in:
Olivier Dubois 2024-02-05 19:16:00 -05:00
commit 18bc9052da
3 changed files with 38 additions and 15 deletions

View File

@ -22,6 +22,8 @@ import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
// Commands // Commands
import frc.robot.command.Balayer; import frc.robot.command.Balayer;
import frc.robot.command.GrimpeurDroit;
import frc.robot.command.GrimpeurGauche;
import frc.robot.command.GuiderBas; import frc.robot.command.GuiderBas;
import frc.robot.command.GuiderHaut; import frc.robot.command.GuiderHaut;
import frc.robot.command.Lancer; import frc.robot.command.Lancer;
@ -52,7 +54,8 @@ public class RobotContainer {
Lancerampli lancerampli = new Lancerampli(lanceur); Lancerampli lancerampli = new Lancerampli(lanceur);
CommandJoystick joystick = new CommandJoystick(0); CommandJoystick joystick = new CommandJoystick(0);
CommandXboxController manette = new CommandXboxController(1); CommandXboxController manette = new CommandXboxController(1);
GrimpeurDroit grimpeurDroit = new GrimpeurDroit(grimpeur, manette::getLeftX);
GrimpeurGauche grimpeurGauche = new GrimpeurGauche(grimpeur, manette::getLeftY);
public RobotContainer() { public RobotContainer() {
NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur)); NamedCommands.registerCommand("balayer",new Balayer(balayeuse, accumulateur));
NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur)); NamedCommands.registerCommand("lancer", new LancerNote(lanceur, accumulateur));
@ -69,8 +72,8 @@ public class RobotContainer {
} }
private void configureBindings() { private void configureBindings() {
joystick.button(3).toggleOnTrue(balayer); joystick.button(3).toggleOnTrue(balayer);
} }

View File

@ -4,13 +4,17 @@
package frc.robot.command; package frc.robot.command;
import java.util.function.DoubleSupplier;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystem.Grimpeur; import frc.robot.subsystem.Grimpeur;
public class GrimpeurHautDroit extends Command { public class GrimpeurDroit extends Command {
private DoubleSupplier doubleSupplier;
private Grimpeur grimpeur; private Grimpeur grimpeur;
/** Creates a new GrimpeurHaut. */ /** Creates a new GrimpeurHaut. */
public GrimpeurHautDroit(Grimpeur grimpeur) { public GrimpeurDroit(Grimpeur grimpeur, DoubleSupplier doubleSupplier) {
this.doubleSupplier = doubleSupplier;
this.grimpeur = grimpeur; this.grimpeur = grimpeur;
addRequirements(grimpeur); addRequirements(grimpeur);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
@ -20,26 +24,32 @@ public class GrimpeurHautDroit extends Command {
@Override @Override
public void initialize() { public void initialize() {
grimpeur.resetencodeurd(); grimpeur.resetencodeurd();
grimpeur.resetencodeurg(); grimpeur.pistonferme();
} }
// 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() {
grimpeur.droit(doubleSupplier.getAsDouble());
if(grimpeur.encoderd()>261 ){ if(grimpeur.encoderd()>261){
grimpeur.droit(0); grimpeur.droit(0);
} }
else if(grimpeur.getpitch()<-15){ else if(grimpeur.getpitch()<-15){
grimpeur.droit(-0.6); grimpeur.droit(-doubleSupplier.getAsDouble());
} }
else if(grimpeur.getpitch()>15){ else if(grimpeur.getpitch()>15){
grimpeur.droit(0.6); grimpeur.droit(doubleSupplier.getAsDouble());
} }
else{ else{
grimpeur.droit(0); grimpeur.droit(0);
} }
if(grimpeur.encoderd()>0){
grimpeur.resetencodeurd();
grimpeur.droit(0);
}
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.

View File

@ -4,13 +4,17 @@
package frc.robot.command; package frc.robot.command;
import java.util.function.DoubleSupplier;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystem.Grimpeur; import frc.robot.subsystem.Grimpeur;
public class GrimpeurHautGauche extends Command { public class GrimpeurGauche extends Command {
private DoubleSupplier doubleSupplier;
private Grimpeur grimpeur; private Grimpeur grimpeur;
/** Creates a new GrimpeurHautGauche. */ /** Creates a new GrimpeurHautGauche. */
public GrimpeurHautGauche(Grimpeur grimpeur) { public GrimpeurGauche(Grimpeur grimpeur,DoubleSupplier doubleSupplier) {
this.doubleSupplier = doubleSupplier;
this.grimpeur = grimpeur; this.grimpeur = grimpeur;
addRequirements(grimpeur); addRequirements(grimpeur);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
@ -26,19 +30,25 @@ public class GrimpeurHautGauche extends Command {
// 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() {
if(grimpeur.encoderg()>261 ){ grimpeur.gauche(doubleSupplier.getAsDouble());
if(grimpeur.encoderg()>261){
grimpeur.gauche(0); grimpeur.gauche(0);
} }
else if(grimpeur.getpitch()<-15){ else if(grimpeur.getpitch()<-15){
grimpeur.gauche(0.6); grimpeur.gauche(doubleSupplier.getAsDouble());
} }
else if(grimpeur.getpitch()>15){ else if(grimpeur.getpitch()>15){
grimpeur.gauche(-0.6); grimpeur.gauche(-doubleSupplier.getAsDouble());
} }
else{ else{
grimpeur.gauche(0); grimpeur.gauche(0);
} }
if(grimpeur.encoderd()>0){
grimpeur.resetencodeurg();
grimpeur.gauche(0);
}
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.